From e7330e346e55c3625efc4c5413a9adf1dbc9461b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Mon, 25 Nov 2024 17:16:57 +0100 Subject: [PATCH] [IMP] base_import_pdf_by_template_account: Improve tests (analytic distribution) TT50003 --- .../demo/base_import_pdf_template.xml | 23 ++++++++++++++++++- ...est_base_import_pdf_by_template_account.py | 11 +++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/base_import_pdf_by_template_account/demo/base_import_pdf_template.xml b/base_import_pdf_by_template_account/demo/base_import_pdf_template.xml index 47f37c6a57..d100cc80b4 100644 --- a/base_import_pdf_by_template_account/demo/base_import_pdf_template.xml +++ b/base_import_pdf_by_template_account/demo/base_import_pdf_template.xml @@ -5,6 +5,13 @@ GENERIC + + Tecnativa plan + + + Tecnativa + + Tecnativa @@ -94,7 +101,7 @@ ref="account.field_account_move__invoice_line_ids" /> - Producto,Cantidad,Precio + Producto,Cantidad,Precio,AnalyticDistribution variable + + + lines + + 3 + fixed + + diff --git a/base_import_pdf_by_template_account/tests/test_base_import_pdf_by_template_account.py b/base_import_pdf_by_template_account/tests/test_base_import_pdf_by_template_account.py index 3028e56ecf..2c09286714 100644 --- a/base_import_pdf_by_template_account/tests/test_base_import_pdf_by_template_account.py +++ b/base_import_pdf_by_template_account/tests/test_base_import_pdf_by_template_account.py @@ -11,6 +11,7 @@ class TestBaseImportPdfByTemplateAccount(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() + cls.env.user.groups_id += cls.env.ref("analytic.group_analytic_accounting") generic_product = cls.env.ref( "base_import_pdf_by_template_account.generic_product" ) @@ -27,6 +28,12 @@ def setUpClass(cls): cls.env.ref( "base_import_pdf_by_template_account.invoice_tecnativa_line_product_id" ).write({"default_value": f"{product_model_name},{generic_product.id}"}) + cls.analytic_account = cls.env.ref( + "base_import_pdf_by_template_account.analytic_account_tecnativa" + ) + cls.env.ref( + "base_import_pdf_by_template_account.invoice_tecnativa_analytic_distribution" + ).write({"fixed_value_text": '{"%s": 100.0}' % (cls.analytic_account.id)}) cls.journal = cls.env["account.journal"].search( [("type", "=", "purchase"), ("company_id", "=", cls.env.company.id)], limit=1, @@ -69,6 +76,10 @@ def _test_account_invoice_tecnativa_data(self, record): self.assertIn("LAMINAS", default_codes) self.assertIn("TRITURADORA", default_codes) self.assertIn("100.25", record.message_ids[-1].body) + self.assertEqual( + record.invoice_line_ids[0].analytic_distribution, + {str(self.analytic_account.id): 100.0}, + ) def test_account_invoice_tecnativa(self): attachment = self._create_ir_attachment("account_invoice_tecnativa.pdf")