[13.0][FIX] account_financial_report: Correct all uses of
self.env.user.company_id. Also move company_id to the wizard abstract model.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Copyright 2019 Lorenzo Battistini @ TAKOBI
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AbstractWizard(models.AbstractModel):
|
||||
@@ -27,3 +27,10 @@ class AbstractWizard(models.AbstractModel):
|
||||
partners -= corp_partners
|
||||
partners |= corp_partners.mapped("commercial_partner_id")
|
||||
return partners.ids
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company.id,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
|
||||
@@ -13,12 +13,6 @@ class AgedPartnerBalanceWizard(models.TransientModel):
|
||||
_description = "Aged Partner Balance Wizard"
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
date_at = fields.Date(required=True, default=fields.Date.context_today)
|
||||
date_from = fields.Date(string="Date From")
|
||||
target_move = fields.Selection(
|
||||
|
||||
@@ -22,12 +22,6 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
_description = "General Ledger Report Wizard"
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||
date_from = fields.Date(required=True, default=lambda self: self._init_date_from())
|
||||
date_to = fields.Date(required=True, default=fields.Date.context_today)
|
||||
@@ -128,8 +122,9 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
||||
def _init_date_from(self):
|
||||
"""set start date to begin of current year if fiscal year running"""
|
||||
today = fields.Date.context_today(self)
|
||||
last_fsc_month = self.env.user.company_id.fiscalyear_last_month
|
||||
last_fsc_day = self.env.user.company_id.fiscalyear_last_day
|
||||
company = self.company_id or self.env.company
|
||||
last_fsc_month = company.fiscalyear_last_month
|
||||
last_fsc_day = company.fiscalyear_last_day
|
||||
|
||||
if (
|
||||
today.month < int(last_fsc_month)
|
||||
|
||||
@@ -12,7 +12,7 @@ class JournalLedgerReportWizard(models.TransientModel):
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
default=lambda self: self.env.company.id,
|
||||
string="Company",
|
||||
required=False,
|
||||
ondelete="cascade",
|
||||
|
||||
@@ -13,12 +13,6 @@ class OpenItemsReportWizard(models.TransientModel):
|
||||
_description = "Open Items Report Wizard"
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
date_at = fields.Date(required=True, default=fields.Date.context_today)
|
||||
date_from = fields.Date(string="Date From")
|
||||
target_move = fields.Selection(
|
||||
|
||||
@@ -16,12 +16,6 @@ class TrialBalanceReportWizard(models.TransientModel):
|
||||
_description = "Trial Balance Report Wizard"
|
||||
_inherit = "account_financial_report_abstract_wizard"
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
|
||||
date_from = fields.Date(required=True)
|
||||
date_to = fields.Date(required=True)
|
||||
|
||||
@@ -11,7 +11,7 @@ class VATReportWizard(models.TransientModel):
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
default=lambda self: self.env.company,
|
||||
default=lambda self: self.env.company.id,
|
||||
required=False,
|
||||
string="Company",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user