Skip to Content
Menu
This question has been flagged
2 Replies
2258 Views

I add a new field x_objt to the quote and invoice. When I create the invoice from the quote I want the value of the x_objt field of the quote to be filled in on the x_objt field of the invoice exactly like the other standard fields
How can I do ?
Thanks

Avatar
Discard
Best Answer

OKay here you will need to inherit the function that prepares the invoice from the quotation.

the def _prepare_invoice is the one that is doing this for us so we are going to inherit it and pass our field to the invoice:

class sale_order(models.Model):
    _inherit = "sale.order"

    @api.multi
    def _prepare_invoice(self):
        invoice_vals = super(sale_order, self)._prepare_invoice()
        invoice_vals['x_objt'] = self.x_objt
        return invoice_vals


and other one is needed on the account.invoice model:

class sale_advance_payment_inv(models.TransientModel):
    _inherit = "sale.advance.payment.inv"

    @api.multi
    def _create_invoice(self, order, so_line, amount):
        invoice = super(sale_advance_payment_inv, self)._create_invoice(order, so_line, amount)
        invoice.x_objt = order.x_objt

There it is, now the field x_objt will be passed to the invoice, just make sure you create this field on the sale.order and on the account.invoice model as well.


Riste Kabranov

odoo developer at simplify-erp.com

Avatar
Discard
Author Best Answer

Thank you
I made the changes on the mother functions and it works
If I want to use inheritance, how do I call the created functions?

Avatar
Discard