[13.0][FIX] account_financial_report: Correct all uses of

self.env.user.company_id. Also move company_id to the
wizard abstract model.
pull/868/head
Lois Rilo 2020-10-21 11:44:14 +02:00 committed by Jasmin Solanki
parent 745e7b4e89
commit 301cf78612
11 changed files with 20 additions and 31 deletions

View File

@ -136,6 +136,8 @@ Contributors
* Harald Panten
* Valentin Vinagre
* Lois Rilo <lois.rilo@forgeflow.com>
Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.

View File

@ -29,5 +29,7 @@
* Harald Panten
* Valentin Vinagre
* Lois Rilo <lois.rilo@forgeflow.com>
Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.

View File

@ -628,7 +628,7 @@ class GeneralLedgerReport(models.AbstractModel):
hide_account_at_0,
):
general_ledger = []
rounding = self.env.user.company_id.currency_id.rounding
rounding = self.env.company.currency_id.rounding
for acc_id in gen_led_data.keys():
account = {}
account.update(

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils 0.15.2: http://docutils.sourceforge.net/" />
<title>Account Financial Reports</title>
<style type="text/css">
@ -492,6 +492,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Valentin Vinagre</li>
</ul>
</li>
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
</ul>
<p>Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016.</p>

View File

@ -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",
)

View File

@ -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(

View File

@ -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)

View File

@ -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",

View File

@ -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(

View File

@ -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)

View File

@ -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",
)