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