Browse Source

[account_financial_report_qweb] backport of PR #498

pull/490/head
Jordi Ballester Alomar 6 years ago
parent
commit
76924ac390
  1. 2
      account_financial_report_qweb/__manifest__.py
  2. 9
      account_financial_report_qweb/readme/HISTORY.rst
  3. 2
      account_financial_report_qweb/report/abstract_report_xlsx.py
  4. 3
      account_financial_report_qweb/report/aged_partner_balance_xlsx.py
  5. 3
      account_financial_report_qweb/report/general_ledger_xlsx.py
  6. 3
      account_financial_report_qweb/report/journal_report_xlsx.py
  7. 3
      account_financial_report_qweb/report/open_items_xlsx.py
  8. 2
      account_financial_report_qweb/report/templates/aged_partner_balance.xml
  9. 2
      account_financial_report_qweb/report/templates/general_ledger.xml
  10. 2
      account_financial_report_qweb/report/templates/journal.xml
  11. 2
      account_financial_report_qweb/report/templates/open_items.xml
  12. 2
      account_financial_report_qweb/report/templates/trial_balance.xml
  13. 3
      account_financial_report_qweb/report/trial_balance_xlsx.py
  14. 20
      account_financial_report_qweb/wizard/aged_partner_balance_wizard.py
  15. 4
      account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml
  16. 36
      account_financial_report_qweb/wizard/general_ledger_wizard.py
  17. 8
      account_financial_report_qweb/wizard/general_ledger_wizard_view.xml
  18. 25
      account_financial_report_qweb/wizard/journal_report_wizard.py
  19. 20
      account_financial_report_qweb/wizard/open_items_wizard.py
  20. 2
      account_financial_report_qweb/wizard/open_items_wizard_view.xml
  21. 32
      account_financial_report_qweb/wizard/trial_balance_wizard.py
  22. 11
      account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

2
account_financial_report_qweb/__manifest__.py

@ -5,7 +5,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'QWeb Financial Reports',
'version': '10.0.2.0.1',
'version': '10.0.3.0.0',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'

9
account_financial_report_qweb/readme/HISTORY.rst

@ -1,3 +1,12 @@
10.0.3.0.0 (2019-01-09)
~~~~~~~~~~~~~~~~~~~~~~~
* Improve multicompany related usability.
* Improve performance in the General Ledger.
* The reports now display an improved title that includes report name,
company and currency.
10.0.2.0.0 (2018-11-29)
~~~~~~~~~~~~~~~~~~~~~~~

2
account_financial_report_qweb/report/abstract_report_xlsx.py

@ -43,7 +43,7 @@ class AbstractReportXslx(ReportXlsx):
self._define_formats(workbook)
report_name = self._get_report_name(objects)
report_name = self._get_report_name(report)
report_footer = self._get_report_footer()
filters = self._get_report_filters(report)
self.columns = self._get_report_columns(report)

3
account_financial_report_qweb/report/aged_partner_balance_xlsx.py

