I run Flectra inside a Docker container. I have custom fields in sale.order which I want to transfer to account.invoice.
class SaleOrder(models.Model):
_inherit = 'sale.order'
myField = fields.Integer(string='My Field', default=21, required = True)
@api.multi
def _prepare_invoice(self):
res = super(SaleOrder, self)._prepare_invoice()
# res.update({
# 'myField': self.myField,
# })
res['myField'] = self.myField
return res
class SaleInvoice(models.Model):
_inherit = 'account.invoice'
myField = fields.Integer(string='My Field', default=21, required = True)
I tried to override _prepare_invoice and also _create_invoices in different variations, but none worked. From my understanding they should have worked, but I am new to Odoo/Flectra, so I would be happy for any help.
I use Flectra 1.7 (Community Edition) which I think corresponds to Odoo 14.
question from:
https://stackoverflow.com/questions/66067896/how-do-i-transfer-data-from-sale-order-to-invoice-when-clicking-on-create-invoi 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…