Odoo - 是否可以在发票行中同时显示含税和不含税的总价?

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

我尝试在帐户发票表单中同时显示两列:

我知道可以在产品价格中设置包含或不包含的税收对象,但我没有看到在发票形式中显示两者的方法。

我已经扩展了 account.invoice.line 如下:

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,)


    """
    @api.multi
    def button_reset_taxes(self):
        #I guess I should override this method but i don't know how
        #to calculate and load the total line with included tax 
        #into the field 'price_with_tax'
    """

提前感谢您的帮助

维克多

找到解决方案:

从 openerp 导入 api、模型、字段

导入 openerp.addons.decimal_precision 作为 dp

class 账户发票行(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)