[FIX] select company in multicompany

pull/837/head
Andrea 2020-02-26 13:38:39 +01:00 committed by Valentin Vinagre Urteaga
parent 5f54ed0747
commit 61b5fa7f06
3 changed files with 12 additions and 7 deletions

View File

@ -26,10 +26,11 @@ class AccountTax(models.Model):
def get_context_values(self):
context = self.env.context
actual_company_id = context.get("company_id", self.env.company.id)
return (
context.get("from_date", fields.Date.context_today(self)),
context.get("to_date", fields.Date.context_today(self)),
context.get("company_ids", [self.env.user.company_id.id]),
context.get("company_ids", [actual_company_id]),
context.get("target_move", "posted"),
)

View File

@ -8,8 +8,12 @@ class WizardOpenTaxBalances(models.TransientModel):
_name = "wizard.open.tax.balances"
_description = "Wizard Open Tax Balances"
company_id = fields.Many2one(
"res.company", required=True, default=lambda self: self.env.user.company_id
company_ids = fields.Many2many(
comodel_name="res.company",
string="Companies",
required=True,
domain=lambda self: [("id", "in", self.env.companies.ids)],
default=lambda self: self.env.companies.ids,
)
from_date = fields.Date(
required=True, store=True, readonly=False, compute="_compute_date_range"
@ -63,17 +67,17 @@ class WizardOpenTaxBalances(models.TransientModel):
"target": _(self.target_move),
"from": self.from_date.strftime(date_format),
"to": self.to_date.strftime(date_format),
"company": self.company_id.name,
}
# name of action which is displayed in breacrumb
vals["name"] = _("%(name)s: %(target)s from %(from)s to %(to)s") % infos
multi_cpny_grp = self.env.ref("base.group_multi_company")
if multi_cpny_grp in self.env.user.groups_id:
vals["name"] = "{} ({})".format(vals["name"], self.company_id.name)
company_names = self.company_ids.mapped("name")
vals["name"] = "{} ({})".format(vals["name"], ", ".join(company_names))
vals["context"] = {
"from_date": self.from_date,
"to_date": self.to_date,
"target_move": self.target_move,
"company_id": self.company_id.id,
"company_ids": self.company_ids.ids,
}
return vals

View File

@ -8,7 +8,7 @@
<field name="arch" type="xml">
<form string="Taxes Balance">
<group>
<field name="company_id"/>
<field name="company_ids" widget="many2many_tags" groups="base.group_multi_company"/>
<field name="date_range_id"/>
<field name="from_date"></field>
<field name="to_date"></field>