summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormreficent <miquel.raich@eficent.com>2018-02-26 12:18:54 -0500
committerqdp-odoo <qdp@odoo.com>2018-02-28 10:29:38 +0100
commit38fde3bc01e13b53abe9fe8020000c557bd2dd77 (patch)
treeace067e36220212f62bd676661688a51450c3f18
parent56eead83568c2df2184eb8b2e70a81b0b71d1f1f (diff)
[IMP] account: support company_id in community reports
Was PR #23259. Courtesy of Miquel Raïch (Eficent)
-rw-r--r--addons/account/report/account_aged_partner_balance.py2
-rw-r--r--addons/account/report/account_balance.py2
-rw-r--r--addons/account/report/account_general_ledger.py2
-rw-r--r--addons/account/report/account_journal.py2
-rw-r--r--addons/account/report/account_overdue_report.py1
-rw-r--r--addons/account/report/account_partner_ledger.py2
-rw-r--r--addons/account/report/account_report_financial.py2
-rw-r--r--addons/account/report/account_tax.py2
-rw-r--r--addons/account/wizard/account_financial_report_view.xml4
-rw-r--r--addons/account/wizard/account_report_aged_partner_balance_view.xml1
-rw-r--r--addons/account/wizard/account_report_common.py15
-rw-r--r--addons/account/wizard/account_report_common_view.xml2
-rw-r--r--addons/web/views/report_templates.xml7
13 files changed, 37 insertions, 7 deletions
diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py
index d280b6cb850..0140d489817 100644
--- a/addons/account/report/account_aged_partner_balance.py
+++ b/addons/account/report/account_aged_partner_balance.py
@@ -223,4 +223,6 @@ class ReportAgedPartnerBalance(models.AbstractModel):
'time': time,
'get_partner_lines': movelines,
'get_direction': total,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py
index 93842ff1374..3c54e886d13 100644
--- a/addons/account/report/account_balance.py
+++ b/addons/account/report/account_balance.py
@@ -76,4 +76,6 @@ class ReportTrialBalance(models.AbstractModel):
'docs': docs,
'time': time,
'Accounts': account_res,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py
index 9c3c79dacf4..922ec24ff0a 100644
--- a/addons/account/report/account_general_ledger.py
+++ b/addons/account/report/account_general_ledger.py
@@ -133,4 +133,6 @@ class ReportGeneralLedger(models.AbstractModel):
'time': time,
'Accounts': accounts_res,
'print_journal': codes,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py
index 83e1b8bda8c..083dae336a7 100644
--- a/addons/account/report/account_journal.py
+++ b/addons/account/report/account_journal.py
@@ -115,4 +115,6 @@ class ReportJournal(models.AbstractModel):
'sum_credit': self._sum_credit,
'sum_debit': self._sum_debit,
'get_taxes': self._get_taxes,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_overdue_report.py b/addons/account/report/account_overdue_report.py
index dbfd933c99a..4d7e4b87ede 100644
--- a/addons/account/report/account_overdue_report.py
+++ b/addons/account/report/account_overdue_report.py
@@ -65,4 +65,5 @@ class ReportOverdue(models.AbstractModel):
'Lines': lines_to_display,
'Totals': totals,
'Date': fields.date.today(),
+ 'company_id': self.env['res.company'].browse([self.env.user.company_id.id]),
}
diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py
index 2da6c42abe7..e28ab7f0169 100644
--- a/addons/account/report/account_partner_ledger.py
+++ b/addons/account/report/account_partner_ledger.py
@@ -119,4 +119,6 @@ class ReportPartnerLedger(models.AbstractModel):
'time': time,
'lines': self._lines,
'sum_partner': self._sum_partner,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_report_financial.py b/addons/account/report/account_report_financial.py
index c4a919411d0..e68e5d6d9fb 100644
--- a/addons/account/report/account_report_financial.py
+++ b/addons/account/report/account_report_financial.py
@@ -158,4 +158,6 @@ class ReportFinancial(models.AbstractModel):
'docs': docs,
'time': time,
'get_account_lines': report_lines,
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
diff --git a/addons/account/report/account_tax.py b/addons/account/report/account_tax.py
index bcaf3697c29..97cdff1484a 100644
--- a/addons/account/report/account_tax.py
+++ b/addons/account/report/account_tax.py
@@ -14,6 +14,8 @@ class ReportTax(models.AbstractModel):
return {
'data': data['form'],
'lines': self.get_lines(data.get('form')),
+ 'company_id': self.env['res.company'].browse(
+ data['form']['company_id'][0]),
}
def _sql_from_amls_one(self):
diff --git a/addons/account/wizard/account_financial_report_view.xml b/addons/account/wizard/account_financial_report_view.xml
index 3d73e7b376a..0d5763da812 100644
--- a/addons/account/wizard/account_financial_report_view.xml
+++ b/addons/account/wizard/account_financial_report_view.xml
@@ -28,6 +28,10 @@
</notebook>
</field>
<field name="journal_ids" position="replace"/>
+ <field name="company_id" position="replace"/>
+ <field name="date_to" position="after">
+ <field name="company_id" options="{'no_create': True}" groups="base.group_multi_company" invisible="0"/>
+ </field>
</field>
</record>
diff --git a/addons/account/wizard/account_report_aged_partner_balance_view.xml b/addons/account/wizard/account_report_aged_partner_balance_view.xml
index 630474d5d07..42ca836364d 100644
--- a/addons/account/wizard/account_report_aged_partner_balance_view.xml
+++ b/addons/account/wizard/account_report_aged_partner_balance_view.xml
@@ -14,6 +14,7 @@
<newline/>
<field name="result_selection" widget="radio"/>
<field name="target_move" widget="radio"/>
+ <field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<field name="journal_ids" required="0" invisible="1"/>
<footer>
diff --git a/addons/account/wizard/account_report_common.py b/addons/account/wizard/account_report_common.py
index f7cba985485..6b47f2a7e8e 100644
--- a/addons/account/wizard/account_report_common.py
+++ b/addons/account/wizard/account_report_common.py
@@ -7,14 +7,22 @@ class AccountCommonReport(models.TransientModel):
_name = "account.common.report"
_description = "Account Common Report"
- company_id = fields.Many2one('res.company', string='Company', readonly=True, default=lambda self: self.env.user.company_id)
- journal_ids = fields.Many2many('account.journal', string='Journals', required=True, default=lambda self: self.env['account.journal'].search([]))
+ company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id)
+ journal_ids = fields.Many2many('account.journal', string='Journals', required=True, default=lambda self: self.env['account.journal'].search([('company_id', '=', self.company_id.id)]))
date_from = fields.Date(string='Start Date')
date_to = fields.Date(string='End Date')
target_move = fields.Selection([('posted', 'All Posted Entries'),
('all', 'All Entries'),
], string='Target Moves', required=True, default='posted')
+ @api.onchange('company_id')
+ def _onchange_company_id(self):
+ if self.company_id:
+ self.journal_ids = self.env['account.journal'].search(
+ [('company_id', '=', self.company_id.id)])
+ else:
+ self.journal_ids = self.env['account.journal'].search([])
+
def _build_contexts(self, data):
result = {}
result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False
@@ -22,6 +30,7 @@ class AccountCommonReport(models.TransientModel):
result['date_from'] = data['form']['date_from'] or False
result['date_to'] = data['form']['date_to'] or False
result['strict_range'] = True if result['date_from'] else False
+ result['company_id'] = data['form']['company_id'][0] or False
return result
def _print_report(self, data):
@@ -33,7 +42,7 @@ class AccountCommonReport(models.TransientModel):
data = {}
data['ids'] = self.env.context.get('active_ids', [])
data['model'] = self.env.context.get('active_model', 'ir.ui.menu')
- data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move'])[0]
+ data['form'] = self.read(['date_from', 'date_to', 'journal_ids', 'target_move', 'company_id'])[0]
used_context = self._build_contexts(data)
data['form']['used_context'] = dict(used_context, lang=self.env.context.get('lang') or 'en_US')
return self._print_report(data)
diff --git a/addons/account/wizard/account_report_common_view.xml b/addons/account/wizard/account_report_common_view.xml
index 569a95b82ad..be111dba194 100644
--- a/addons/account/wizard/account_report_common_view.xml
+++ b/addons/account/wizard/account_report_common_view.xml
@@ -6,7 +6,6 @@
<field name="model">account.common.report</field>
<field name="arch" type="xml">
<form string="Report Options">
- <field name="company_id" invisible="1"/>
<group col="4">
<field name="target_move" widget="radio"/>
<field name="date_from"/>
@@ -14,6 +13,7 @@
</group>
<group>
<field name="journal_ids" widget="many2many_tags" options="{'no_create': True}"/>
+ <field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<footer>
<button name="check_report" string="Print" type="object" default_focus="1" class="oe_highlight"/>
diff --git a/addons/web/views/report_templates.xml b/addons/web/views/report_templates.xml
index 7f1f1108992..f6a79d48d77 100644
--- a/addons/web/views/report_templates.xml
+++ b/addons/web/views/report_templates.xml
@@ -332,10 +332,11 @@
<template id="internal_layout">
<!-- Multicompany -->
- <t t-if="o and 'company_id' in o">
- <t t-set="company" t-value="o.company_id"/>
+ <t t-if="company_id">
+ <t t-set="company" t-value="company_id"/>
+ <t t-set="res_company" t-value="company_id"/>
</t>
- <t t-if="not o or not 'company_id' in o">
+ <t t-if="not company_id">
<t t-set="company" t-value="res_company"/>
</t>