diff --git a/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot b/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot index 8fa0194b0f0614295659032d44487a05caa86547..2064b37c2cc5f6052b00e4e21828d1fe4548e0b6 100644 --- a/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot +++ b/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot @@ -43,6 +43,12 @@ msgid "" "<strong>Format used to import the invoice: %s</strong> <p><li> %s </li></p>" msgstr "" +#. module: account_edi_ubl_cii +#: code:addons/account_edi_ubl_cii/models/account_edi_common.py:0 +#, python-format +msgid "A payment of %s was detected." +msgstr "" + #. module: account_edi_ubl_cii #: code:addons/account_edi_ubl_cii/models/account_edi_common.py:0 #, python-format diff --git a/addons/account_edi_ubl_cii/models/account_edi_common.py b/addons/account_edi_ubl_cii/models/account_edi_common.py index 3591f54569427286c6159c38dce5ec75e4b065ab..81915b6db80a1920d61292a8298f94b9ffaa45ae 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_common.py +++ b/addons/account_edi_ubl_cii/models/account_edi_common.py @@ -5,6 +5,7 @@ from odoo.tools import float_repr from odoo.tests.common import Form from odoo.exceptions import UserError, ValidationError from odoo.tools.float_utils import float_round +from odoo.tools.misc import formatLang from zeep import Client @@ -396,6 +397,7 @@ class AccountEdiCommon(models.AbstractModel): def _import_fill_invoice_down_payment(self, invoice_form, prepaid_node, qty_factor): """ + DEPRECATED: removed in master Creates a down payment line on the invoice at import if prepaid_node (TotalPrepaidAmount in CII, PrepaidAmount in UBL) exists. qty_factor -1 if the xml is labelled as an invoice but has negative amounts -> conversion into a credit note @@ -418,6 +420,19 @@ class AccountEdiCommon(models.AbstractModel): invoice_line_form.quantity = qty_factor * -1 invoice_line_form.tax_ids.clear() + def _import_log_prepaid_amount(self, invoice_form, prepaid_node, qty_factor): + """ + Log a message in the chatter at import if prepaid_node (TotalPrepaidAmount in CII, PrepaidAmount in UBL) exists. + """ + prepaid_amount = float(prepaid_node.text) if prepaid_node is not None else 0.0 + if not invoice_form.currency_id.is_zero(prepaid_amount): + amount = prepaid_amount * qty_factor + formatted_amount = formatLang(self.env, amount, currency_obj=invoice_form.currency_id) + return [ + _("A payment of %s was detected.", formatted_amount) + ] + return [] + def _import_fill_invoice_line_values(self, tree, xpath_dict, invoice_line_form, qty_factor): """ Read the xml invoice, extract the invoice line values, compute the odoo values diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index 83d22be6489c0dcd98ba811dd90b28b8f825303e..1ff7e11ab8769612749ab6f044be3f089ae80097 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -287,11 +287,11 @@ class AccountEdiXmlCII(models.AbstractModel): logs += self._import_fill_invoice_allowance_charge(tree, invoice_form, journal, qty_factor) - # ==== Down Payment (prepaid amount) ==== + # ==== Prepaid amount ==== prepaid_node = tree.find('.//{*}ApplicableHeaderTradeSettlement/' '{*}SpecifiedTradeSettlementHeaderMonetarySummation/{*}TotalPrepaidAmount') - self._import_fill_invoice_down_payment(invoice_form, prepaid_node, qty_factor) + logs += self._import_log_prepaid_amount(invoice_form, prepaid_node, qty_factor) # ==== invoice_line_ids ==== diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py index df5003d06494247380776508f3b5e9ad4d29a428..213b2e7c7ed8c5db5baaeac29da156b0b129e58b 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py @@ -554,10 +554,10 @@ class AccountEdiXmlUBL20(models.AbstractModel): logs += self._import_fill_invoice_allowance_charge(tree, invoice_form, journal, qty_factor) - # ==== Down Payment (prepaid amount) ==== + # ==== Prepaid amount ==== prepaid_node = tree.find('./{*}LegalMonetaryTotal/{*}PrepaidAmount') - self._import_fill_invoice_down_payment(invoice_form, prepaid_node, qty_factor) + logs += self._import_log_prepaid_amount(invoice_form, prepaid_node, qty_factor) # ==== invoice_line_ids: InvoiceLine/CreditNoteLine ====