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'
Solution 1:
Try this:
def create_invoice(self):
for rec in self:
invoice = rec.env['account.move'].create({
'move_type': 'out_invoice',
# 'partner_id': self.partner.id,
'journal_id': 18, # say u forget to create journal
# 'currency_id': self.env.ref('base.USD').id,
'payment_reference': 'invoice to client',
'invoice_line_ids': [(0, 0, {
'product_id': self.env['product.product'].create({'name': 'A Test Product'}),
'quantity': 1,
'price_unit': 40,
'name': 'Your project product',
})],
})
Post a Comment for "How Do I Transfer Data From Sale Order To Invoice When Clicking On 'create Invoice' In Odoo 14 Or Flectra 1.7?"