[IMP] sale: Convert _compute_tax_id into real compute method
This commit is contained in:
@@ -51,7 +51,6 @@ class PosOrder(models.Model):
|
||||
'discount': line.discount,
|
||||
'sequence': sale_lines and sale_lines[-1].sequence + 1 or 10,
|
||||
})
|
||||
sale_line._compute_tax_id()
|
||||
line.sale_order_line_id = sale_line
|
||||
|
||||
so_lines = order.lines.mapped('sale_order_line_id')
|
||||
|
||||
@@ -120,14 +120,6 @@ class SaleOrder(models.Model):
|
||||
def _get_default_team(self):
|
||||
return self.env['crm.team']._get_default_team_id()
|
||||
|
||||
@api.onchange('fiscal_position_id')
|
||||
def _compute_tax_id(self):
|
||||
"""
|
||||
Trigger the recompute of the taxes if the fiscal position is changed on the SO.
|
||||
"""
|
||||
for order in self:
|
||||
order.order_line._compute_tax_id()
|
||||
|
||||
def _search_invoice_ids(self, operator, value):
|
||||
if operator == 'in' and value:
|
||||
self.env.cr.execute("""
|
||||
|
||||
@@ -134,6 +134,7 @@ class SaleOrderLine(models.Model):
|
||||
for line in self:
|
||||
line.price_reduce_taxexcl = line.price_subtotal / line.product_uom_qty if line.product_uom_qty else 0.0
|
||||
|
||||
@api.depends('order_id.fiscal_position_id')
|
||||
def _compute_tax_id(self):
|
||||
for line in self:
|
||||
line = line.with_company(line.company_id)
|
||||
@@ -242,7 +243,10 @@ class SaleOrderLine(models.Model):
|
||||
price_total = fields.Monetary(compute='_compute_amount', string='Total', store=True)
|
||||
|
||||
price_reduce = fields.Float(compute='_compute_price_reduce', string='Price Reduce', digits='Product Price', store=True)
|
||||
tax_id = fields.Many2many('account.tax', string='Taxes', domain=['|', ('active', '=', False), ('active', '=', True)])
|
||||
tax_id = fields.Many2many(
|
||||
'account.tax', string='Taxes',
|
||||
compute='_compute_tax_id', store=True, readonly=False,
|
||||
domain=['|', ('active', '=', False), ('active', '=', True)])
|
||||
price_reduce_taxinc = fields.Monetary(compute='_compute_price_reduce_taxinc', string='Price Reduce Tax inc', store=True)
|
||||
price_reduce_taxexcl = fields.Monetary(compute='_compute_price_reduce_taxexcl', string='Price Reduce Tax excl', store=True)
|
||||
|
||||
@@ -626,8 +630,6 @@ class SaleOrderLine(models.Model):
|
||||
|
||||
vals.update(name=self.get_sale_order_line_multiline_description_sale(product))
|
||||
|
||||
self._compute_tax_id()
|
||||
|
||||
if self.order_id.pricelist_id and self.order_id.partner_id:
|
||||
vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
|
||||
self.update(vals)
|
||||
|
||||
@@ -58,7 +58,6 @@ class TestReInvoice(TestSaleCommon):
|
||||
})
|
||||
sale_order_line2.product_id_change()
|
||||
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
# create invoice lines and validate it
|
||||
@@ -176,7 +175,6 @@ class TestReInvoice(TestSaleCommon):
|
||||
'order_id': self.sale_order.id,
|
||||
})
|
||||
sale_order_line2.product_id_change()
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
# create invoice lines and validate it
|
||||
@@ -244,7 +242,6 @@ class TestReInvoice(TestSaleCommon):
|
||||
'price_unit': self.company_data['product_delivery_no'].list_price,
|
||||
'order_id': self.sale_order.id,
|
||||
})
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
# create invoice lines and validate it
|
||||
@@ -283,7 +280,6 @@ class TestReInvoice(TestSaleCommon):
|
||||
})
|
||||
so_line2.product_id_change()
|
||||
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
for line in self.sale_order.order_line:
|
||||
|
||||
@@ -72,7 +72,6 @@ class TestSaleFlow(TestSaleCommonBase):
|
||||
for line in sale_order.order_line:
|
||||
line.product_id_change()
|
||||
|
||||
sale_order._compute_tax_id()
|
||||
sale_order.action_confirm()
|
||||
|
||||
self.assertRecordValues(sale_order.order_line, [
|
||||
|
||||
@@ -501,6 +501,7 @@ class SaleOrderLine(models.Model):
|
||||
related_program_lines |= line.order_id.order_line.filtered(lambda l: l.product_id.id == related_program.discount_line_product_id.id) - line
|
||||
return super(SaleOrderLine, self | related_program_lines).unlink()
|
||||
|
||||
@api.depends('order_id.fiscal_position_id')
|
||||
def _compute_tax_id(self):
|
||||
reward_lines = self.filtered('is_reward_line')
|
||||
super(SaleOrderLine, self - reward_lines)._compute_tax_id()
|
||||
|
||||
@@ -188,7 +188,6 @@ class TestSaleCouponProgramNumbers(TestSaleCouponCommon):
|
||||
order.recompute_coupon_lines()
|
||||
self.assertEqual(len(order.order_line.ids), 1, "We should not get the reduction line since we dont have 320$ tax excluded (cabinet is 320$ tax included)")
|
||||
sol1.tax_id.price_include = False
|
||||
sol1._compute_tax_id()
|
||||
order.recompute_coupon_lines()
|
||||
self.assertEqual(len(order.order_line.ids), 2, "We should now get the reduction line since we have 320$ tax included (cabinet is 320$ tax included)")
|
||||
# Name | Qty | price_unit | Tax | HTVA | TVAC | TVA |
|
||||
@@ -390,7 +389,6 @@ class TestSaleCouponProgramNumbers(TestSaleCouponCommon):
|
||||
self.assertEqual(len(order.order_line.ids), 12, "Order should contains 5 regular product lines, 3 free product lines and 4 discount lines (one for every tax)")
|
||||
|
||||
# -- This is a test inside the test
|
||||
order.order_line._compute_tax_id()
|
||||
self.assertEqual(order.amount_total, 1711, "Recomputing tax on sale order lines should not change total amount")
|
||||
self.assertEqual(order.amount_untaxed, 1435.46, "Recomputing tax on sale order lines should not change untaxed amount")
|
||||
self.assertEqual(len(order.order_line.ids), 12, "Recomputing tax on sale order lines should not change number of order line")
|
||||
|
||||
@@ -26,7 +26,6 @@ class TestSaleExpense(TestExpenseCommon, TestSaleCommon):
|
||||
})],
|
||||
'pricelist_id': self.env.ref('product.list0').id,
|
||||
})
|
||||
so._compute_tax_id()
|
||||
so.action_confirm()
|
||||
so._create_analytic_account() # normally created at so confirmation when you use the right products
|
||||
init_price = so.amount_total
|
||||
|
||||
@@ -131,7 +131,6 @@ class SaleOrder(models.Model):
|
||||
order_lines.append((0, 0, data))
|
||||
|
||||
self.order_line = order_lines
|
||||
self.order_line._compute_tax_id()
|
||||
|
||||
# then, process the list of optional products from the template
|
||||
option_lines = [(5, 0, 0)]
|
||||
@@ -258,7 +257,6 @@ class SaleOrderOption(models.Model):
|
||||
|
||||
values = self._get_values_to_add_to_order()
|
||||
order_line = self.env['sale.order.line'].create(values)
|
||||
order_line._compute_tax_id()
|
||||
|
||||
self.write({'line_id': order_line.id})
|
||||
if sale_order:
|
||||
|
||||
@@ -72,7 +72,6 @@ class TestReInvoice(TestCommonSaleTimesheet):
|
||||
})
|
||||
sale_order_line2.product_id_change()
|
||||
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
self.assertEqual(sale_order_line1.qty_delivered_method, 'timesheet', "Delivered quantity of 'service' SO line should be computed by timesheet amount")
|
||||
@@ -174,7 +173,6 @@ class TestReInvoice(TestCommonSaleTimesheet):
|
||||
'order_id': self.sale_order.id,
|
||||
})
|
||||
sale_order_line2.product_id_change()
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
# let's log some timesheets (on the project created by sale_order_line1)
|
||||
@@ -259,7 +257,6 @@ class TestReInvoice(TestCommonSaleTimesheet):
|
||||
'price_unit': self.company_data['product_order_no'].list_price,
|
||||
'order_id': self.sale_order.id,
|
||||
})
|
||||
self.sale_order._compute_tax_id()
|
||||
self.sale_order.action_confirm()
|
||||
|
||||
# create invoice lines and validate it
|
||||
|
||||
Reference in New Issue
Block a user