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.

1

Is it possible to show both tax included and tax excluded total price in invoice lines ?

By
Victor Godayer
on 4/2/15, 12:01 PM 1,221 views

Hi,


I try to show both columns in the account invoice form :

* total of an invoice line, tax excluded

* total of an invoice line, tax included.


I know that it is possible to set the tax object to be included or excluded in product price, but I don't see the way to show both in invoice form.


I already extended account.invoice.line as follow :



from openerp import api, models, fields

import openerp.addons.decimal_precision as dp

class cap_account_invoice_line(models.Model):

     _inherit = 'account.invoice.line'

     price_with_tax = fields.Float(string='Prix TTC', digits= dp.get_precision('Product Price'), store=True, readonly=True,)


"""

     I guess I should override the method below, but i don't know how to calculate and load the total line with included tax into the line...

     @api.multi

     def button_reset_taxes(self):

         ???

"""



Thank you in advance for your help

Victor

5

Cyril Gaspard (GEM)

--Cyril Gaspard (GEM)--
4136
| 5 6 8
Paris, France
--Cyril Gaspard (GEM)--

Forum contributor since 2008

Cyril Gaspard (GEM)
On 4/2/15, 8:16 PM

Hi,

this is an example, but you can override existing function _compute_price used by the field price_subtotal ...


from openerp import api, models, fields

import openerp.addons.decimal_precision as dp



class AccountInvoiceLine(models.Model):

     _inherit = 'account.invoice.line'


     price_subtotal_tax = fields.Float(compute='_compute_price_tax', string=' Total including tax', digits= dp.get_precision('Product Price'), store=True)


    

    @api.one

     @api.depends('price_unit', 'discount', 'invoice_line_tax_id', 'quantity',

         'product_id', 'invoice_id.partner_id', 'invoice_id.currency_id')

     def _compute_price_tax(self):

         price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)

         taxes = self.invoice_line_tax_id.compute_all(price, self.quantity, product=self.product_id,

                                                                                  partner=self.invoice_id.partner_id)

         self.price_subtotal_tax = taxes['total_included']

         if self.invoice_id:

             self.price_subtotal_tax = self.invoice_id.currency_id.round(self.price_subtotal_tax)


Bye

Thanks a lot, it works like a charm, and understood the logic, so I did the same one sale_order_line!

Victor Godayer
on 4/3/15, 3:21 AM

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: 4/2/15, 12:01 PM
Seen: 1221 times
Last updated: 4/3/15, 4:45 AM