Skip to content

Commit

Permalink
[IMP] base_import_pdf_by_template_account: Improve tests (analytic di…
Browse files Browse the repository at this point in the history
…stribution)

TT50003
  • Loading branch information
victoralmau committed Dec 2, 2024
1 parent 5734fa9 commit b98e98b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<field name="default_code">GENERIC</field>
</record>
<!-- Account invoice Template Data !-->
<record id="analytic_plan_tecnativa" model="account.analytic.plan">
<field name="name">Tecnativa plan</field>
</record>
<record id="analytic_account_tecnativa" model="account.analytic.account">
<field name="name">Tecnativa</field>
<field name="plan_id" ref="analytic_plan_tecnativa" />
</record>
<record id="partner_tecnativa" model="res.partner">
<field name="name">Tecnativa</field>
</record>
Expand Down Expand Up @@ -94,7 +101,7 @@
ref="account.field_account_move__invoice_line_ids"
/>
<!-- <field name="auto_detect_pattern">(?<=B 8 7 5 3 0 4 3 2)[\S\s]*</field> -->
<field name="header_items">Producto,Cantidad,Precio</field>
<field name="header_items">Producto,Cantidad,Precio,AnalyticDistribution</field>
</record>
<record
id="invoice_tecnativa_line_partner_id"
Expand Down Expand Up @@ -152,4 +159,18 @@
<field name="value_type">variable</field>
<field name="log_distinct_value" eval="True" />
</record>
<record
id="invoice_tecnativa_analytic_distribution"
model="base.import.pdf.template.line"
>
<field name="template_id" ref="invoice_tecnativa" />
<field name="related_model">lines</field>
<field
name="field_id"
ref="account.field_account_move_line__analytic_distribution"
/>
<field name="column">3</field>
<field name="value_type">fixed</field>
<!--<field name="fixed_value_text">{"cls.env.ref('base_import_pdf_by_template_account.analytic_account_tecnativa').id": 100.0}</field>!-->
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b98e98b

Please sign in to comment.