Skip to Content
Menu
This question has been flagged
1 Reply
3483 Views

I am trying to add an extra field to Odoo invoicing app after installing my custom app.

I didn't get any error while loading the server, and I can see from the developer mode's Edit View Form that my view is inherited. However, I cannot see the new field showing up in the invoice form.

models.py:

class einvoice_tw(models.Model):

    _inherit = 'account.invoice'
​    _name = 'einvoice_tw.einvoice_tw'

    _description = 'Taiwan E-Invoice'

    e_invoice_number = fields.Char(string='E-Invoice No.', required=True)

    is_used = fields.Boolean(string='Used', deafult=False, required=True, readonly=True)



the view's xml (I tried both field and xpath to find the element, but no difference, no error, no field shown):

<record id="view_einvoice_tw_inherited" model="ir.ui.view"> 

    <field name="name">E-Invoice Inherited</field>

    <field name="model">einvoice_tw.einvoice_tw</field>

    <field name="inherit_id" ref="account.invoice_form"/>

    <field name="arch" type="xml">

         <xpath expr="//field[@name='date_invoice']" position="before">

         <!--<field name="date_invoice" position="before">-->

             <field string="E-Invoice" name="e_invoice_number"/>

         </xpath>

         <!--</field>-->

    </field>

</record>

Avatar
Discard
Best Answer

Hi,

From the python file, remove the new name given for the model, just _inherit =  'account.invoice' is necessary and from the xml file change the model name to account.invoice .

See the example shown here: How To Inherit And Add Field to Existing Views In Odoo

Thanks

Avatar
Discard
Author

Hi Niyas, thank you for your help. But I would like two add the extra field from the model of my custom module. If I remove the name variable of my custom model, how can I reference it to my module’s form view? If I create a new class like the tutorial, how is the new field linked to the same field of my main model?