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.

2

Add New Field in account.invoice

By
Mohammed Roshan
on 2/9/15, 11:13 PM 1,614 views

Hi

How can i add a custom field in account.invoice

N.B: there is no _columns in account.invoice

3

Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
3577
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 2/10/15, 12:33 AM

In V8, you don't need to provide _columns={}. Go through this for clear description.

Base:
class account_invoice(models.Model):
    _name = 'account.invoice'
    name = fields.Char(string='Reference/Description') #Base field

Your module:
class account_invoice(models.Model):
    _inherit = 'account.invoice'
    description = fields.Char(string='Your Description') #Inherited Field

4

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--


Jusab Sida (jsi)
On 2/10/15, 1:05 AM

Hi Mohammed Roshan,

        In the V8, account.invoce is migrated in new api.

So, here you can see _columns is not present but you can inherite it both way.

By new api or as per Vasanth discribe.

Hope this will help.....

Well Done Jusab.... Ur 1st answer is great!!! Welcome to odoo help forum...

aci aisha
on 2/10/15, 1:23 AM

My pleasure :)

Jusab Sida (jsi)
on 2/10/15, 1:38 AM
2

Vasanth

--Vasanth--
3458
| 5 3 8
Pondicherry, India
--Vasanth--
Vasanth
On 2/9/15, 11:48 PM

Hi Mohammed,

you can add the custom field by using inheritance.By inheritance you can add or remove or update any columns in the table.

for example:

 

In the .py file:

class account_invoice(orm.Model):
    _inherit="account.invoice"
    _columns={
            'your_field':fields.char('New Field')
}

 

in the xml view:

        <record id="account_invoice_form_inherit" model="ir.ui.view">
            <field name="name">account.invoice.form.example</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
                <field name="date_invoice" position="after">

                     <field name="your_field" />
                </field>
            </field>
        </record>

Hi Vasanth i tried the above method, its not the way to accomplish it in account.invoice. if you go through the account_invoice, you will find there is no _columns present and "( _columns={ 'your_field':fields.char('New Field') }) " this method is not followed in it. its something else anyways thanks for your answer

Mohammed Roshan
on 2/10/15, 12:23 AM

In v8,we dont need _columns.we can inherit by using _inherit="account.invoice" and add new fields in the _columns

Vasanth
on 2/10/15, 12:36 AM
1
Mohammed Roshan
On 2/10/15, 12:02 AM

Hi Vasanth

i tried the above method, its not the way to accomplish it in account.invoice.

if you go through the account_invoice, you will find there is no _columns present and

"( _columns={
            'your_field':fields.char('New Field')
}) "
  

this method is not followed in it.

its something else

anyways thanks for your answer

 

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: 2/9/15, 11:13 PM
Seen: 1614 times
Last updated: 3/16/15, 8:10 AM