Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
4 Відповіді
8734 Переглядів

Hi

How can i add a custom field in account.invoice

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

Аватар
Відмінити
Найкраща відповідь

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

My pleasure :)

Найкраща відповідь

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

Аватар
Відмінити
Найкраща відповідь

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

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

Автор Найкраща відповідь

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

 

Аватар
Відмінити