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

I can't add fields in account_invoice, why?

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

--Axel Mendoza--
10205
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


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

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>

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

2 follower(s)

Stats

Asked: 12/4/15, 3:38 AM
Seen: 502 times
Last updated: 12/6/15, 9:33 AM