[IMP] account_financial_report: adapt the wizards to multicompany

This commit is contained in:
mreficent
2018-03-23 15:42:04 +01:00
committed by chaule97
parent 83983f417f
commit cdf1382c8e
13 changed files with 167 additions and 31 deletions

View File

@@ -17,6 +17,7 @@ class OpenItemsReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
required=True,
string='Company'
)
date_at = fields.Date(required=True,
@@ -51,11 +52,22 @@ class OpenItemsReportWizard(models.TransientModel):
'will display initial and final balance in that currency.'
)
@api.onchange('company_id')
def onchange_company_id(self):
"""Handle company change."""
if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
if self.company_id and self.account_ids:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only:
domain = []
domain = [('company_id', '=', self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))]
elif self.receivable_accounts_only: