Odoo Help


Views Inheritance issue : Customize invoice_form "Customer Invoices" ; v7

Yassine TEIMI
on 12/30/14, 9:43 AM 1,515 views

I'm trying to customize the invoice form, especially the Customer invoices form, I'm just trying to add a date field after the invoice date, and replace a button, for that I created a new module, here after the code : 

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

class AccountInvoice(orm.Model):

    _inherit = 'account.invoice'
    _name = 'account.invoice'
    _colmuns = {
        'date_livraison': fields.date('Date Livraison'),

For the view : 

        <record id="invoice_form_custom" model="ir.ui.view">
            <field name="name">invoice.form.custom</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">

                <xpath expr="//form/header/button[@name='invoice_open']" position="replace">
                   <button name="invoice_validate" states="draft" string="Valider" type="object" class="oe_highlight"/>
                <xpath expr="//form/sheet/group/group/field[@name='date_invoice]" position="after">
                    <field name="date_livraison"/>


Three points deserves interest : 

When commenting the inheritance of date_livraison, it rises XML architecture error,then, the replacement of the button is correct, and the inheritance for date_livraison is not correct.

The account.invoice inherits from mail.thread like this : 

    _name = "account.invoice"
    _inherit = ['mail.thread']

And invoice_form is a view used also for Customer refund.

Is that may cause some problems when customizing invoice_form view, or just I'm missing something on the xml code ?

In original "account.invoice_form" are two buttons named 'invoice_open', you have not specified clearly that replacing.

on 12/30/14, 12:29 PM

but when I remove the second inheritance, it works fine, so the problem is wieh the field "date_livraison", it's not recognized as a field added by inheritance !!

Yassine TEIMI
on 12/30/14, 12:47 PM
sameer alhwety
On 12/31/14, 4:16 AM

from openerp.osv import fields, osv, orm

class AccountInvoice(osv.osv):

    _inherit = 'account.invoice'
    _columns = {
        'date_livraison': fields.date('Date Livraison'),

Yes, that's right, I used to inherit with "orm.Model", when adding fields, it's considered among the best practices of inheritance, why it didn't work here ?

Yassine TEIMI
on 12/31/14, 5:12 AM
Aitor Bouzas
On 12/30/14, 12:53 PM

Hi Yassine,

I can see in your code that instead of "_columns" it says "_colmuns"... Could this be your problem?

Hi Aitor, No it's just here, it's right on the source code.

Yassine TEIMI
on 12/31/14, 5:09 AM

In fact, I should inherit with "osv.osv" check my comment for sameer.

Yassine TEIMI
on 12/31/14, 5:13 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

1 follower(s)


Asked: 12/30/14, 9:43 AM
Seen: 1515 times
Last updated: 3/16/15, 8:10 AM