[IMP] account: support company_id in community reports
Was PR #23259. Courtesy of Miquel Raïch (Eficent)
This commit is contained in:
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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]),
|
||||
}
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user