Add missing unaffected earnings account into reports
parent
7e2d01dfa8
commit
1421c92442
|
@ -6,8 +6,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 9.0c\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-07-29 07:38+0000\n"
|
||||
"PO-Revision-Date: 2016-07-29 07:38+0000\n"
|
||||
"POT-Creation-Date: 2016-08-12 12:17+0000\n"
|
||||
"PO-Revision-Date: 2016-08-12 12:17+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -262,6 +262,22 @@ msgstr ""
|
|||
msgid "Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_aged_partner_balance_wizard_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_open_items_report_wizard_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_company_id
|
||||
msgid "Company"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_aged_partner_balance_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_open_items_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_trial_balance_qweb_company_id
|
||||
msgid "Company id"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger_xlsx.py:30
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_move_line_cost_center
|
||||
|
@ -463,6 +479,12 @@ msgstr ""
|
|||
msgid "Date from"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_date_range_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_date_range_id
|
||||
msgid "Date range"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger_xlsx.py:61
|
||||
#: code:addons/account_financial_report_qweb/report/trial_balance_xlsx.py:66
|
||||
|
@ -472,12 +494,6 @@ msgstr ""
|
|||
msgid "Date range filter"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_date_range_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_date_range_id
|
||||
msgid "Date range id"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_date_to
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_date_to
|
||||
|
@ -683,6 +699,11 @@ msgstr ""
|
|||
msgid "General Ledger XLSX"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.view,arch_db:account_financial_report_qweb.general_ledger_wizard
|
||||
msgid "General Ledger can be computed only if selected company have only one unaffected earnings account."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_trial_balance_qweb_general_ledger_id
|
||||
msgid "General ledger id"
|
||||
|
@ -918,14 +939,20 @@ msgid "No"
|
|||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:457
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:673
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:275
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:491
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:491
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:707
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:277
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:493
|
||||
#, python-format
|
||||
msgid "No partner allocated"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_not_only_one_unaffected_earnings_account
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_not_only_one_unaffected_earnings_account
|
||||
msgid "Not only one unaffected earnings account"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.menu,name:account_financial_report_qweb.menu_oca_reports
|
||||
msgid "OCA accounting reports"
|
||||
|
@ -1224,6 +1251,16 @@ msgstr ""
|
|||
msgid "Trial Balance XLSX"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.view,arch_db:account_financial_report_qweb.trial_balance_wizard
|
||||
msgid "Trial Balance can be computed only if selected company have only one unaffected earnings account."
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_unaffected_earnings_account
|
||||
msgid "Unaffected earnings account"
|
||||
msgstr ""
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,help:account_financial_report_qweb.field_general_ledger_report_wizard_hide_account_balance_at_0
|
||||
#: model:ir.model.fields,help:account_financial_report_qweb.field_open_items_report_wizard_hide_account_balance_at_0
|
||||
|
|
|
@ -6,8 +6,8 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 9.0c\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-08-11 09:11+0000\n"
|
||||
"PO-Revision-Date: 2016-08-11 09:11+0000\n"
|
||||
"POT-Creation-Date: 2016-08-12 12:18+0000\n"
|
||||
"PO-Revision-Date: 2016-08-12 12:18+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -246,7 +246,7 @@ msgid "Centralized"
|
|||
msgstr "Centralisé"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:901
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:933
|
||||
#, python-format
|
||||
msgid "Centralized Entries"
|
||||
msgstr "Écritures centralisées"
|
||||
|
@ -270,6 +270,14 @@ msgstr "Code"
|
|||
msgid "Company"
|
||||
msgstr "Société"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_aged_partner_balance_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_open_items_qweb_company_id
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_trial_balance_qweb_company_id
|
||||
msgid "Company id"
|
||||
msgstr "Société"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger_xlsx.py:30
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_move_line_cost_center
|
||||
|
@ -529,7 +537,7 @@ msgstr "Débit"
|
|||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_trial_balance_qweb_partner_display_name
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_display_name
|
||||
msgid "Display Name"
|
||||
msgstr "Afficher le nom"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/aged_partner_balance_xlsx.py:75
|
||||
|
@ -691,6 +699,11 @@ msgstr "General Ledger Report Wizard"
|
|||
msgid "General Ledger XLSX"
|
||||
msgstr "Grand livre en XLSX"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.view,arch_db:account_financial_report_qweb.general_ledger_wizard
|
||||
msgid "General Ledger can be computed only if selected company have only one unaffected earnings account."
|
||||
msgstr "Le Grand Livre ne peut être calculé que si la société sélectionnée a un seul compte de résultat non affecté."
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_trial_balance_qweb_general_ledger_id
|
||||
msgid "General ledger id"
|
||||
|
@ -926,14 +939,20 @@ msgid "No"
|
|||
msgstr "Non"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:459
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:675
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:491
|
||||
#: code:addons/account_financial_report_qweb/report/general_ledger.py:707
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:277
|
||||
#: code:addons/account_financial_report_qweb/report/open_items.py:493
|
||||
#, python-format
|
||||
msgid "No partner allocated"
|
||||
msgstr "Écritures sans partenaire"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_general_ledger_report_wizard_not_only_one_unaffected_earnings_account
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_trial_balance_report_wizard_not_only_one_unaffected_earnings_account
|
||||
msgid "Not only one unaffected earnings account"
|
||||
msgstr "Pas un seul compte de résultat non affecté"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.menu,name:account_financial_report_qweb.menu_oca_reports
|
||||
msgid "OCA accounting reports"
|
||||
|
@ -1232,6 +1251,16 @@ msgstr "Trial Balance Report Wizard"
|
|||
msgid "Trial Balance XLSX"
|
||||
msgstr "Balance générale XLSX"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.ui.view,arch_db:account_financial_report_qweb.trial_balance_wizard
|
||||
msgid "Trial Balance can be computed only if selected company have only one unaffected earnings account."
|
||||
msgstr "La Balance Générale ne peut être calculée que si la société sélectionnée a un seul compte de résultat non affecté."
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,field_description:account_financial_report_qweb.field_report_general_ledger_qweb_unaffected_earnings_account
|
||||
msgid "Unaffected earnings account"
|
||||
msgstr "Compte de résultat non affecté"
|
||||
|
||||
#. module: account_financial_report_qweb
|
||||
#: model:ir.model.fields,help:account_financial_report_qweb.field_general_ledger_report_wizard_hide_account_balance_at_0
|
||||
#: model:ir.model.fields,help:account_financial_report_qweb.field_open_items_report_wizard_hide_account_balance_at_0
|
||||
|
@ -1333,3 +1362,4 @@ msgstr "report_trial_balance_qweb_account"
|
|||
#: model:ir.model,name:account_financial_report_qweb.model_report_trial_balance_qweb_partner
|
||||
msgid "report_trial_balance_qweb_partner"
|
||||
msgstr "report_trial_balance_qweb_partner"
|
||||
|
||||
|
|
|
@ -51,6 +51,22 @@ class GeneralLedgerReport(models.TransientModel):
|
|||
inverse_name='report_id'
|
||||
)
|
||||
|
||||
# Compute of unaffected earnings account
|
||||
@api.depends('company_id')
|
||||
def _compute_unaffected_earnings_account(self):
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
self.unaffected_earnings_account = self.env['account.account'].search(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
|
||||
unaffected_earnings_account = fields.Many2one(
|
||||
comodel_name='account.account',
|
||||
compute='_compute_unaffected_earnings_account',
|
||||
store=True
|
||||
)
|
||||
|
||||
|
||||
class GeneralLedgerReportAccount(models.TransientModel):
|
||||
|
||||
|
@ -198,6 +214,13 @@ class GeneralLedgerReportCompute(models.TransientModel):
|
|||
# Compute report data
|
||||
self._inject_account_values()
|
||||
self._inject_partner_values()
|
||||
|
||||
# Add unaffected earnings account
|
||||
if (not self.filter_account_ids or
|
||||
self.unaffected_earnings_account.id in
|
||||
self.filter_account_ids.ids):
|
||||
self._inject_unaffected_earnings_account_values()
|
||||
|
||||
self._inject_line_not_centralized_values()
|
||||
self._inject_line_not_centralized_values(is_account_line=False,
|
||||
is_partner_line=True)
|
||||
|
@ -206,6 +229,13 @@ class GeneralLedgerReportCompute(models.TransientModel):
|
|||
only_empty_partner_line=True)
|
||||
if self.centralize:
|
||||
self._inject_line_centralized_values()
|
||||
|
||||
# Complete unaffected earnings account
|
||||
if (not self.filter_account_ids or
|
||||
self.unaffected_earnings_account.id in
|
||||
self.filter_account_ids.ids):
|
||||
self._complete_unaffected_earnings_account_values()
|
||||
|
||||
# Compute display flag
|
||||
self._compute_has_second_currency()
|
||||
# Refresh cache because all data are computed with SQL requests
|
||||
|
@ -285,6 +315,7 @@ WITH
|
|||
query_inject_account += """
|
||||
WHERE
|
||||
a.company_id = %s
|
||||
AND a.id != %s
|
||||
"""
|
||||
if self.filter_account_ids:
|
||||
query_inject_account += """
|
||||
|
@ -364,6 +395,7 @@ AND
|
|||
)
|
||||
query_inject_account_params += (
|
||||
self.company_id.id,
|
||||
self.unaffected_earnings_account.id,
|
||||
)
|
||||
if self.filter_account_ids:
|
||||
query_inject_account_params += (
|
||||
|
@ -979,3 +1011,141 @@ WHERE id = %s
|
|||
"""
|
||||
params = (self.id,) * 3
|
||||
self.env.cr.execute(query_update_has_second_currency, params)
|
||||
|
||||
def _inject_unaffected_earnings_account_values(self):
|
||||
"""Inject the report values of the unaffected earnings account
|
||||
for report_general_ledger_qweb_account."""
|
||||
subquery_sum_amounts = """
|
||||
SELECT
|
||||
SUM(ml.balance) AS balance
|
||||
FROM
|
||||
account_account a
|
||||
INNER JOIN
|
||||
account_account_type at ON a.user_type_id = at.id
|
||||
INNER JOIN
|
||||
account_move_line ml
|
||||
ON a.id = ml.account_id
|
||||
AND ml.date <= %s
|
||||
AND
|
||||
NOT(
|
||||
at.include_initial_balance != TRUE AND ml.date >= %s
|
||||
OR at.include_initial_balance = TRUE
|
||||
)
|
||||
"""
|
||||
if self.only_posted_moves:
|
||||
subquery_sum_amounts += """
|
||||
INNER JOIN
|
||||
account_move m ON ml.move_id = m.id AND m.state = 'posted'
|
||||
"""
|
||||
if self.filter_cost_center_ids:
|
||||
subquery_sum_amounts += """
|
||||
INNER JOIN
|
||||
account_analytic_account aa
|
||||
ON
|
||||
ml.analytic_account_id = aa.id
|
||||
AND aa.id IN %s
|
||||
"""
|
||||
subquery_sum_amounts += """
|
||||
WHERE
|
||||
a.company_id =%s
|
||||
AND a.id != %s
|
||||
"""
|
||||
query_inject_account = """
|
||||
WITH
|
||||
initial_sum_amounts AS ( """ + subquery_sum_amounts + """ )
|
||||
INSERT INTO
|
||||
report_general_ledger_qweb_account
|
||||
(
|
||||
report_id,
|
||||
create_uid,
|
||||
create_date,
|
||||
account_id,
|
||||
code,
|
||||
name,
|
||||
is_partner_account,
|
||||
initial_balance
|
||||
)
|
||||
SELECT
|
||||
%s AS report_id,
|
||||
%s AS create_uid,
|
||||
NOW() AS create_date,
|
||||
a.id AS account_id,
|
||||
a.code,
|
||||
a.name,
|
||||
False AS is_partner_account,
|
||||
COALESCE(i.balance, 0.0) AS initial_balance
|
||||
FROM
|
||||
account_account a,
|
||||
initial_sum_amounts i
|
||||
WHERE
|
||||
a.company_id = %s
|
||||
AND a.id = %s
|
||||
"""
|
||||
query_inject_account_params = (
|
||||
self.date_from,
|
||||
self.fy_start_date,
|
||||
)
|
||||
if self.filter_cost_center_ids:
|
||||
query_inject_account_params += (
|
||||
tuple(self.filter_cost_center_ids.ids),
|
||||
)
|
||||
query_inject_account_params += (
|
||||
self.company_id.id,
|
||||
self.unaffected_earnings_account.id,
|
||||
self.id,
|
||||
self.env.uid,
|
||||
self.company_id.id,
|
||||
self.unaffected_earnings_account.id,
|
||||
)
|
||||
self.env.cr.execute(query_inject_account,
|
||||
query_inject_account_params)
|
||||
|
||||
def _complete_unaffected_earnings_account_values(self):
|
||||
"""Complete the report values of the unaffected earnings account
|
||||
for report_general_ledger_qweb_account."""
|
||||
query_update_unaffected_earnings_account_values = """
|
||||
WITH
|
||||
sum_amounts AS
|
||||
(
|
||||
SELECT
|
||||
SUM(COALESCE(rml.debit, 0.0)) AS debit,
|
||||
SUM(COALESCE(rml.credit, 0.0)) AS credit,
|
||||
SUM(
|
||||
COALESCE(rml.debit, 0.0) -
|
||||
COALESCE(rml.credit, 0.0)
|
||||
) + ra.initial_balance AS balance
|
||||
FROM
|
||||
report_general_ledger_qweb_account ra
|
||||
LEFT JOIN
|
||||
report_general_ledger_qweb_move_line rml
|
||||
ON ra.id = rml.report_account_id
|
||||
WHERE
|
||||
ra.report_id = %s
|
||||
AND ra.account_id = %s
|
||||
GROUP BY
|
||||
ra.id
|
||||
)
|
||||
UPDATE
|
||||
report_general_ledger_qweb_account ra
|
||||
SET
|
||||
initial_debit = 0.0,
|
||||
initial_credit = 0.0,
|
||||
final_debit = sum_amounts.debit,
|
||||
final_credit = sum_amounts.credit,
|
||||
final_balance = sum_amounts.balance
|
||||
FROM
|
||||
sum_amounts
|
||||
WHERE
|
||||
ra.report_id = %s
|
||||
AND ra.account_id = %s
|
||||
"""
|
||||
params = (
|
||||
self.id,
|
||||
self.unaffected_earnings_account.id,
|
||||
self.id,
|
||||
self.unaffected_earnings_account.id,
|
||||
)
|
||||
self.env.cr.execute(
|
||||
query_update_unaffected_earnings_account_values,
|
||||
params
|
||||
)
|
||||
|
|
|
@ -55,6 +55,22 @@ class GeneralLedgerReportWizard(models.TransientModel):
|
|||
string='Filter cost centers',
|
||||
)
|
||||
|
||||
not_only_one_unaffected_earnings_account = fields.Boolean(
|
||||
readonly=True,
|
||||
string='Not only one unaffected earnings account'
|
||||
)
|
||||
|
||||
@api.onchange('company_id')
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
count = self.env['account.account'].search_count(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
self.not_only_one_unaffected_earnings_account = count != 1
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
def onchange_date_range_id(self):
|
||||
"""Handle date range change."""
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<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)]"/>
|
||||
|
@ -35,12 +36,24 @@
|
|||
<field name="payable_accounts_only"/>
|
||||
</group>
|
||||
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
|
||||
<group/>
|
||||
<h4>General Ledger can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group/>
|
||||
</div>
|
||||
<footer>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
|
@ -49,6 +49,22 @@ class TrialBalanceReportWizard(models.TransientModel):
|
|||
string='Filter partners',
|
||||
)
|
||||
|
||||
not_only_one_unaffected_earnings_account = fields.Boolean(
|
||||
readonly=True,
|
||||
string='Not only one unaffected earnings account'
|
||||
)
|
||||
|
||||
@api.onchange('company_id')
|
||||
def onchange_company_id(self):
|
||||
"""Handle company change."""
|
||||
account_type = self.env.ref('account.data_unaffected_earnings')
|
||||
count = self.env['account.account'].search_count(
|
||||
[
|
||||
('user_type_id', '=', account_type.id),
|
||||
('company_id', '=', self.company_id.id)
|
||||
])
|
||||
self.not_only_one_unaffected_earnings_account = count != 1
|
||||
|
||||
@api.onchange('date_range_id')
|
||||
def onchange_date_range_id(self):
|
||||
"""Handle date range change."""
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<group name="main_info">
|
||||
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<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)]"/>
|
||||
|
@ -32,12 +33,24 @@
|
|||
<field name="payable_accounts_only"/>
|
||||
</group>
|
||||
<field name="account_ids" nolabel="1" options="{'no_create': True}"/>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
|
||||
<group/>
|
||||
<h4>Trial Balance can be computed only if selected company have only one unaffected earnings account.</h4>
|
||||
<group/>
|
||||
</div>
|
||||
<footer>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
|
||||
<button name="button_export_pdf" string="Export PDF" type="object" default_focus="1" class="oe_highlight"/>
|
||||
or
|
||||
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue