Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
495 views
in Technique[技术] by (71.8m points)

python - How Do I transfer data from sale order to invoice when clicking on 'Create Invoice' in Odoo 14 or Flectra 1.7?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...