Odoo Help


Add Custom Invoice Column with calculation

Maximilien Vicidomini
on 9/30/14, 12:02 PM 956 views

Hello All,

I have managed to add a custom column on my invoices but I would like now as the tax, to impact the subtotal with these new field.

How can I do it ?


Thanks in advance

can you paste the code of what you have achieved so far , so that we can help you

on 6/19/17, 3:17 AM
On 6/19/17, 3:26 AM


For adding a new column to Invoice line , first you need to inherit the account_invoice_line class. Create a custom module for that.


class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
@api.depends('quantity', 'price_unit')
    def _compute_gross_amount(self):
        Compute the Gross amount of the IN line.
        for line in self:
            line.gross_amount = line.quantity * line.price_unit

gross_amount = fields.Monetary(compute='_compute_gross_amount', string='Gross Amount', readonly=True, store=True)

In the account_invoice view.xml you need to inherit hte invoice view , I am here putting the customer invoice lines view for eg:


        <!-- Update account invoice !-->
        <record id="invoice_form_inherit" model="ir.ui.view">
            <field name="name">account.invoice.form.inherit</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">   
            <xpath expr="/form/sheet/notebook/page/tree/field[@name='price_unit']" position="after">
                    <field name="gross_amount" readonly="0" widget='monetary' options="{'currency_field': 'currency_id'}"/>

On 6/19/17, 3:07 AM

How did you add a custom column on the invoices? Can you help me with the steps?

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.


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

1 follower(s)


Asked: 9/30/14, 12:02 PM
Seen: 956 times
Last updated: 6/19/17, 3:26 AM