Skip to content

Commit 0f0a069

Browse files
committed
[FIX] l10n_my_edi: relax credit note check
So far, we have enforced that credit notes must be linked to an invoice that has been sent to MyInvois. In real life, this is too strict. Users could be issuing credit notes for invoices created before MyInvois was used, in which case these must still be reported to MyInvois even though the original invoice isn't on the platform. This also fixes a small issue with the issue date, which was set to the invoice date up until now but on their platform they explicitly ask for today in UTC timezone. task-4889022 closes odoo#216710 X-original-commit: 6bd676d Signed-off-by: Habib Ayob (ayh) <[email protected]> Signed-off-by: Nicolas Viseur (vin) <[email protected]>
1 parent 9c5e08a commit 0f0a069

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

addons/l10n_my_edi/models/account_edi_xml_ubl_my.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def _export_invoice_vals(self, invoice):
107107
# The current version is 1.1 (document with signature), the type code depends on the move type.
108108
'document_type_code_attrs': {'listVersionID': 1.1},
109109
'document_type_code': document_type_code,
110-
# The issue time must be the current time set in the UTC time zone
110+
# The issue date and time must be the current time set in the UTC time zone
111+
'issue_date': datetime.now(tz=UTC).strftime("%Y-%m-%d"),
111112
'issue_time': datetime.now(tz=UTC).strftime("%H:%M:%SZ"),
112113
# Exchange rate information must be provided if applicable
113114
'tax_exchange_rate': self._l10n_my_edi_get_tax_exchange_rate(invoice),
@@ -132,11 +133,14 @@ def _export_invoice_vals(self, invoice):
132133
vals['vals']['accounting_customer_party_vals']['party_vals']['party_identification_vals'] = customer_identification_vals
133134

134135
# Debit/Credit note original invoice ref.
135-
if original_document:
136+
# Applies to credit notes, debit notes, refunds for both invoices and self-billed invoices.
137+
# The original document is mandatory; but in some specific cases it will be empty (sending a credit note for an invoice
138+
# managed outside Odoo/...)
139+
if document_type_code in ('02', '03', '04', '12', '13', '14'):
136140
vals['vals'].update({
137141
'billing_reference_vals': {
138-
'id': original_document.name,
139-
'uuid': original_document.l10n_my_edi_external_uuid,
142+
'id': (original_document and original_document.name) or 'NA',
143+
'uuid': (original_document and original_document.l10n_my_edi_external_uuid) or 'NA',
140144
},
141145
})
142146

@@ -302,10 +306,6 @@ def _export_invoice_constraints(self, invoice, vals):
302306
elif any(tax.l10n_my_tax_type == 'E' for tax in line.tax_ids) and not invoice.l10n_my_edi_exemption_reason:
303307
self._l10n_my_edi_make_validation_error(constraints, 'tax_exemption_required', invoice.id, invoice.display_name)
304308

305-
document_type_code, original_document = self._l10n_my_edi_get_document_type_code(invoice)
306-
if document_type_code != '01' and not original_document:
307-
self._l10n_my_edi_make_validation_error(constraints, 'adjustment_origin', invoice.id, invoice.display_name)
308-
309309
return constraints
310310

311311
def _get_invoice_line_item_vals(self, line, taxes_vals):

addons/l10n_my_edi/tests/expected_xmls/bill_import.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
33
<cbc:ID>BILL/2019/01/0001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">11</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>MYR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>MYR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice_foreigner.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>MYR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice_import.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>MYR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice_multicurrency.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice_optional_fields.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>EUR</cbc:DocumentCurrencyCode>

addons/l10n_my_edi/tests/expected_xmls/invoice_tax_exempt.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
33
<cbc:ID>INV/2019/00001</cbc:ID>
4-
<cbc:IssueDate>2019-01-01</cbc:IssueDate>
4+
<cbc:IssueDate>2024-07-15</cbc:IssueDate>
55
<cbc:IssueTime>10:00:00Z</cbc:IssueTime>
66
<cbc:InvoiceTypeCode listVersionID="1.1">01</cbc:InvoiceTypeCode>
77
<cbc:DocumentCurrencyCode>MYR</cbc:DocumentCurrencyCode>

0 commit comments

Comments
 (0)