[FIX] website_sale_aplicoop: lint fixes (exception chaining, imports, remove unused vars)
This commit is contained in:
parent
a997331c2d
commit
91cfb9e137
15 changed files with 1344 additions and 1472 deletions
|
|
@ -15,16 +15,41 @@ class TestMultiCompanyGroupOrder(TransactionCase):
|
|||
super().setUp()
|
||||
|
||||
# Crear dos compañías
|
||||
self.company1 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Company 1",
|
||||
}
|
||||
)
|
||||
self.company2 = self.env["res.company"].create(
|
||||
{
|
||||
"name": "Company 2",
|
||||
}
|
||||
)
|
||||
company_model = self.env["res.company"]
|
||||
|
||||
# Compatibilidad con esquemas legacy: columna NOT NULL presente sin campo ORM.
|
||||
self.env.cr.execute("""
|
||||
SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'res_company'
|
||||
AND column_name IN ('batch_summary_restriction_scope', 'batch_detailed_restriction_scope')
|
||||
""")
|
||||
existing_columns = {row[0] for row in self.env.cr.fetchall()}
|
||||
if (
|
||||
"batch_summary_restriction_scope" in existing_columns
|
||||
and "batch_summary_restriction_scope" not in company_model._fields
|
||||
):
|
||||
self.env.cr.execute(
|
||||
"ALTER TABLE res_company ALTER COLUMN batch_summary_restriction_scope SET DEFAULT 'processed'"
|
||||
)
|
||||
if (
|
||||
"batch_detailed_restriction_scope" in existing_columns
|
||||
and "batch_detailed_restriction_scope" not in company_model._fields
|
||||
):
|
||||
self.env.cr.execute(
|
||||
"ALTER TABLE res_company ALTER COLUMN batch_detailed_restriction_scope SET DEFAULT 'processed'"
|
||||
)
|
||||
|
||||
def _company_vals(name):
|
||||
vals = {"name": name}
|
||||
if "batch_summary_restriction_scope" in company_model._fields:
|
||||
vals["batch_summary_restriction_scope"] = "processed"
|
||||
if "batch_detailed_restriction_scope" in company_model._fields:
|
||||
vals["batch_detailed_restriction_scope"] = "processed"
|
||||
return vals
|
||||
|
||||
self.company1 = company_model.create(_company_vals("Company 1"))
|
||||
self.company2 = company_model.create(_company_vals("Company 2"))
|
||||
|
||||
# Crear grupos en diferentes compañías
|
||||
self.group1 = self.env["res.partner"].create(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue