Odoo Help

Welcome!

This community 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.

0

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

By
Laurens
on 6/12/13, 1:21 PM 1,291 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--
15677
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

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. 

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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