diff --git a/addons/l10n_in_edi_ewaybill/models/account_edi_format.py b/addons/l10n_in_edi_ewaybill/models/account_edi_format.py index 3332d266fb2..92e839f13d5 100755 --- a/addons/l10n_in_edi_ewaybill/models/account_edi_format.py +++ b/addons/l10n_in_edi_ewaybill/models/account_edi_format.py @@ -98,6 +98,9 @@ class AccountEdiFormat(models.Model): error_message.append(_("- Transport document number and date is required when Transportation Mode is Rail,Air or Ship")) if error_message: error_message.insert(0, _("The following information are missing on the invoice (see eWayBill tab):")) + goods_lines = move.invoice_line_ids.filtered(lambda line: not (line.display_type or line.is_rounding_line or line.product_id.type == "service")) + if not goods_lines: + error_message.append(_('You need at least one product having "Product Type" as stockable or consumable.')) if base == "irn": # already checked by E-invoice (l10n_in_edi) so no need to check return error_message @@ -107,9 +110,7 @@ class AccountEdiFormat(models.Model): if not re.match("^.{1,16}$", is_purchase and move.ref or move.name): error_message.append(_("%s number should be set and not more than 16 characters", (is_purchase and "Bill Reference" or "Invoice"))) - goods_line_is_available = False - for line in move.invoice_line_ids.filtered(lambda line: not (line.display_type in ('line_section', 'line_note', 'rounding') or line.product_id.type == "service")): - goods_line_is_available = True + for line in goods_lines: if line.product_id: hsn_code = self._l10n_in_edi_extract_digits(line.product_id.l10n_in_hsn_code) if not hsn_code: @@ -120,8 +121,6 @@ class AccountEdiFormat(models.Model): )) else: error_message.append(_("product is required to get HSN code")) - if not goods_line_is_available: - error_message.append(_('You need at least one product having "Product Type" as stockable or consumable.')) if error_message: error_message.insert(0, _("Impossible to send the Ewaybill.")) return error_message