Browse Source

Merge pull request #445 from mpanarin/10.0-imp-account_financial_report_qweb

10.0 imp account financial report qweb
pull/451/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
b3e1351fc8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      account_financial_report_qweb/report/general_ledger.py
  2. 2
      account_financial_report_qweb/report/trial_balance.py
  3. 5
      account_financial_report_qweb/wizard/general_ledger_wizard.py
  4. 3
      account_financial_report_qweb/wizard/general_ledger_wizard_view.xml
  5. 4
      account_financial_report_qweb/wizard/trial_balance_wizard.py
  6. 2
      account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

49
account_financial_report_qweb/report/general_ledger.py

@ -33,6 +33,7 @@ class GeneralLedgerReport(models.TransientModel):
company_id = fields.Many2one(comodel_name='res.company') company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account') filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner') filter_partner_ids = fields.Many2many(comodel_name='res.partner')
filter_journal_ids = fields.Many2many(comodel_name='account.journal')
filter_cost_center_ids = fields.Many2many( filter_cost_center_ids = fields.Many2many(
comodel_name='account.analytic.account' comodel_name='account.analytic.account'
) )
@ -1103,6 +1104,11 @@ AND
AND AND
rp.partner_id IS NULL rp.partner_id IS NULL
""" """
if self.filter_journal_ids:
query_inject_move_line += """
AND
j.id IN %s
"""
if is_account_line: if is_account_line:
query_inject_move_line += """ query_inject_move_line += """
ORDER BY ORDER BY
@ -1137,6 +1143,10 @@ ORDER BY
self.date_from, self.date_from,
self.date_to, self.date_to,
) )
if self.filter_journal_ids:
query_inject_move_line_params += (tuple(
self.filter_journal_ids.ids,
),)
self.env.cr.execute( self.env.cr.execute(
query_inject_move_line, query_inject_move_line,
query_inject_move_line_params query_inject_move_line_params
@ -1160,7 +1170,8 @@ WITH
SUM(ml.debit) AS debit, SUM(ml.debit) AS debit,
SUM(ml.credit) AS credit, SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance, SUM(ml.balance) AS balance,
ml.currency_id AS currency_id
ml.currency_id AS currency_id,
ml.journal_id as journal_id
FROM FROM
report_general_ledger_qweb_account ra report_general_ledger_qweb_account ra
INNER JOIN INNER JOIN
@ -1193,7 +1204,7 @@ WITH
""" """
query_inject_move_line_centralized += """ query_inject_move_line_centralized += """
GROUP BY GROUP BY
ra.id, ml.account_id, a.code, 2, ml.currency_id
ra.id, ml.account_id, a.code, 2, ml.currency_id, ml.journal_id
) )
INSERT INTO INSERT INTO
report_general_ledger_qweb_move_line report_general_ledger_qweb_move_line
@ -1203,6 +1214,7 @@ INSERT INTO
create_date, create_date,
date, date,
account, account,
journal,
label, label,
debit, debit,
credit, credit,
@ -1214,6 +1226,7 @@ SELECT
NOW() AS create_date, NOW() AS create_date,
ml.date, ml.date,
a.code AS account, a.code AS account,
j.code as journal,
'""" + _('Centralized Entries') + """' AS label, '""" + _('Centralized Entries') + """' AS label,
ml.debit AS debit, ml.debit AS debit,
ml.credit AS credit, ml.credit AS credit,
@ -1227,12 +1240,21 @@ INNER JOIN
move_lines ml ON ra.account_id = ml.account_id move_lines ml ON ra.account_id = ml.account_id
INNER JOIN INNER JOIN
account_account a ON ml.account_id = a.id account_account a ON ml.account_id = a.id
INNER JOIN
account_journal j ON ml.journal_id = j.id
LEFT JOIN LEFT JOIN
res_currency c ON ml.currency_id = c.id res_currency c ON ml.currency_id = c.id
WHERE WHERE
ra.report_id = %s ra.report_id = %s
AND AND
(a.centralized IS NOT NULL AND a.centralized = TRUE) (a.centralized IS NOT NULL AND a.centralized = TRUE)
"""
if self.filter_journal_ids:
query_inject_move_line_centralized += """
AND
j.id in %s
"""
query_inject_move_line_centralized += """
ORDER BY ORDER BY
a.code, ml.date a.code, ml.date
""" """
@ -1249,6 +1271,10 @@ ORDER BY
self.env.uid, self.env.uid,
self.id, self.id,
) )
if self.filter_journal_ids:
query_inject_move_line_centralized_params += (tuple(
self.filter_journal_ids.ids,
),)
self.env.cr.execute( self.env.cr.execute(
query_inject_move_line_centralized, query_inject_move_line_centralized,
query_inject_move_line_centralized_params query_inject_move_line_centralized_params
@ -1288,8 +1314,13 @@ ORDER BY
sub_subquery_sum_amounts += """ sub_subquery_sum_amounts += """
WHERE WHERE
a.company_id = %(company_id)s a.company_id = %(company_id)s
AND a.id IN %(unaffected_earnings_account_ids)s
AND
a.id IN %(unaffected_earnings_account_ids)s
""" """
if self.filter_journal_ids:
sub_subquery_sum_amounts += """
AND
ml.journal_id in %(filter_journal_ids)s """
return sub_subquery_sum_amounts return sub_subquery_sum_amounts
def _get_unaffected_earnings_account_sub_subquery_sum_final(self): def _get_unaffected_earnings_account_sub_subquery_sum_final(self):
@ -1327,7 +1358,13 @@ ORDER BY
sub_subquery_sum_amounts += """ sub_subquery_sum_amounts += """
WHERE WHERE
a.company_id = %(company_id)s a.company_id = %(company_id)s
AND a.id IN %(unaffected_earnings_account_ids)s
AND
a.id IN %(unaffected_earnings_account_ids)s
"""
if self.filter_journal_ids:
sub_subquery_sum_amounts += """
AND
ml.journal_id in %(filter_journal_ids)s
""" """
return sub_subquery_sum_amounts return sub_subquery_sum_amounts
@ -1405,6 +1442,10 @@ ORDER BY
query_inject_account_params['report_id'] = self.id query_inject_account_params['report_id'] = self.id
query_inject_account_params['user_id'] = self.env.uid query_inject_account_params['user_id'] = self.env.uid
if self.filter_journal_ids:
query_inject_account_params['filter_journal_ids'] = (tuple(
self.filter_journal_ids.ids,
),)
# Fetch the profit and loss accounts # Fetch the profit and loss accounts
query_unaffected_earnings_account_ids = """ query_unaffected_earnings_account_ids = """
SELECT a.id SELECT a.id

2
account_financial_report_qweb/report/trial_balance.py

@ -28,6 +28,7 @@ class TrialBalanceReport(models.TransientModel):
company_id = fields.Many2one(comodel_name='res.company') company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account') filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner') filter_partner_ids = fields.Many2many(comodel_name='res.partner')
filter_journal_ids = fields.Many2many(comodel_name='account.journal')
show_partner_details = fields.Boolean() show_partner_details = fields.Boolean()
# General Ledger Report Data fields, # General Ledger Report Data fields,
@ -170,6 +171,7 @@ class TrialBalanceReportCompute(models.TransientModel):
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, account_ids.ids)], 'filter_account_ids': [(6, 0, account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)], 'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
'filter_journal_ids': [(6, 0, self.filter_journal_ids.ids)],
'fy_start_date': self.fy_start_date, 'fy_start_date': self.fy_start_date,
} }

