Browse Source

Merge pull request #490 from Eficent/10.0-afr-multicompany

[10.0][IMP] account_financial_report: adapt the wizards to multicompany
pull/505/head
Jordi Ballester Alomar 6 years ago
committed by GitHub
parent
commit
6b8200001b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      account_financial_report_qweb/README.rst
  2. 2
      account_financial_report_qweb/__manifest__.py
  3. 1
      account_financial_report_qweb/readme/CONTRIBUTORS.rst
  4. 9
      account_financial_report_qweb/readme/HISTORY.rst
  5. 4
      account_financial_report_qweb/report/abstract_report_xlsx.py
  6. 5
      account_financial_report_qweb/report/aged_partner_balance_xlsx.py
  7. 5
      account_financial_report_qweb/report/general_ledger_xlsx.py
  8. 5
      account_financial_report_qweb/report/journal_report_xlsx.py
  9. 5
      account_financial_report_qweb/report/open_items_xlsx.py
  10. 5
      account_financial_report_qweb/report/templates/aged_partner_balance.xml
  11. 6
      account_financial_report_qweb/report/templates/general_ledger.xml
  12. 7
      account_financial_report_qweb/report/templates/journal.xml
  13. 10
      account_financial_report_qweb/report/templates/layouts.xml
  14. 5
      account_financial_report_qweb/report/templates/open_items.xml
  15. 6
      account_financial_report_qweb/report/templates/trial_balance.xml
  16. 5
      account_financial_report_qweb/report/trial_balance_xlsx.py
  17. 28
      account_financial_report_qweb/wizard/aged_partner_balance_wizard.py
  18. 9
      account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml
  19. 59
      account_financial_report_qweb/wizard/general_ledger_wizard.py
  20. 15
      account_financial_report_qweb/wizard/general_ledger_wizard_view.xml
  21. 25
      account_financial_report_qweb/wizard/journal_report_wizard.py
  22. 28
      account_financial_report_qweb/wizard/open_items_wizard.py
  23. 12
      account_financial_report_qweb/wizard/open_items_wizard_view.xml
  24. 51
      account_financial_report_qweb/wizard/trial_balance_wizard.py
  25. 15
      account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

1
account_financial_report_qweb/README.rst

@ -101,6 +101,7 @@ Contributors
* Alexis de Lattre <alexis@via.ecp.fr> * Alexis de Lattre <alexis@via.ecp.fr>
* Mihai Fekete <feketemihai@gmail.com> * Mihai Fekete <feketemihai@gmail.com>
* Benjamin Willig <benjamin.willig@acsone.eu> * Benjamin Willig <benjamin.willig@acsone.eu>
* Miquel Raïch <miquel.raich@eficent.com>
Much of the work in this module was done at a sprint in Sorrento, Italy in Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016. April 2016.

2
account_financial_report_qweb/__manifest__.py

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

1
account_financial_report_qweb/readme/CONTRIBUTORS.rst

@ -15,6 +15,7 @@
* Alexis de Lattre <alexis@via.ecp.fr> * Alexis de Lattre <alexis@via.ecp.fr>
* Mihai Fekete <feketemihai@gmail.com> * Mihai Fekete <feketemihai@gmail.com>
* Benjamin Willig <benjamin.willig@acsone.eu> * Benjamin Willig <benjamin.willig@acsone.eu>
* Miquel Raïch <miquel.raich@eficent.com>
Much of the work in this module was done at a sprint in Sorrento, Italy in Much of the work in this module was done at a sprint in Sorrento, Italy in
April 2016. April 2016.

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) 10.0.2.0.0 (2018-11-29)
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~

4
account_financial_report_qweb/report/abstract_report_xlsx.py

