Odoo Help


Openerp 7 Functional Field Help [Closed]

on 3/6/14, 1:55 PM 1,157 views

The Question has been closed

Sudhir Arya (ERP Harbor Consulting Services)
on 03/07/2014 02:35:34

I am trying to create a functional field by inheriting the account.invoice.line table, but I cant seem to get it working. Here is the python code

class account_invoice_line(orm.Model):
_name = 'account.invoice.line'
_inherit = 'account.invoice.line'

_columns = {        
    'calc_qty': fields.function(_get_calc_qty, type="float", string="Quantity", store=False),

def _get_calc_qty(self, cr, uid, ids, field_name, arg, context=None):
    calc_qty = {'qty': 0.0}
    return calc_qty

and here is the xml view code

<record id="view_account_invoice_custom_form_inherit" model="ir.ui.view">
    <field name="name">Account Invoice Form Inherited</field>
    <field name="model">account.invoice</field>
    <field name="inherit_id" ref="account.invoice_form"/>
    <field name="arch" type="xml">

        <xpath expr="/form/sheet/notebook/page[@string='Invoice Lines']/field[@name='invoice_line']/tree/field[@name='quantity']" position="replace">
            <field name="calc_qty" />


Now I dont want to store this value in the table, but I would like to show the calculated number in the view. I know this is possible, but after I install the module and then check the invoices form then I get this message

image description


Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 3/6/14, 2:48 PM

Try it again after restarting the OpenERP server.

Tried it again by removing _name. You just need to use _inherit

If you already have tried this then make sure you have imported your py file in __init__.py.

As per the error it seems your code is not getting updated.

Thank you Sudhir! It turned out that all I needed to do was to import the python file in the __init__.py file. I forgot to add that in haha.

on 3/6/14, 2:59 PM

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: 3/6/14, 1:55 PM
Seen: 1157 times
Last updated: 3/16/15, 8:10 AM