@ -15,8 +15,7 @@ class AgedPartnerBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
super(AgedPartnerBalanceXslx, self).__init__(
name, table, rml, parser, header, store)
def _get_report_name(self, objects):
report = objects
def _get_report_name(self, report):
return _('Aged Partner Balance - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report_qweb/report/general_ledger_xlsx.py

@ -16,8 +16,7 @@ class GeneralLedgerXslx(abstract_report_xlsx.AbstractReportXslx):
super(GeneralLedgerXslx, self).__init__(
name, table, rml, parser, header, store)
def _get_report_name(self, objects):
report = objects
def _get_report_name(self, report):
return _('General Ledger - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report_qweb/report/journal_report_xlsx.py

@ -17,8 +17,7 @@ class JournalXslx(abstract_report_xlsx.AbstractReportXslx):
super(JournalXslx, self).__init__(
name, table, rml, parser, header, store)
def _get_report_name(self, objects):
report = objects
def _get_report_name(self, report):
return _('Journal Ledger - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name)

3
account_financial_report_qweb/report/open_items_xlsx.py

@ -15,8 +15,7 @@ class OpenItemsXslx(abstract_report_xlsx.AbstractReportXslx):
super(OpenItemsXslx, self).__init__(
name, table, rml, parser, header, store)
def _get_report_name(self, objects):
report = objects
def _get_report_name(self, report):
return _('Open Items - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name)

2
account_financial_report_qweb/report/templates/aged_partner_balance.xml

@ -19,7 +19,7 @@
<t t-set="title" >Aged Partner Balance - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="res_company" t-value="o.company_id"/>
<div class="page data_table">
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>

2
account_financial_report_qweb/report/templates/general_ledger.xml

@ -20,7 +20,7 @@
<!-- Defines global variables used by internal layout -->
<t t-set="title" style="text-align: center;">General Ledger - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="res_company" t-value="o.company_id"/>
<div class="page data_table">
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>

2
account_financial_report_qweb/report/templates/journal.xml

@ -17,7 +17,7 @@
<t t-set="display_currency" t-value="o.foreign_currency"/>
<t t-set="display_account_name" t-value="o.with_account_name"/>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page data_table">
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>

2
account_financial_report_qweb/report/templates/open_items.xml

@ -17,7 +17,7 @@
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="res_company" t-value="o.company_id"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/>
<div class="page data_table">
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>

2
account_financial_report_qweb/report/templates/trial_balance.xml

@ -19,7 +19,7 @@
<t t-set="title" >Trial Balance - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="res_company" t-value="o.company_id"/>
<div class="page data_table">
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>

3
account_financial_report_qweb/report/trial_balance_xlsx.py

@ -15,8 +15,7 @@ class TrialBalanceXslx(abstract_report_xlsx.AbstractReportXslx):
super(TrialBalanceXslx, self).__init__(
name, table, rml, parser, header, store)
def _get_report_name(self, objects):
report = objects
def _get_report_name(self, report):
return _('Trial Balance - %s - %s') % (
report.company_id.name, report.company_id.currency_id.name)

20
account_financial_report_qweb/wizard/aged_partner_balance_wizard.py

@ -17,7 +17,7 @@ class AgedPartnerBalance(models.TransientModel):
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
required=True,
required=False,
string='Company'
)
date_at = fields.Date(required=True,
@ -47,8 +47,22 @@ class AgedPartnerBalance(models.TransientModel):
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.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': []}}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self):

4
account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml

@ -23,8 +23,7 @@
<label for="partner_ids"/>
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
options="{'no_create': True}"/>
</group>
<group name="account_filter" col="4">
<label for="account_ids" colspan="4"/>
@ -33,7 +32,6 @@
<field name="account_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
domain="[('company_id','=',company_id)]"
colspan="4"/>
</group>
<footer>

36
account_financial_report_qweb/wizard/general_ledger_wizard.py

@ -19,7 +19,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
required=True,
required=False,
string='Company'
)
date_range_id = fields.Many2one(
@ -100,16 +100,46 @@ class GeneralLedgerReportWizard(models.TransientModel):
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.journal_ids:
self.journal_ids = self.journal_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
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.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
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)
res = {'domain': {'account_ids': [],
'journal_ids': [],
'partner_ids': [],
'cost_center_ids': [],
'date_range_id': []
}
}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['journal_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res['domain']['cost_center_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
return res
@api.onchange('date_range_id')
def onchange_date_range_id(self):

8
account_financial_report_qweb/wizard/general_ledger_wizard_view.xml

@ -13,8 +13,7 @@
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<group name="filters">
<group name="date_range">
<field name="date_range_id"
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="fy_start_date" invisible="1"/>
@ -37,19 +36,16 @@
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
domain="[('company_id','=',company_id)]"/>
options="{'no_create': True}"/>
</page>
<page string="Filter partners">
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
options="{'no_create': True}"/>
</page>
<page string="Filter cost centers" groups="analytic.group_analytic_accounting">
<field name="cost_center_ids" nolabel="1"
options="{'no_create': True}"
domain="[('company_id','=',company_id)]"
groups="analytic.group_analytic_accounting"/>
</page>
<page string="Filter analytic tags">

25
account_financial_report_qweb/wizard/journal_report_wizard.py

@ -14,15 +14,12 @@ class JournalReportWizard(models.TransientModel):
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
string='Company',
required=True,
required=False,
ondelete='cascade',
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range',
domain="['|', "
"('company_id', '=', False),"
"('company_id', '=', company_id)]",
string='Date range'
)
date_from = fields.Date(
string="Start date",
@ -35,7 +32,6 @@ class JournalReportWizard(models.TransientModel):
journal_ids = fields.Many2many(
comodel_name='account.journal',
string="Journals",
domain="[('company_id', '=', company_id)]",
required=False,
)
move_target = fields.Selection(
@ -87,6 +83,23 @@ class JournalReportWizard(models.TransientModel):
self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end
@api.onchange('company_id')
def onchange_company_id(self):
"""Handle company change."""
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.journal_ids:
self.journal_ids = self.journal_ids.filtered(
lambda p: p.company_id == self.company_id or not p.company_id)
res = {'domain': {'journal_ids': []}}
if not self.company_id:
return res
else:
res['domain']['journal_ids'] += [
('company_id', '=', self.company_id.id)]
return res
@api.multi
def button_export_html(self):
self.ensure_one()

20
account_financial_report_qweb/wizard/open_items_wizard.py

@ -17,7 +17,7 @@ class OpenItemsReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
required=True,
required=False,
string='Company'
)
date_at = fields.Date(required=True,
@ -60,8 +60,22 @@ class OpenItemsReportWizard(models.TransientModel):
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.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': []}}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self):

2
account_financial_report_qweb/wizard/open_items_wizard_view.xml

@ -24,7 +24,6 @@
<label for="partner_ids"/>
<field name="partner_ids"
nolabel="1"
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
widget="many2many_tags"
options="{'no_create': True}"/>
</group>
@ -34,7 +33,6 @@
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
domain="[('company_id','=',company_id)]"
options="{'no_create': True}"
colspan="4"/>
</group>

32
account_financial_report_qweb/wizard/trial_balance_wizard.py

@ -19,7 +19,7 @@ class TrialBalanceReportWizard(models.TransientModel):
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
required=True,
required=False,
string='Company'
)
date_range_id = fields.Many2one(
@ -116,9 +116,35 @@ class TrialBalanceReportWizard(models.TransientModel):
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(
if self.company_id and self.journal_ids:
self.journal_ids = self.journal_ids.filtered(
lambda a: a.company_id == self.company_id)
if self.company_id and self.account_ids:
if self.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': [],
'date_range_id': [],
'journal_ids': [],
}
}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res['domain']['journal_ids'] += [
('company_id', '=', self.company_id.id)]
return res
@api.onchange('date_range_id')
def onchange_date_range_id(self):

11
account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

@ -13,7 +13,7 @@
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<group name="filters">
<group name="date_range">
<field name="date_range_id" domain="['|',('company_id','=',company_id), ('company_id','=',False)]"/>
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="fy_start_date" invisible="1"/>
@ -33,17 +33,9 @@
<label for="partner_ids"/>
<field name="partner_ids"
nolabel="1"
domain="['|',('company_id','=',company_id), ('company_id','=',False)]"
widget="many2many_tags"
options="{'no_create': True}"/>
</group>
<label for="journal_ids"/>
<field name="journal_ids"
widget="many2many_tags"
domain="[('company_id','=',company_id)]"
nolabel="1"
options="{'no_create': True}"
/>
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<div/>
<group name="account_filter" col="4">
@ -53,7 +45,6 @@
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
domain="[('company_id','=',company_id)]"
options="{'no_create': True}"
colspan="4"/>
</group>

Loading…
Cancel
Save