@ -43,7 +43,7 @@ class AbstractReportXslx(ReportXlsx):
self._define_formats(workbook) self._define_formats(workbook)
report_name = self._get_report_name()
report_name = self._get_report_name(report)
report_footer = self._get_report_footer() report_footer = self._get_report_footer()
filters = self._get_report_filters(report) filters = self._get_report_filters(report)
self.columns = self._get_report_columns(report) self.columns = self._get_report_columns(report)
@ -360,7 +360,7 @@ class AbstractReportXslx(ReportXlsx):
def _generate_report_content(self, workbook, report): def _generate_report_content(self, workbook, report):
pass pass
def _get_report_name(self):
def _get_report_name(self, objects):
""" """
Allow to define the report name. Allow to define the report name.
Report name will be used as sheet name and as report title. Report name will be used as sheet name and as report title.

5
account_financial_report_qweb/report/aged_partner_balance_xlsx.py

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

5
account_financial_report_qweb/report/general_ledger_xlsx.py

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

5
account_financial_report_qweb/report/journal_report_xlsx.py

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

5
account_financial_report_qweb/report/open_items_xlsx.py

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

5
account_financial_report_qweb/report/templates/aged_partner_balance.xml

@ -16,10 +16,13 @@
<t t-set="show_move_line_details" t-value="o.show_move_line_details"/> <t t-set="show_move_line_details" t-value="o.show_move_line_details"/>
<!-- Defines global variables used by internal layout --> <!-- Defines global variables used by internal layout -->
<t t-set="title">Aged Partner Balance</t>
<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"/> <t t-set="res_company" t-value="o.company_id"/>
<div class="page"> <div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>
<!-- Display filters --> <!-- Display filters -->
<t t-call="account_financial_report_qweb.report_aged_partner_balance_filters"/> <t t-call="account_financial_report_qweb.report_aged_partner_balance_filters"/>

6
account_financial_report_qweb/report/templates/general_ledger.xml

@ -18,12 +18,14 @@
<t t-set="show_cost_center" t-value="o.show_cost_center"/> <t t-set="show_cost_center" t-value="o.show_cost_center"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/> <t t-set="foreign_currency" t-value="o.foreign_currency"/>
<!-- Defines global variables used by internal layout --> <!-- Defines global variables used by internal layout -->
<t t-set="title">General Ledger</t>
<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"/> <t t-set="res_company" t-value="o.company_id"/>
<div class="page"> <div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>
<!-- Display filters --> <!-- Display filters -->
<t t-call="account_financial_report_qweb.report_general_ledger_filters"/> <t t-call="account_financial_report_qweb.report_general_ledger_filters"/>
<t t-foreach="o.account_ids" t-as="account"> <t t-foreach="o.account_ids" t-as="account">
<div class="page_break"> <div class="page_break">
<!-- Display account header --> <!-- Display account header -->

7
account_financial_report_qweb/report/templates/journal.xml

@ -12,12 +12,15 @@
</template> </template>
<template id="report_journal_qweb_base"> <template id="report_journal_qweb_base">
<t t-set="title">Journal Ledger</t>
<t t-set="title" >Journal Ledger - <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="company_name" t-value="o.company_id.name"/>
<t t-set="display_currency" t-value="o.foreign_currency"/> <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="display_account_name" t-value="o.with_account_name"/>
<t t-set="company_name" t-value="o.company_id.name"/>
<div class="page"> <div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>
<t t-if="o.group_option == 'none'"> <t t-if="o.group_option == 'none'">
<div class="page_break"> <div class="page_break">
<t t-call="account_financial_report_qweb.report_journal_qweb_all"/> <t t-call="account_financial_report_qweb.report_journal_qweb_all"/>

10
account_financial_report_qweb/report/templates/layouts.xml

@ -8,16 +8,6 @@
</template> </template>
<template id="account_financial_report_qweb.internal_layout"> <template id="account_financial_report_qweb.internal_layout">
<div class="header">
<div class="row">
<div class="col-xs-6">
<span t-esc="title"/>
</div>
<div class="col-xs-6 text-right">
<span t-esc="company_name"/>
</div>
</div>
</div>
<t t-raw="0" /> <t t-raw="0" />
<div class="footer"> <div class="footer">
<div class="row"> <div class="row">

