From 2b80646ccb0bbfa7d3242dfd12003902788a9857 Mon Sep 17 00:00:00 2001 From: Paolo Gatti Date: Tue, 11 Oct 2022 08:40:09 +0000 Subject: [PATCH] [FIX] l10n_it_edi: downpayment document type selection fix TD02 is the only document type in l10n_it_edi that requires the invoice to be a downpayment, but this doesn't mean that downpayments are limited to it. The condition has been adapted to allow downpayments to fall under the other document types cases. opw-3033403 closes odoo/odoo#104242 X-original-commit: 197dbf7a8d14b619d19ff5904eb07d53c1fd97d2 Signed-off-by: Josse Colpaert Signed-off-by: Paolo Gatti (pgi) --- addons/l10n_it_edi/models/account_edi_format.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/l10n_it_edi/models/account_edi_format.py b/addons/l10n_it_edi/models/account_edi_format.py index 9e2cf337281..e6b23f8953c 100644 --- a/addons/l10n_it_edi/models/account_edi_format.py +++ b/addons/l10n_it_edi/models/account_edi_format.py @@ -229,7 +229,7 @@ class AccountEdiFormat(models.Model): def _l10n_it_document_type_mapping(self): return { - 'TD01': dict(move_types=['out_invoice'], import_type='in_invoice'), + 'TD01': dict(move_types=['out_invoice'], import_type='in_invoice', downpayment=False), 'TD02': dict(move_types=['out_invoice'], import_type='in_invoice', downpayment=True), 'TD04': dict(move_types=['out_refund'], import_type='in_refund'), 'TD07': dict(move_types=['out_invoice'], import_type='in_invoice', simplified=True), @@ -251,7 +251,9 @@ class AccountEdiFormat(models.Model): info_partner_in_eu = infos.get('partner_in_eu', False) if all([ invoice.move_type in infos.get('move_types', False), - invoice._is_downpayment() == infos.get('downpayment', False), + # Only check downpayment if the key is specified in the document_type_mapping entry + # If it's not specified, the get() will return None and the condition will be True + infos.get('downpayment') in (None, invoice._is_downpayment()), is_self_invoice == infos.get('self_invoice', False), is_simplified == infos.get('simplified', False), info_services_or_goods in ("both", services_or_goods), @@ -259,6 +261,7 @@ class AccountEdiFormat(models.Model): goods_in_italy == infos.get('goods_in_italy', False), ]): return code + return None def _l10n_it_is_simplified_document_type(self, document_type):