From 7e7c16534bcd58bd883827fbf55b915016fe9c87 Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Mon, 13 Sep 2021 12:40:18 +0000 Subject: [PATCH] [FIX] repair: Respect account.group_show_line_subtotals_tax_included Steps to follow - Enable group_show_line_subtotals_tax_included - Create a repair order and add a tax to a line -> The subtotal doesn't contain the tax amount opw-2513287 closes odoo/odoo#78631 X-original-commit: 133888a1859d81a252177b58b046b54d22ba5ca8 Signed-off-by: William Henrotin Signed-off-by: Hubert Van De Walle --- addons/repair/models/repair.py | 16 ++++++++++------ addons/repair/views/repair_views.xml | 6 ++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/repair/models/repair.py b/addons/repair/models/repair.py index 3c072d8904c..8b9e2fbfbc2 100644 --- a/addons/repair/models/repair.py +++ b/addons/repair/models/repair.py @@ -630,7 +630,8 @@ class RepairLine(models.Model): domain="[('type', 'in', ['product', 'consu']), '|', ('company_id', '=', company_id), ('company_id', '=', False)]") invoiced = fields.Boolean('Invoiced', copy=False, readonly=True) price_unit = fields.Float('Unit Price', required=True, digits='Product Price') - price_subtotal = fields.Float('Subtotal', compute='_compute_price_subtotal', store=True, digits=0) + price_subtotal = fields.Float('Subtotal', compute='_compute_price_total_and_subtotal', store=True, digits=0) + price_total = fields.Float('Total', compute='_compute_price_total_and_subtotal', store=True, digits=0) tax_id = fields.Many2many( 'account.tax', 'repair_operation_line_tax', 'repair_operation_line_id', 'tax_id', 'Taxes', domain="[('type_tax_use','=','sale'), ('company_id', '=', company_id)]", check_company=True) @@ -665,11 +666,12 @@ class RepairLine(models.Model): help='The status of a repair line is set automatically to the one of the linked repair order.') tracking = fields.Selection(string='Product Tracking', related="product_id.tracking") - @api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'repair_id.invoice_method') - def _compute_price_subtotal(self): + @api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'tax_id', 'repair_id.invoice_method') + def _compute_price_total_and_subtotal(self): for line in self: taxes = line.tax_id.compute_all(line.price_unit, line.repair_id.pricelist_id.currency_id, line.product_uom_qty, line.product_id, line.repair_id.partner_id) line.price_subtotal = taxes['total_excluded'] + line.price_total = taxes['total_included'] @api.onchange('type') def onchange_operation_type(self): @@ -764,18 +766,20 @@ class RepairFee(models.Model): price_unit = fields.Float('Unit Price', required=True, digits='Product Price') product_uom = fields.Many2one('uom.uom', 'Product Unit of Measure', required=True, domain="[('category_id', '=', product_uom_category_id)]") product_uom_category_id = fields.Many2one(related='product_id.uom_id.category_id') - price_subtotal = fields.Float('Subtotal', compute='_compute_price_subtotal', store=True, digits=0) + price_subtotal = fields.Float('Subtotal', compute='_compute_price_total_and_subtotal', store=True, digits=0) + price_total = fields.Float('Total', compute='_compute_price_total_and_subtotal', store=True, digits=0) tax_id = fields.Many2many( 'account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes', domain="[('type_tax_use','=','sale'), ('company_id', '=', company_id)]", check_company=True) invoice_line_id = fields.Many2one('account.move.line', 'Invoice Line', copy=False, readonly=True, check_company=True) invoiced = fields.Boolean('Invoiced', copy=False, readonly=True) - @api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id') - def _compute_price_subtotal(self): + @api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'tax_id') + def _compute_price_total_and_subtotal(self): for fee in self: taxes = fee.tax_id.compute_all(fee.price_unit, fee.repair_id.pricelist_id.currency_id, fee.product_uom_qty, fee.product_id, fee.repair_id.partner_id) fee.price_subtotal = taxes['total_excluded'] + fee.price_total = taxes['total_included'] @api.onchange('repair_id', 'product_id', 'product_uom_qty') def onchange_product_id(self): diff --git a/addons/repair/views/repair_views.xml b/addons/repair/views/repair_views.xml index 9815559852c..88bfdb1018d 100644 --- a/addons/repair/views/repair_views.xml +++ b/addons/repair/views/repair_views.xml @@ -145,7 +145,8 @@ - + + @@ -189,7 +190,8 @@ - + +