我想在发票中添加很多2个字段,但是当我使用_prepare_invoice方法时,我得到了一个空字段,并且在x_fleet_vehicle_invoice_rel表中没有记录!所以希望有人可以帮助我...
class SaleOrderInherited(models.Model):
_inherit = 'sale.order'
order_field = fields.Many2many('fleet.vehicle', 'x_fleet_vehicle_sale_order_rel', 'order_id', 'vehicle_id', string='Order Field ')
@api.multi
def _prepare_invoice(self):
res = super(SaleOrder, self)._prepare_invoice()
res['invoice_field'] = self.order_field
return res
class AccountInvoiceInherited(models.Model):
_inherit = 'account.invoice'
invoice_field = fields.Many2many('fleet.vehicle', 'x_fleet_vehicle_invoice_rel', 'invoice_id', 'vehicle_id', string='Invoice Field')
答案 0 :(得分:0)
尝试res['invoice_field'] = [(6, 0, self.order_field.ids)]
更多信息:http://odoo-development.readthedocs.io/en/latest/dev/py/x2many.html