Hi,
I am overriding _prepare_invoice in a custom module to copy the value of a sale order field to an invoice one.
But it doesn't work.
This is my code:
class XOrder(models.Model):
_inherit = 'sale.order'
payment_method = fields.Selection([
('transfer', 'Transfer'),
('credit_card', 'Credit Card'),
('check', 'Check'),
('cash', 'Cash')
])
@api.v7
def _prepare_invoice(self, cr, uid, order, lines, context=None):
res = super(XOrder, self)._prepare_invoice(cr, uid, order, lines, context=context)
res.update({'payment_method' : order.payment_method})
return res
class XInvoice(models.Model):
_inherit = 'account.invoice'
payment_method = fields.Selection([
('transfer', 'Transfer'),
('credit_card', 'Credit Card'),
('check', 'Check'),
('cash', 'Cash')
])
Could someone help ?
If I also override _make_invoice it works but I don't know if it is the right way.
Just remove this line: