Skip to content
Snippets Groups Projects
Commit 7da06362 authored by Hubert Van de Walle (huvw)'s avatar Hubert Van de Walle (huvw)
Browse files

[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#78624

X-original-commit: 133888a1
Signed-off-by: default avatarHubert Van De Walle <hubvd@users.noreply.github.com>
Signed-off-by: default avatarWilliam Henrotin <Whenrow@users.noreply.github.com>
parent ddab2798
Branches
Tags
No related merge requests found
......@@ -631,6 +631,7 @@ class RepairLine(models.Model):
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_total = fields.Float('Total', compute='_compute_price_total', compute_sudo=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)
......@@ -671,6 +672,12 @@ class RepairLine(models.Model):
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']
@api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'tax_id', 'repair_id.invoice_method')
def _compute_price_total(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_total = taxes['total_included']
@api.onchange('type')
def onchange_operation_type(self):
""" On change of operation type it sets source location, destination location
......@@ -765,6 +772,7 @@ class RepairFee(models.Model):
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_total = fields.Float('Total', compute='_compute_price_total', compute_sudo=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)
......@@ -777,6 +785,12 @@ class RepairFee(models.Model):
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']
@api.depends('price_unit', 'repair_id', 'product_uom_qty', 'product_id', 'tax_id')
def _compute_price_total(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_total = taxes['total_included']
@api.onchange('repair_id', 'product_id', 'product_uom_qty')
def onchange_product_id(self):
""" On change of product it sets product quantity, tax account, name,
......
......@@ -145,7 +145,8 @@
<field name="product_uom" string="UoM" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
<field name="price_subtotal" widget="monetary" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" widget="monetary" groups="account.group_show_line_subtotals_tax_included"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
......@@ -189,7 +190,8 @@
<field name="product_uom" string="Unit of Measure" groups="uom.group_uom" optional="show"/>
<field name="price_unit"/>
<field name="tax_id" widget="many2many_tags" optional="show"/>
<field name="price_subtotal" widget="monetary"/>
<field name="price_subtotal" widget="monetary" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" widget="monetary" groups="account.group_show_line_subtotals_tax_included"/>
<field name="currency_id" invisible="1"/>
</tree>
</field>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment