Odoo Help


import new field values from sale_order to invoice

on 12/7/15, 4:40 AM 708 views


I have a new field in sale_order named: myfield

Now when I create a invoice from the sale_order , the myfield value is empty in invoice.

How can I move the value from my new field to invoice, when it creates a new invoice from the sale_order.

I tried something like this:

I see that the _prepare_invoice function is used to put values from sale_order to invoice.

Now when I make something like this it's not working.

I have the same field in invoice like "myfield" in sale_order:

def _prepare_invoice(self, cr, uid, order, lines, context=None):
"""Prepare the dict of values to create the new invoice for a
sales order. This method may be overridden to implement custom
invoice generation (making sure to call super() to establish
a clean extension chain).

:param browse_record order: sale.order record to invoice
:param list(int) line: list of invoice line IDs that must be
attached to the invoice
:return: dict of value to create() the invoice
if context is None:
context = {}
journal_ids = self.pool.get('account.journal').search(cr, uid,
[('type', '=', 'sale'), ('company_id', '=', order.company_id.id)],
if not journal_ids:
raise osv.except_osv(_('Error!'),
_('Please define sales journal for this company: "%s" (id:%d).') % (order.company_id.name, order.company_id.id))
invoice_vals = {
'myfield': order.myfield,


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/7/15, 4:40 AM
Seen: 708 times
Last updated: 12/7/15, 9:37 AM