Do not change line type when calling on_change_product
The wizard to modify header calls on_change_product on all lines but their type must not change. Closes #12633
This commit is contained in:
@@ -1420,18 +1420,20 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
|
||||
and self.product_supplier not in product_suppliers):
|
||||
self.product_supplier = None
|
||||
|
||||
self.unit_price = self.compute_unit_price()
|
||||
self.unit_price = self.compute_unit_price()
|
||||
|
||||
self.type = 'line'
|
||||
self.amount = self.on_change_with_amount()
|
||||
|
||||
@fields.depends(
|
||||
'product',
|
||||
'type', 'product',
|
||||
methods=['on_change_with_company', '_get_tax_rule_pattern'])
|
||||
def compute_taxes(self, party):
|
||||
pool = Pool()
|
||||
AccountConfiguration = pool.get('account.configuration')
|
||||
|
||||
if self.type != 'line':
|
||||
return []
|
||||
|
||||
company = self.on_change_with_company()
|
||||
taxes = set()
|
||||
pattern = self._get_tax_rule_pattern()
|
||||
|
||||
@@ -80,6 +80,7 @@ Create a sale with a line::
|
||||
>>> purchase_line.product = product
|
||||
>>> purchase_line.quantity = 3
|
||||
>>> purchase_line.unit_price = Decimal('5.0000')
|
||||
>>> purchase_line_comment = purchase.lines.new(type='comment')
|
||||
>>> purchase.save()
|
||||
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
|
||||
(Decimal('15.00'), Decimal('1.50'), Decimal('16.50'))
|
||||
|
||||
@@ -1492,18 +1492,20 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView):
|
||||
if not self.unit or self.unit.category != category:
|
||||
self.unit = self.product.sale_uom
|
||||
|
||||
self.unit_price = self.compute_unit_price()
|
||||
self.unit_price = self.compute_unit_price()
|
||||
|
||||
self.type = 'line'
|
||||
self.amount = self.on_change_with_amount()
|
||||
|
||||
@fields.depends(
|
||||
'product',
|
||||
'type', 'product',
|
||||
methods=['on_change_with_company', '_get_tax_rule_pattern'])
|
||||
def compute_taxes(self, party):
|
||||
pool = Pool()
|
||||
AccountConfiguration = pool.get('account.configuration')
|
||||
|
||||
if self.type != 'line':
|
||||
return []
|
||||
|
||||
company = self.on_change_with_company()
|
||||
taxes = set()
|
||||
pattern = self._get_tax_rule_pattern()
|
||||
|
||||
@@ -82,6 +82,7 @@ Create a sale with a line::
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 3
|
||||
>>> sale_line_comment = sale.lines.new(type='comment')
|
||||
>>> sale.save()
|
||||
>>> sale.untaxed_amount, sale.tax_amount, sale.total_amount
|
||||
(Decimal('30.00'), Decimal('3.00'), Decimal('33.00'))
|
||||
|
||||
Reference in New Issue
Block a user