Odoo Help

0

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

By
Laurens
on 6/12/13, 1:21 PM 1,349 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?

1

Ray Carnes

--Ray Carnes--
16009
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

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

Completed Odoo Functional and Technical Training.

Major Skills:

  • 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.

Laurens
on 6/14/13, 9:19 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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.

Register

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)

Stats

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