Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed Dec 29, 2024
1 parent bd5b881 commit 7989057
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions l10n_br_fiscal/tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,35 @@


def load_fiscal_fixture_files(env):
load_fixture_files( # FIXME create fake records
env, "base", file_names=["data/res_partner_demo.xml"], mode="init"
)
# TODO base.res_partner_1
# the following data is a minimal set of fixtures for the demo partners
# of the base module when it's installed without demo data.
partner_fixtures = {
"res_partner_1": {},
"res_partner_2": {},
"res_partner_3": {},
"res_partner_4": {},
"res_partner_10": {},
"res_partner_12": {},
"res_partner_18": {},
}
for key, partner_data in partner_fixtures.items():
if not env.ref(f"base.{key}", raise_if_not_found=False):
if not partner_data.get("name"):
partner_data["name"] = f"fixture_{key}"

rec = env["res.partner"].create(partner_data)
env["ir.model.data"].create(
{
"name": key,
"res_id": rec.id,
"noupdate": True,
"module": "base",
"model": "res.partner",
}
)

# the following data is a minimal set of fixtures for the demo products
# of the product module when it's installed without demo data.
product_fixtures = {
"product_product_1": {},
"product_product_2": {},
Expand Down Expand Up @@ -45,13 +69,7 @@ def load_fiscal_fixture_files(env):
}
idref = {}
for key, product_data in product_fixtures.items():
if not env["ir.model.data"].search(
[
("model", "=", "product.product"),
("name", "=", key),
("module", "=", "product"),
]
):
if not env.ref(f"product.{key}", raise_if_not_found=False):
if not product_data.get("name"):
product_data["name"] = f"fixture_{key}"
prod = env["product.product"].create(product_data)
Expand All @@ -65,12 +83,7 @@ def load_fiscal_fixture_files(env):
}
)
idref[f"product.{key}"] = prod.id
if not env["ir.model.data"].search(
[
("model", "=", "product.template"),
("res_id", "=", prod.product_tmpl_id.id),
]
):
if not env.ref(f"product.{key}_product_template", raise_if_not_found=False):
env["ir.model.data"].create(
{
"name": f"{key}_product_template",
Expand Down Expand Up @@ -103,5 +116,4 @@ def load_fiscal_fixture_files(env):
"fiscal_document_demo.xml",
],
idref=idref,
mode="init",
)

0 comments on commit 7989057

Please sign in to comment.