5
account_financial_report_qweb/report/templates/open_items.xml

@ -13,11 +13,14 @@
<template id="report_open_items_base"> <template id="report_open_items_base">
<!-- Defines global variables used by internal layout --> <!-- Defines global variables used by internal layout -->
<t t-set="title">Open Items</t>
<t t-set="title" >Open Items - <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="company_name" t-value="o.company_id.name"/>
<t t-set="res_company" t-value="o.company_id"/> <t t-set="res_company" t-value="o.company_id"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/> <t t-set="foreign_currency" t-value="o.foreign_currency"/>
<div class="page"> <div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>
<!-- Display filters --> <!-- Display filters -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_filters"/> <t t-call="account_financial_report_qweb.report_open_items_qweb_filters"/>

6
account_financial_report_qweb/report/templates/trial_balance.xml

@ -16,11 +16,13 @@
<t t-set="show_partner_details" t-value="o.show_partner_details"/> <t t-set="show_partner_details" t-value="o.show_partner_details"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/> <t t-set="foreign_currency" t-value="o.foreign_currency"/>
<!-- Defines global variables used by internal layout --> <!-- Defines global variables used by internal layout -->
<t t-set="title">Trial Balance</t>
<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="company_name" t-value="o.company_id.name"/>
<t t-set="res_company" t-value="o.company_id"/> <t t-set="res_company" t-value="o.company_id"/>
<div class="page"> <div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
</div>
<!-- Display filters --> <!-- Display filters -->
<t t-call="account_financial_report_qweb.report_trial_balance_qweb_filters"/> <t t-call="account_financial_report_qweb.report_trial_balance_qweb_filters"/>
<div class="act_as_table list_table" style="margin-top: 10px;"/> <div class="act_as_table list_table" style="margin-top: 10px;"/>

5
account_financial_report_qweb/report/trial_balance_xlsx.py

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

28
account_financial_report_qweb/wizard/aged_partner_balance_wizard.py

@ -17,6 +17,7 @@ class AgedPartnerBalance(models.TransientModel):
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
default=lambda self: self.env.user.company_id, default=lambda self: self.env.user.company_id,
required=False,
string='Company' string='Company'
) )
date_at = fields.Date(required=True, date_at = fields.Date(required=True,
@ -38,11 +39,36 @@ class AgedPartnerBalance(models.TransientModel):
) )
show_move_line_details = fields.Boolean() show_move_line_details = fields.Boolean()
@api.onchange('company_id')
def onchange_company_id(self):
"""Handle company change."""
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:
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') @api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self): def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change.""" """Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only: if self.receivable_accounts_only or self.payable_accounts_only:
domain = []
domain = [('company_id', '=', self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only: if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))] domain += [('internal_type', 'in', ('receivable', 'payable'))]
elif self.receivable_accounts_only: elif self.receivable_accounts_only:

9
account_financial_report_qweb/wizard/aged_partner_balance_wizard_view.xml

@ -21,13 +21,18 @@
</group> </group>
<group name="partner_filter" col="1"> <group name="partner_filter" col="1">
<label for="partner_ids"/> <label for="partner_ids"/>
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
</group> </group>
<group name="account_filter" col="4"> <group name="account_filter" col="4">
<label for="account_ids" colspan="4"/> <label for="account_ids" colspan="4"/>
<field name="receivable_accounts_only"/> <field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/> <field name="payable_accounts_only"/>
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
<field name="account_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
</group> </group>
<footer> <footer>
<button name="button_export_html" string="View" <button name="button_export_html" string="View"

59
account_financial_report_qweb/wizard/general_ledger_wizard.py

