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

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

By
Yassine TEIMI
on 12/30/14, 9:43 AM 934 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>
                <xpath expr="//form/sheet/group/group/field[@name='date_invoice]" position="after">
                    <field name="date_livraison"/>
                </xpath>


            </field>
        </record>

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.

zbik
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
0
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
1
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

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

1 follower(s)

Stats

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