Browse Source

[FIX] select company in multicompany

pull/736/head
Andrea 5 years ago
committed by Francisco Ivan Anton Prieto
parent
commit
4389b07e0b
  1. 3
      account_tax_balance/models/account_tax.py
  2. 14
      account_tax_balance/wizard/open_tax_balances.py
  3. 2
      account_tax_balance/wizard/open_tax_balances_view.xml

3
account_tax_balance/models/account_tax.py

@ -26,10 +26,11 @@ class AccountTax(models.Model):
def get_context_values(self): def get_context_values(self):
context = self.env.context context = self.env.context
actual_company_id = context.get("company_id", self.env.company.id)
return ( return (
context.get("from_date", fields.Date.context_today(self)), context.get("from_date", fields.Date.context_today(self)),
context.get("to_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"), context.get("target_move", "posted"),
) )

14
account_tax_balance/wizard/open_tax_balances.py

@ -8,8 +8,12 @@ class WizardOpenTaxBalances(models.TransientModel):
_name = "wizard.open.tax.balances" _name = "wizard.open.tax.balances"
_description = "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( from_date = fields.Date(
required=True, store=True, readonly=False, compute="_compute_date_range" required=True, store=True, readonly=False, compute="_compute_date_range"
@ -63,17 +67,17 @@ class WizardOpenTaxBalances(models.TransientModel):
"target": _(self.target_move), "target": _(self.target_move),
"from": self.from_date.strftime(date_format), "from": self.from_date.strftime(date_format),
"to": self.to_date.strftime(date_format), "to": self.to_date.strftime(date_format),
"company": self.company_id.name,
} }
# name of action which is displayed in breacrumb # name of action which is displayed in breacrumb
vals["name"] = _("%(name)s: %(target)s from %(from)s to %(to)s") % infos vals["name"] = _("%(name)s: %(target)s from %(from)s to %(to)s") % infos
multi_cpny_grp = self.env.ref("base.group_multi_company") multi_cpny_grp = self.env.ref("base.group_multi_company")
if multi_cpny_grp in self.env.user.groups_id: 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"] = { vals["context"] = {
"from_date": self.from_date, "from_date": self.from_date,
"to_date": self.to_date, "to_date": self.to_date,
"target_move": self.target_move, "target_move": self.target_move,
"company_id": self.company_id.id,
"company_ids": self.company_ids.ids,
} }
return vals return vals

2
account_tax_balance/wizard/open_tax_balances_view.xml

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

Loading…
Cancel
Save