@ -5,8 +5,9 @@
# Copyright 2017 Akretion - Alexis de Lattre # Copyright 2017 Akretion - Alexis de Lattre
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval from odoo.tools.safe_eval import safe_eval
from odoo.exceptions import ValidationError
class GeneralLedgerReportWizard(models.TransientModel): class GeneralLedgerReportWizard(models.TransientModel):
@ -18,6 +19,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
default=lambda self: self.env.user.company_id, default=lambda self: self.env.user.company_id,
required=False,
string='Company' string='Company'
) )
date_range_id = fields.Many2one( date_range_id = fields.Many2one(
@ -95,6 +97,49 @@ class GeneralLedgerReportWizard(models.TransientModel):
('company_id', '=', self.company_id.id) ('company_id', '=', self.company_id.id)
]) ])
self.not_only_one_unaffected_earnings_account = count != 1 self.not_only_one_unaffected_earnings_account = count != 1
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:
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') @api.onchange('date_range_id')
def onchange_date_range_id(self): def onchange_date_range_id(self):
@ -102,11 +147,21 @@ class GeneralLedgerReportWizard(models.TransientModel):
self.date_from = self.date_range_id.date_start self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end self.date_to = self.date_range_id.date_end
@api.multi
@api.constrains('company_id', 'date_range_id')
def _check_company_id_date_range_id(self):
for rec in self.sudo():
if rec.company_id and rec.date_range_id.company_id and\
rec.company_id != rec.date_range_id.company_id:
raise ValidationError(
_('The Company in the General Ledger Report Wizard and in '
'Date Range must be the same.'))
@api.onchange('receivable_accounts_only', 'payable_accounts_only') @api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self): def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change.""" """Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only: if self.receivable_accounts_only or self.payable_accounts_only:
domain = []
domain = [('company_id', '=', self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only: if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))] domain += [('internal_type', 'in', ('receivable', 'payable'))]
elif self.receivable_accounts_only: elif self.receivable_accounts_only:

15
account_financial_report_qweb/wizard/general_ledger_wizard_view.xml

@ -13,7 +13,7 @@
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"> <div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<group name="filters"> <group name="filters">
<group name="date_range"> <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_from"/>
<field name="date_to"/> <field name="date_to"/>
<field name="fy_start_date" invisible="1"/> <field name="fy_start_date" invisible="1"/>
@ -33,13 +33,20 @@
<field name="receivable_accounts_only"/> <field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/> <field name="payable_accounts_only"/>
</group> </group>
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
</page> </page>
<page string="Filter partners"> <page string="Filter partners">
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
</page> </page>
<page string="Filter cost centers" groups="analytic.group_analytic_accounting"> <page string="Filter cost centers" groups="analytic.group_analytic_accounting">
<field name="cost_center_ids" nolabel="1" options="{'no_create': True}" groups="analytic.group_analytic_accounting"/>
<field name="cost_center_ids" nolabel="1"
options="{'no_create': True}"
groups="analytic.group_analytic_accounting"/>
</page> </page>
<page string="Filter analytic tags"> <page string="Filter analytic tags">
<field name="analytic_tag_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/> <field name="analytic_tag_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>

25
account_financial_report_qweb/wizard/journal_report_wizard.py

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

28
account_financial_report_qweb/wizard/open_items_wizard.py

@ -17,6 +17,7 @@ class OpenItemsReportWizard(models.TransientModel):
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
default=lambda self: self.env.user.company_id, default=lambda self: self.env.user.company_id,
required=False,
string='Company' string='Company'
) )
date_at = fields.Date(required=True, date_at = fields.Date(required=True,
@ -51,11 +52,36 @@ class OpenItemsReportWizard(models.TransientModel):
'will display initial and final balance in that currency.' 'will display initial and final balance in that currency.'
) )
@api.onchange('company_id')
def onchange_company_id(self):
"""Handle company change."""
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:
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') @api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self): def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change.""" """Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only: if self.receivable_accounts_only or self.payable_accounts_only:
domain = []
domain = [('company_id', '=', self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only: if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))] domain += [('internal_type', 'in', ('receivable', 'payable'))]
elif self.receivable_accounts_only: elif self.receivable_accounts_only:

