Openerp 在自定义模块的多个字段中添加多个产品应转换为发票行

Openerp 在自定义模块的多个字段中添加多个产品应转换为发票行,openerp,odoo-8,odoo-9,Openerp,Odoo 8,Odoo 9,我正在我的字段中添加多个产品。现在我有两个产品列表,可以自动将这些产品列表逐个转换为发票行。单击时,我会创建一个按钮,它将自动创建发票。但无法添加产品的发票行 谁能帮我一个接一个地把这些产品添加到发票行中 您需要调用create方法,其中包含一组具有当前poduct id的值: @api.one def _add_to_invoice(self): #you need to pass the the id of the product to the invoice and add othe

我正在我的字段中添加多个产品。现在我有两个产品列表,可以自动将这些产品列表逐个转换为发票行。单击时,我会创建一个按钮,它将自动创建发票。但无法添加产品的发票行


谁能帮我一个接一个地把这些产品添加到发票行中

您需要调用create方法,其中包含一组具有当前poduct id的值:

@api.one
def _add_to_invoice(self):
   #you need to pass the the id of the product to the invoice and add others  
   #fields too
   self.env['invoice'].create({'product_id',int(self.id),'field_one':your_value})

您需要使用具有当前poduct id的值的字典调用create方法:

@api.one
def _add_to_invoice(self):
   #you need to pass the the id of the product to the invoice and add others  
   #fields too
   self.env['invoice'].create({'product_id',int(self.id),'field_one':your_value})