Skip to Content
Menu
This question has been flagged
5 Replies
4369 Views

I want to add this, but it's not working:


account_invoice.py

# -*- coding: utf-8 -*-

from openerp import api
from openerp.osv import fields, osv


class account_invoice(osv.osv):
_inherit = 'account.invoice'


_columns = {
'notes_header': fields.text(''),
'notes_footer': fields.text('')
}

class account_invoice_line(osv.osv):
_inherit = 'account.invoice.line'

_columns = {
'product_position': fields.char(''),
'product_note': fields.text('')
}


account_invoice.xml

<?xml version="1.0" encoding="utf-8"?>

<openerp>
<data>
<record id="account_invoice_form_ext_view" model="ir.ui.view">
<field name="name">account.invoice.form.ext</field>
<field name="model">account.invoice</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_invoice_form" />
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='comment']" position="after">
<field name="notes_header" placeholder="Kopfzeile" />
<field name="notes_footer" placeholder="Fusszeile" />
</xpath>
</field>
</record>



<record model="ir.ui.view" id="invoice_margin_percent_1">
<field name="name">account.margin.percent.view.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.view_invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line']/form//field[@name='product_id']" position="before">
<field name="product_position"/>
</xpath>
<xpath expr="//field[@name='invoice_line']/form//field[@name='name']" position="before">
<field name="product_note"/>
</xpath>
</field>
</record>


</data>
</openerp>

Can someone help me ? I wanna add 2 fields in account_invoice under comment or above, and then a column "position" in the invoice_order_line.

Avatar
Discard
Best Answer

Hi @wizardz

Check that you are importing the .py that contains the account.invoice extension in your module __init__.py file, perhaps you forget to import the file that contains the extension

Avatar
Discard
Best Answer

1) You restart server after change code .py

2) Verify how many instances of odoo server you have, should be one.

3) Do not forget to add  'depends': ['account']  in __openerp__.py

4) Do not forget to add your_file_name.py to __init__.py

Avatar
Discard
Best Answer

The name of the view is wrong 

ref="account.view_invoice_form"

the correct one is 

ref="account.invoice_form"



Avatar
Discard
Best Answer

In Python file:

class size_details_line(osv.Model):
_name = 'account.invoice.line'
_inherit = 'account.invoice.line'
_description = ''
_columns = {
'the_size': fields.text('The Size', size=30),
}

In XML File:


<record id="account_invoice_adding_form" model="ir.ui.view">
<field name="name">account.invoiceee.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//tree[@string='Invoice Lines']/field[@name='product_id']" position="after" > 
<field name="the_size" />
</xpath>
</field>
</record>


This should do the trick. I am doing this way. :)


Avatar
Discard
Author Best Answer

I get this error all time:

Error details:

Das Feld `notes_header` existiert nicht

Fehler Kontext:
Ansicht `account.invoice.form.ext`
[view_id: 1741, xml_id: k. A., model: account.invoice, parent_id: 470]" while parsing /opt/odoo/custom_addons/satsolar_custom/views/account_invoice.xml:4, near
<record id="account_invoice_form_ext" model="ir.ui.view">
<field name="name">account.invoice.form.ext</field>
<field name="model">account.invoice</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='comment']" position="after">
<field name="notes_header" placeholder="Kopfzeile"/>
<field name="notes_footer" placeholder="Fusszeile"/>
</xpath>
</field>
</record>
Avatar
Discard
Related Posts Replies Views Activity
1
Nov 16
6150
1
Mar 15
4098
1
Mar 15
4578
2
Apr 24
279
1
Dec 22
4102