12
account_financial_report_qweb/wizard/open_items_wizard_view.xml

@ -22,13 +22,19 @@
</group> </group>
<group name="partner_filter" col="1"> <group name="partner_filter" col="1">
<label for="partner_ids"/> <label for="partner_ids"/>
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
<field name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
</group> </group>
<group name="account_filter" col="4"> <group name="account_filter" col="4">
<label for="account_ids" colspan="4"/>
<field name="receivable_accounts_only"/> <field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/> <field name="payable_accounts_only"/>
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
</group> </group>
<footer> <footer>
<button name="button_export_html" string="View" <button name="button_export_html" string="View"

51
account_financial_report_qweb/wizard/trial_balance_wizard.py

@ -7,7 +7,7 @@
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval from odoo.tools.safe_eval import safe_eval
from odoo.exceptions import UserError
from odoo.exceptions import UserError, ValidationError
class TrialBalanceReportWizard(models.TransientModel): class TrialBalanceReportWizard(models.TransientModel):
@ -19,6 +19,7 @@ class TrialBalanceReportWizard(models.TransientModel):
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
default=lambda self: self.env.user.company_id, default=lambda self: self.env.user.company_id,
required=False,
string='Company' string='Company'
) )
date_range_id = fields.Many2one( date_range_id = fields.Many2one(
@ -108,6 +109,42 @@ class TrialBalanceReportWizard(models.TransientModel):
('company_id', '=', self.company_id.id) ('company_id', '=', self.company_id.id)
]) ])
self.not_only_one_unaffected_earnings_account = count != 1 self.not_only_one_unaffected_earnings_account = count != 1
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.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.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') @api.onchange('date_range_id')
def onchange_date_range_id(self): def onchange_date_range_id(self):
@ -115,11 +152,21 @@ class TrialBalanceReportWizard(models.TransientModel):
self.date_from = self.date_range_id.date_start self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end self.date_to = self.date_range_id.date_end
@api.multi
@api.constrains('company_id', 'date_range_id')
def _check_company_id_date_range_id(self):
for rec in self.sudo():
if rec.company_id and rec.date_range_id.company_id and\
rec.company_id != rec.date_range_id.company_id:
raise ValidationError(
_('The Company in the Trial Balance Report Wizard and in '
'Date Range must be the same.'))
@api.onchange('receivable_accounts_only', 'payable_accounts_only') @api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self): def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change.""" """Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only: if self.receivable_accounts_only or self.payable_accounts_only:
domain = []
domain = [('company_id', '=', self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only: if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))] domain += [('internal_type', 'in', ('receivable', 'payable'))]
elif self.receivable_accounts_only: elif self.receivable_accounts_only:

15
account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

@ -13,7 +13,7 @@
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"> <div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<group name="filters"> <group name="filters">
<group name="date_range"> <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_from"/>
<field name="date_to"/> <field name="date_to"/>
<field name="fy_start_date" invisible="1"/> <field name="fy_start_date" invisible="1"/>
@ -31,13 +31,22 @@
</group> </group>
<group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1"> <group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1">
<label for="partner_ids"/> <label for="partner_ids"/>
<field name="partner_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}"/>
<field name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
</group> </group>
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<div/>
<group name="account_filter" col="4"> <group name="account_filter" col="4">
<label for="account_ids" colspan="4"/> <label for="account_ids" colspan="4"/>
<field name="receivable_accounts_only"/> <field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/> <field name="payable_accounts_only"/>
<field name="account_ids" nolabel="1" widget="many2many_tags" options="{'no_create': True}" colspan="4"/>
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
</group> </group>
</div> </div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"> <div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">

Loading…
Cancel
Save