5
account_financial_report_qweb/wizard/general_ledger_wizard.py

@ -51,6 +51,10 @@ class GeneralLedgerReportWizard(models.TransientModel):
comodel_name='res.partner', comodel_name='res.partner',
string='Filter partners', string='Filter partners',
) )
journal_ids = fields.Many2many(
comodel_name="account.journal",
string="Filter journals",
)
cost_center_ids = fields.Many2many( cost_center_ids = fields.Many2many(
comodel_name='account.analytic.account', comodel_name='account.analytic.account',
string='Filter cost centers', string='Filter cost centers',
@ -154,6 +158,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)], 'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)], 'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'filter_journal_ids': [(6, 0, self.partner_ids.ids)],
'filter_cost_center_ids': [(6, 0, self.cost_center_ids.ids)], 'filter_cost_center_ids': [(6, 0, self.cost_center_ids.ids)],
'centralize': self.centralize, 'centralize': self.centralize,
'fy_start_date': self.fy_start_date, 'fy_start_date': self.fy_start_date,

3
account_financial_report_qweb/wizard/general_ledger_wizard_view.xml

@ -31,6 +31,9 @@
<label for="partner_ids"/> <label for="partner_ids"/>
<field name="partner_ids" nolabel="1" options="{'no_create': True}"/> <field name="partner_ids" nolabel="1" options="{'no_create': True}"/>
<group/> <group/>
<label for="journal_ids"/>
<field name="journal_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<group/>
<label for="account_ids"/> <label for="account_ids"/>
<group col="4"> <group col="4">
<field name="receivable_accounts_only"/> <field name="receivable_accounts_only"/>

4
account_financial_report_qweb/wizard/trial_balance_wizard.py

@ -49,6 +49,9 @@ class TrialBalanceReportWizard(models.TransientModel):
comodel_name='res.partner', comodel_name='res.partner',
string='Filter partners', string='Filter partners',
) )
journal_ids = fields.Many2many(
comodel_name="account.journal",
)
not_only_one_unaffected_earnings_account = fields.Boolean( not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True, readonly=True,
@ -151,6 +154,7 @@ class TrialBalanceReportWizard(models.TransientModel):
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)], 'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)], 'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'filter_journal_ids': [(6, 0, self.partner_ids.ids)],
'fy_start_date': self.fy_start_date, 'fy_start_date': self.fy_start_date,
'show_partner_details': self.show_partner_details, 'show_partner_details': self.show_partner_details,
} }

2
account_financial_report_qweb/wizard/trial_balance_wizard_view.xml

@ -27,6 +27,8 @@
</group> </group>
<label for="partner_ids" attrs="{'invisible':[('show_partner_details','!=',True)]}"/> <label for="partner_ids" attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<field name="partner_ids" nolabel="1" options="{'no_create': True}" attrs="{'invisible':[('show_partner_details','!=',True)]}"/> <field name="partner_ids" nolabel="1" options="{'no_create': True}" attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<label for="journal_ids"/>
<field name="journal_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/> <group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<label for="account_ids"/> <label for="account_ids"/>
<group col="4"> <group col="4">

Loading…
Cancel
Save