![](/img/trans.png)
[英]Odoo 12 : How to pop up a message when “Save” button is clicked on sale.order model?
[英]Load custom model and add a field to pos.order.line in Point of Sale - Odoo 12
需要一个示例工作代码,以便我可以尝试更好地了解它在 Odoo 12 中的销售点应用程序上的工作原理。
我正在尝试向“pos.order.line”添加一个新的自定义字段以用于销售点应用程序,但我对 Odoo 12 pos 不满意。
这个新领域依赖于我为产品使用而创建的新模型。 我将此字段添加到模型中,我需要在每个产品的每个 pos 订单行上自动填写它。
它类似于“税收”,如果用户选择产品,Odoo 会自动在 pos“订单行”上设置税收信息。
为了更好地理解,我将尝试重现我迄今为止完成的步骤。
1. 新模型:对于这个例子,我将称之为“类型”。
这个模型将填充“几种”类型并添加到我拥有的每个产品中。
class Types(models.Model):
_name = 'types'
_description = 'Sample Types Model'
code = fields.Char('Code', required=True)
name = fields.Char('Description', required=True)
2.这个“类型”信息将添加到我拥有的每个产品中,因此,我在“products.template”模型中添加了一个新字段:
class ProductTemplate(models.Model):
_inherit = "product.template"
types_id = fields.Many2one('types', string='Product specific type')
3.由于我需要在每个 pos 订单行上显示此值,因此我使用相同的方法将该字段添加到“pos.order.line”模型中:
class PosOrderLine(models.Model):
_inherit = "pos.order.line"
types_id = fields.Many2one('types', string='Product specific type')
4. 问题由此开始。
我需要加载新模型和添加到“product.template”的新字段,并在将产品添加到购物篮时为“pos.order.line”上的每个产品编写默认“类型”。
在 PoS 上,我需要:
加载新模型和字段;
当订单添加到篮子时,将值写入 pos.order.line;
有人可以帮我吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.