Odoo Help

0

I can't add fields in account_invoice, why?

By
wizardz
on 12/4/15, 3:38 AM 822 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.

1
Axel Mendoza
On 12/5/15, 3:05 AM

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

1
Zbik
On 12/5/15, 6:27 AM

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

0
dorsaf dhouibi
On 7/31/17, 11:32 AM

The name of the view is wrong 

ref="account.view_invoice_form"

the correct one is 

ref="account.invoice_form"



0

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. :)


0
wizardz
On 12/4/15, 3:47 AM

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>

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.

Register

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

2 follower(s)

Stats

Asked: 12/4/15, 3:38 AM
Seen: 822 times
Last updated: 7/31/17, 11:32 AM