[IMP] l10n_in_edi: negative discount now allowed

Before this commit:
Negative discounts could be applied to products, which is not allowed
in Indian EDI.

After this commit:
Applied conditions to check for negative discounts and raise an error in case of
such discounts.

task_id: 3293247

closes odoo/odoo#135790

X-original-commit: fb1352bc1937d54183173c57094b5b176525d8d6
Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
kasp-odoo
2023-09-20 13:03:11 +00:00
parent cdd29dfe98
commit d8931675f4
@@ -77,6 +77,8 @@ class AccountEdiFormat(models.Model):
if not move._l10n_in_edi_is_managing_invoice_negative_lines_allowed():
raise ValidationError(_("Invoice lines having a negative amount are not allowed to generate the IRN. "
"Please create a credit note instead."))
if line.display_type == 'product' and line.discount < 0:
error_message.append(_("Negative discount is not allowed, set in line %s", line.name))
if line.product_id:
hsn_code = self._l10n_in_edi_extract_digits(line.product_id.l10n_in_hsn_code)
if not hsn_code: