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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
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?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up