[IMP] account_financial_report: adapt the wizards to multicompany
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools import pycompat
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
|
||||
class TrialBalanceReportWizard(models.TransientModel):
|
||||
@@ -19,6 +19,7 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
company_id = fields.Many2one(
|
||||
comodel_name='res.company',
|
||||
default=lambda self: self.env.user.company_id,
|
||||
required=True,
|
||||
string='Company'
|
||||
)
|
||||
date_range_id = fields.Many2one(
|
||||
@@ -107,6 +108,16 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
self.not_only_one_unaffected_earnings_account = count != 1
|
||||
if self.company_id and self.date_range_id.company_id and \
|
||||
self.date_range_id.company_id != self.company_id:
|
||||
self.date_range_id = False
|
||||
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('date_range_id')
|
||||
def onchange_date_range_id(self):
|
||||
@@ -114,11 +125,21 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
self.date_from = self.date_range_id.date_start
|
||||
self.date_to = self.date_range_id.date_end
|
||||
|
||||
@api.multi
|
||||
@api.constrains('company_id', 'date_range_id')
|
||||
def _check_company_id_date_range_id(self):
|
||||
for rec in self.sudo():
|
||||
if rec.company_id and rec.date_range_id.company_id and\
|
||||
rec.company_id != rec.date_range_id.company_id:
|
||||
raise ValidationError(
|
||||
_('The Company in the Trial Balance Report Wizard and in '
|
||||
'Date Range must be the same.'))
|
||||
|
||||
@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:
|
||||
|
||||
Reference in New Issue
Block a user