[FIX] account_discount: calculation if tax option included used

This commit is contained in:
thomi 2018-01-24 13:14:47 +01:00
parent 775913b9dd
commit 91c9454281

View File

@ -43,7 +43,8 @@ class AccountInvoice(models.Model):
self._check_constrains() self._check_constrains()
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
line.write({'discount': 0.0}) line.write({'discount': 0.0})
amount_untaxed = self.amount_untaxed # amount_untaxed = self.amount_untaxed
gross_amount = self.gross_amount
if self.discount_method == 'per': if self.discount_method == 'per':
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
line.write({'discount': line.discount + self.discount_per}) line.write({'discount': line.discount + self.discount_per})
@ -51,7 +52,7 @@ class AccountInvoice(models.Model):
for line in self.invoice_line_ids: for line in self.invoice_line_ids:
discount_value_ratio = \ discount_value_ratio = \
(self.discount_amount * line.price_subtotal) / \ (self.discount_amount * line.price_subtotal) / \
amount_untaxed gross_amount
discount_per_ratio = \ discount_per_ratio = \
(discount_value_ratio * 100) / line.price_subtotal (discount_value_ratio * 100) / line.price_subtotal
line.write({'discount': line.discount + discount_per_ratio}) line.write({'discount': line.discount + discount_per_ratio})