diff --git a/addons/l10n_ke_edi_tremol/models/account_move.py b/addons/l10n_ke_edi_tremol/models/account_move.py index 7325ef87d67..59e64b23f58 100644 --- a/addons/l10n_ke_edi_tremol/models/account_move.py +++ b/addons/l10n_ke_edi_tremol/models/account_move.py @@ -129,7 +129,7 @@ class AccountMove(models.Model): in order to add a line to the opened invoice. """ def is_discount_line(line): - return line.price_unit < 0.0 + return line.price_subtotal < 0.0 def is_candidate(discount_line, other_line): """ If the of one line match those of the discount line, the discount can be distributed accross that line """ @@ -166,7 +166,7 @@ class AccountMove(models.Model): msgs = [] for line in self.invoice_line_ids.filtered(lambda l: l.display_type == 'product' and l.quantity and l.price_total > 0 and not discount_dict.get(l.id) >= 100): # Here we use the original discount of the line, since it the distributed discount has not been applied in the price_total - price = round(line.price_total / line.quantity * 100 / (100 - line.discount), 2) * currency_rate + price = round(line.price_total / abs(line.quantity) * 100 / (100 - line.discount), 2) * currency_rate percentage = line.tax_ids[0].amount # Letter to classify tax, 0% taxes are handled conditionally, as the tax can be zero-rated or exempt @@ -194,7 +194,7 @@ class AccountMove(models.Model): str(percentage).encode('cp1251')[:5] # up to 5 symbols for vat rate ]) # 1 to 10 symbols for quantity - line_data += b'*' + str(line.quantity).encode('cp1251')[:10] + line_data += b'*' + str(abs(line.quantity)).encode('cp1251')[:10] if discount_dict.get(line.id): # 1 to 7 symbols for percentage of discount/addition discount_sign = b'-' if discount_dict[line.id] > 0 else b'+'