[IMP] account_financial_report: adapt the wizards to multicompany
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools import pycompat
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class GeneralLedgerReportWizard(models.TransientModel):
|
||||
@@ -21,6 +22,7 @@ class GeneralLedgerReportWizard(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(
|
||||
@@ -98,6 +100,19 @@ class GeneralLedgerReportWizard(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)
|
||||
if self.company_id and self.cost_center_ids:
|
||||
self.cost_center_ids = self.cost_center_ids.filtered(
|
||||
lambda c: c.company_id == self.company_id)
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
def onchange_date_range_id(self):
|
||||
@@ -105,11 +120,21 @@ class GeneralLedgerReportWizard(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 General Ledger 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