From 59c2d7fe5370490aa95290851658112d0b4e69ae Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Tue, 26 Oct 2021 12:55:59 +0000 Subject: [PATCH] [FIX] account_edi: tax (included) amount shows as discount in CFDI 1. Configure MX company, make sure testing certificate and vat are loaded into the company 2. Sign an invoice with 16% included in price No errors will be shown but opening the resulting CFDI xml will show a discount "Descuento" equal to the tax amount, which is incorrect opw-2665082 closes odoo/odoo#79501 X-original-commit: 3f58aefe607e562044617e2c9dbecb1afd2de586 Related: odoo/enterprise#22170 Signed-off-by: Laurent Smet --- addons/account_edi/models/account_move.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/account_edi/models/account_move.py b/addons/account_edi/models/account_move.py index 7d7d3ae17eb..a32422054bc 100644 --- a/addons/account_edi/models/account_move.py +++ b/addons/account_edi/models/account_move.py @@ -585,16 +585,20 @@ class AccountMoveLine(models.Model): ''' self.ensure_one() + if self.discount == 100.0: + gross_price_subtotal = self.currency_id.round(self.price_unit * self.quantity) + else: + gross_price_subtotal = self.currency_id.round(self.price_subtotal / (1 - self.discount / 100.0)) + res = { 'line': self, - 'price_unit_after_discount': self.price_unit * (1 - (self.discount / 100.0)), - 'price_subtotal_before_discount': self.currency_id.round(self.price_unit * self.quantity), + 'price_unit_after_discount': self.currency_id.round(self.price_unit * (1 - (self.discount / 100.0))), + 'price_subtotal_before_discount': gross_price_subtotal, 'price_subtotal_unit': self.currency_id.round(self.price_subtotal / self.quantity) if self.quantity else 0.0, 'price_total_unit': self.currency_id.round(self.price_total / self.quantity) if self.quantity else 0.0, + 'price_discount': gross_price_subtotal - self.price_subtotal, + 'gross_price_total_unit': self.currency_id.round(gross_price_subtotal / self.quantity) if self.quantity else 0.0, } - - res['price_discount'] = res['price_subtotal_before_discount'] - self.price_subtotal - return res def reconcile(self):