Odoo Help


Where in account module do fields get copied over? [From SO --> Invoice]

on 6/12/13, 1:21 PM 1,753 views

In what file, and where, can I find where fields get copied over from the Sale Order to the invoice? For instance client_order_ref --> name and payment_term.

I want to copy my custom field value over to another custom field I have under the invoices. But I can not find where I have to inherit.

Can someone show me where this happens?


Ray Carnes

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

Ray Carnes
On 6/12/13, 1:54 PM

It isn't the account module, it is the sale module.

sale.order has a _make_invoice method that uses the order lines to create an Invoice.

The python for adding the new field to the invoice (assuming both custom fields already exist on sale.order and account.invoice) might look something like this:

from openerp.osv import fields,osv
from tools.translate import _

class sale_order(osv.osv):
    _inherit = 'sale.order'

def _make_invoice(self, cr, uid, order, lines, context=None):
    inv_id = super(sale_order, self)._make_invoice(cr, uid, order, lines, context)
    inv_obj = self.pool.get('account.invoice')
    if order.name_of_custom_order_field:
        inv_obj.write(cr, uid, [inv_id], {'name_of_custom_invoice_field': order.name_of_custom_order_field.id}, context=context)
    return inv_id

(I copied this from an example so I haven't actually tested the code).

The original function above you are overriding is in addons\sale\sale.py

Thanks Ray, I had found it already; guess I was just braindead for a moment. Obviously the function is called in the sale model. Already made my module, and it's up and running. However your instruction was spot on, great feedback man.

on 6/14/13, 9:19 AM

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

0 follower(s)


Asked: 6/12/13, 1:21 PM
Seen: 1753 times
Last updated: 3/16/15, 8:10 AM