Browse Source

[11.0][IMP] account_financial_report - foreign_currency

pull/663/head
hveficent 7 years ago
committed by Ernesto Tejeda
parent
commit
843aefc3b4
  1. 8
      account_financial_report/README.rst
  2. 3
      account_financial_report/__manifest__.py
  3. 7
      account_financial_report/menuitems.xml
  4. 2
      account_financial_report/report/__init__.py
  5. 93
      account_financial_report/report/abstract_report_xlsx.py
  6. 2
      account_financial_report/report/aged_partner_balance.py
  7. 148
      account_financial_report/report/general_ledger.py
  8. 79
      account_financial_report/report/general_ledger_xlsx.py
  9. 810
      account_financial_report/report/journal_ledger.py
  10. 249
      account_financial_report/report/journal_ledger_xlsx.py
  11. 230
      account_financial_report/report/open_items.py
  12. 35
      account_financial_report/report/open_items_xlsx.py
  13. 203
      account_financial_report/report/templates/general_ledger.xml
  14. 463
      account_financial_report/report/templates/journal_ledger.xml
  15. 89
      account_financial_report/report/templates/open_items.xml
  16. 179
      account_financial_report/report/templates/trial_balance.xml
  17. 4
      account_financial_report/report/templates/vat_report.xml
  18. 61
      account_financial_report/report/trial_balance.py
  19. 67
      account_financial_report/report/trial_balance_xlsx.py
  20. 31
      account_financial_report/reports.xml
  21. 3
      account_financial_report/static/src/css/report.css
  22. 13
      account_financial_report/static/src/js/account_financial_report_backend.js
  23. 27
      account_financial_report/static/src/js/account_financial_report_widgets.js
  24. 2
      account_financial_report/tests/__init__.py
  25. 2
      account_financial_report/tests/abstract_test.py
  26. 78
      account_financial_report/tests/abstract_test_foreign_currency.py
  27. 5
      account_financial_report/tests/test_general_ledger.py
  28. 366
      account_financial_report/tests/test_journal_ledger.py
  29. 5
      account_financial_report/tests/test_open_items.py
  30. 6
      account_financial_report/tests/test_trial_balance.py
  31. 2
      account_financial_report/tests/test_vat_report.py
  32. 9
      account_financial_report/view/report_journal_ledger.xml
  33. 6
      account_financial_report/view/report_template.xml
  34. 1
      account_financial_report/wizard/__init__.py
  35. 2
      account_financial_report/wizard/aged_partner_balance_wizard.py
  36. 7
      account_financial_report/wizard/general_ledger_wizard.py
  37. 1
      account_financial_report/wizard/general_ledger_wizard_view.xml
  38. 142
      account_financial_report/wizard/journal_ledger_wizard.py
  39. 66
      account_financial_report/wizard/journal_ledger_wizard_view.xml
  40. 7
      account_financial_report/wizard/open_items_wizard.py
  41. 1
      account_financial_report/wizard/open_items_wizard_view.xml
  42. 8
      account_financial_report/wizard/trial_balance_wizard.py
  43. 1
      account_financial_report/wizard/trial_balance_wizard_view.xml

8
account_financial_report/README.rst

@ -15,6 +15,14 @@ Accounting / Reporting / OCA Reports.
- Aged Partner Balance
- VAT Report
Currently General ledger, Trial Balance and Open Items are fully compatible with a foreign
currency set up in account in order to display balances. Moreover, any foreign
currency used in account move lines is properly shown.
In case that in an account has not been configured a second currency foreign
currency balances are not available.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/11.0

3
account_financial_report/__manifest__.py

@ -21,6 +21,7 @@
'data': [
'wizard/aged_partner_balance_wizard_view.xml',
'wizard/general_ledger_wizard_view.xml',
'wizard/journal_ledger_wizard_view.xml',
'wizard/open_items_wizard_view.xml',
'wizard/trial_balance_wizard_view.xml',
'wizard/vat_report_wizard_view.xml',
@ -29,12 +30,14 @@
'report/templates/layouts.xml',
'report/templates/aged_partner_balance.xml',
'report/templates/general_ledger.xml',
'report/templates/journal_ledger.xml',
'report/templates/open_items.xml',
'report/templates/trial_balance.xml',
'report/templates/vat_report.xml',
'view/account_view.xml',
'view/report_template.xml',
'view/report_general_ledger.xml',
'view/report_journal_ledger.xml',
'view/report_trial_balance.xml',
'view/report_open_items.xml',
'view/report_aged_partner_balance.xml',

7
account_financial_report/menuitems.xml

@ -15,6 +15,13 @@
sequence="10"
/>
<menuitem
parent="menu_oca_reports"
action="action_journal_ledger_wizard"
id="menu_journal_ledger_wizard"
sequence="15"
/>
<menuitem
parent="menu_oca_reports"
action="action_trial_balance_wizard"

2
account_financial_report/report/__init__.py

@ -8,6 +8,8 @@ from . import aged_partner_balance
from . import aged_partner_balance_xlsx
from . import general_ledger
from . import general_ledger_xlsx
from . import journal_ledger
from . import journal_ledger_xlsx
from . import open_items
from . import open_items_xlsx
from . import trial_balance

93
account_financial_report/report/abstract_report_xlsx.py

@ -43,7 +43,7 @@ class AbstractReportXslx(models.AbstractModel):
report_name = self._get_report_name()
filters = self._get_report_filters(report)
self.columns = self._get_report_columns(report)
self.workbook = workbook
self.sheet = workbook.add_worksheet(report_name[:31])
self._set_column_width()
@ -92,9 +92,12 @@ class AbstractReportXslx(models.AbstractModel):
{'bold': True,
'border': True,
'bg_color': '#FFFFCC'})
self.format_header_amount.set_num_format('#,##0.00')
currency_id = self.env['res.company']._get_user_currency()
self.format_header_amount.set_num_format(
'#,##0.'+'0'*currency_id.decimal_places)
self.format_amount = workbook.add_format()
self.format_amount.set_num_format('#,##0.00')
self.format_amount.set_num_format(
'#,##0.'+'0'*currency_id.decimal_places)
self.format_percent_bold_italic = workbook.add_format(
{'bold': True, 'italic': True}
)
@ -168,13 +171,19 @@ class AbstractReportXslx(models.AbstractModel):
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
self.sheet.write_string(
self.row_pos, col_pos, value.name or '')
self.row_pos, col_pos, value.name or '', self.format_right)
elif cell_type == 'string':
self.sheet.write_string(self.row_pos, col_pos, value or '')
elif cell_type == 'amount':
self.sheet.write_number(
self.row_pos, col_pos, float(value), self.format_amount
)
elif cell_type == 'amount_currency':
if line_object.currency_id:
format_amt = self._get_currency_amt_format(line_object)
self.sheet.write_number(
self.row_pos, col_pos, float(value), format_amt
)
self.row_pos += 1
def write_initial_balance(self, my_object, label):
@ -195,6 +204,24 @@ class AbstractReportXslx(models.AbstractModel):
self.sheet.write_number(
self.row_pos, col_pos, float(value), self.format_amount
)
elif cell_type == 'amount_currency':
if my_object.currency_id:
format_amt = self._get_currency_amt_format(
my_object)
self.sheet.write_number(
self.row_pos, col_pos,
float(value), format_amt
)
elif column.get('field_currency_balance'):
value = getattr(my_object, column['field_currency_balance'])
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
if my_object.currency_id:
self.sheet.write_string(
self.row_pos, col_pos,
value.name or '',
self.format_right
)
self.row_pos += 1
def write_ending_balance(self, my_object, name, label):
@ -225,10 +252,66 @@ class AbstractReportXslx(models.AbstractModel):
self.row_pos, col_pos, float(value),
self.format_header_amount
)
elif cell_type == 'amount_currency':
if my_object.currency_id:
format_amt = self._get_currency_amt_header_format(
my_object)
self.sheet.write_number(
self.row_pos, col_pos, float(value),
format_amt
)
elif column.get('field_currency_balance'):
value = getattr(my_object, column['field_currency_balance'])
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
if my_object.currency_id:
self.sheet.write_string(
self.row_pos, col_pos,
value.name or '',
self.format_header_right
)
self.row_pos += 1
def _get_currency_amt_format(self, line_object):
""" Return amount format specific for each currency. """
format_amt = getattr(self, 'format_amount')
if line_object.currency_id:
field_name = \
'format_amount_%s' % line_object.currency_id.name
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format()
setattr(self, 'field_name', format_amt)
format_amount = \
'#,##0.' + ('0' * line_object.currency_id.decimal_places)
format_amt.set_num_format(format_amount)
return format_amt
def _get_currency_amt_header_format(self, line_object):
""" Return amount header format for each currency. """
format_amt = getattr(self, 'format_header_amount')
if line_object.currency_id:
field_name = \
'format_header_amount_%s' % line_object.currency_id.name
if hasattr(self, field_name):
format_amt = getattr(self, field_name)
else:
format_amt = self.workbook.add_format(
{'bold': True,
'border': True,
'bg_color': '#FFFFCC'})
setattr(self, 'field_name', format_amt)
format_amount = \
'#,##0.' + ('0' * line_object.currency_id.decimal_places)
format_amt.set_num_format(format_amount)
return format_amt
def _generate_report_content(self, workbook, report):
pass
"""
Allow to fetch report content to be displayed.
"""
raise NotImplementedError()
def _get_report_name(self):
"""

2
account_financial_report/report/aged_partner_balance.py

@ -238,7 +238,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
self._inject_move_line_values(only_empty_partner_line=True)
self._compute_accounts_cumul()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _inject_account_values(self):
"""Inject report values for report_aged_partner_balance_account"""

148
account_financial_report/report/general_ledger.py

@ -29,6 +29,7 @@ class GeneralLedgerReport(models.TransientModel):
fy_start_date = fields.Date()
only_posted_moves = fields.Boolean()
hide_account_balance_at_0 = fields.Boolean()
foreign_currency = fields.Boolean()
company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner')
@ -38,7 +39,6 @@ class GeneralLedgerReport(models.TransientModel):
centralize = fields.Boolean()
# Flag fields, used for report display
has_second_currency = fields.Boolean()
show_cost_center = fields.Boolean(
default=lambda self: self.env.user.has_group(
'analytic.group_analytic_accounting'
@ -91,9 +91,12 @@ class GeneralLedgerReportAccount(models.TransientModel):
initial_debit = fields.Float(digits=(16, 2))
initial_credit = fields.Float(digits=(16, 2))
initial_balance = fields.Float(digits=(16, 2))
currency_id = fields.Many2one('res.currency')
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
final_debit = fields.Float(digits=(16, 2))
final_credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Flag fields, used for report display and for data computation
is_partner_account = fields.Boolean()
@ -130,9 +133,12 @@ class GeneralLedgerReportPartner(models.TransientModel):
initial_debit = fields.Float(digits=(16, 2))
initial_credit = fields.Float(digits=(16, 2))
initial_balance = fields.Float(digits=(16, 2))
currency_id = fields.Many2one('res.currency')
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
final_debit = fields.Float(digits=(16, 2))
final_credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
move_line_ids = fields.One2many(
@ -177,6 +183,7 @@ class GeneralLedgerReportMoveLine(models.TransientModel):
entry = fields.Char()
journal = fields.Char()
account = fields.Char()
taxes_description = fields.Char()
partner = fields.Char()
label = fields.Char()
cost_center = fields.Char()
@ -264,12 +271,8 @@ class GeneralLedgerReportCompute(models.TransientModel):
if self.centralize:
self._inject_line_centralized_values()
if with_line_details:
# Compute display flag
self._compute_has_second_currency()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _get_account_sub_subquery_sum_amounts(
self, include_initial_balance, date_included):
@ -279,7 +282,13 @@ class GeneralLedgerReportCompute(models.TransientModel):
a.id AS account_id,
SUM(ml.debit) AS debit,
SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance
SUM(ml.balance) AS balance,
c.id AS currency_id,
CASE
WHEN c.id IS NOT NULL
THEN SUM(ml.amount_currency)
ELSE NULL
END AS balance_currency
FROM
accounts a
INNER JOIN
@ -321,8 +330,12 @@ class GeneralLedgerReportCompute(models.TransientModel):
AND aa.id IN %s
"""
sub_subquery_sum_amounts += """
LEFT JOIN
res_currency c ON a.currency_id = c.id
"""
sub_subquery_sum_amounts += """
GROUP BY
a.id
a.id, c.id
"""
return sub_subquery_sum_amounts
@ -333,7 +346,9 @@ class GeneralLedgerReportCompute(models.TransientModel):
sub.account_id AS account_id,
SUM(COALESCE(sub.debit, 0.0)) AS debit,
SUM(COALESCE(sub.credit, 0.0)) AS credit,
SUM(COALESCE(sub.balance, 0.0)) AS balance
SUM(COALESCE(sub.balance, 0.0)) AS balance,
MAX(sub.currency_id) AS currency_id,
SUM(COALESCE(sub.balance_currency, 0.0)) AS balance_currency
FROM
(
"""
@ -365,7 +380,8 @@ WITH
a.name,
a.internal_type IN ('payable', 'receivable')
AS is_partner_account,
a.user_type_id
a.user_type_id,
a.currency_id
FROM
account_account a
"""
@ -431,9 +447,12 @@ INSERT INTO
initial_debit,
initial_credit,
initial_balance,
currency_id,
initial_balance_foreign_currency,
final_debit,
final_credit,
final_balance,
final_balance_foreign_currency,
is_partner_account
)
SELECT
@ -446,9 +465,12 @@ SELECT
COALESCE(i.debit, 0.0) AS initial_debit,
COALESCE(i.credit, 0.0) AS initial_credit,
COALESCE(i.balance, 0.0) AS initial_balance,
c.id AS currency_id,
COALESCE(i.balance_currency, 0.0) AS initial_balance_foreign_currency,
COALESCE(f.debit, 0.0) AS final_debit,
COALESCE(f.credit, 0.0) AS final_credit,
COALESCE(f.balance, 0.0) AS final_balance,
COALESCE(f.balance_currency, 0.0) AS final_balance_foreign_currency,
a.is_partner_account
FROM
accounts a
@ -456,6 +478,8 @@ LEFT JOIN
initial_sum_amounts i ON a.id = i.account_id
LEFT JOIN
final_sum_amounts f ON a.id = f.account_id
LEFT JOIN
res_currency c ON c.id = a.currency_id
WHERE
(
i.debit IS NOT NULL AND i.debit != 0
@ -534,9 +558,19 @@ AND
ap.partner_id AS partner_id,
SUM(ml.debit) AS debit,
SUM(ml.credit) AS credit,
SUM(ml.balance) AS balance
SUM(ml.balance) AS balance,
c.id as currency_id,
CASE
WHEN c.id IS NOT NULL
THEN SUM(ml.amount_currency)
ELSE NULL
END AS balance_currency
FROM
accounts_partners ap
INNER JOIN account_account ac
ON ac.id = ap.account_id
LEFT JOIN
res_currency c ON ac.currency_id = c.id
INNER JOIN
account_move_line ml
ON ap.account_id = ml.account_id
@ -580,7 +614,7 @@ AND
"""
sub_subquery_sum_amounts += """
GROUP BY
ap.account_id, ap.partner_id
ap.account_id, ap.partner_id, c.id
"""
return sub_subquery_sum_amounts
@ -595,7 +629,9 @@ AND
sub.partner_id AS partner_id,
SUM(COALESCE(sub.debit, 0.0)) AS debit,
SUM(COALESCE(sub.credit, 0.0)) AS credit,
SUM(COALESCE(sub.balance, 0.0)) AS balance
SUM(COALESCE(sub.balance, 0.0)) AS balance,
MAX(sub.currency_id) AS currency_id,
SUM(COALESCE(sub.balance_currency, 0.0)) AS balance_currency
FROM
(
"""
@ -720,9 +756,12 @@ INSERT INTO
initial_debit,
initial_credit,
initial_balance,
currency_id,
initial_balance_foreign_currency,
final_debit,
final_credit,
final_balance
final_balance,
final_balance_foreign_currency
)
SELECT
ap.report_account_id,
@ -733,9 +772,12 @@ SELECT
COALESCE(i.debit, 0.0) AS initial_debit,
COALESCE(i.credit, 0.0) AS initial_credit,
COALESCE(i.balance, 0.0) AS initial_balance,
i.currency_id AS currency_id,
COALESCE(i.balance_currency, 0.0) AS initial_balance_foreign_currency,
COALESCE(f.debit, 0.0) AS final_debit,
COALESCE(f.credit, 0.0) AS final_credit,
COALESCE(f.balance, 0.0) AS final_balance
COALESCE(f.balance, 0.0) AS final_balance,
COALESCE(f.balance_currency, 0.0) AS final_balance_foreign_currency
FROM
accounts_partners ap
LEFT JOIN
@ -870,6 +912,7 @@ INSERT INTO
entry,
journal,
account,
taxes_description,
partner,
label,
cost_center,
@ -898,6 +941,27 @@ SELECT
m.name AS entry,
j.code AS journal,
a.code AS account,
CASE
WHEN
ml.tax_line_id is not null
THEN
COALESCE(at.description, at.name)
WHEN
ml.tax_line_id is null
THEN
(SELECT
array_to_string(
array_agg(COALESCE(at.description, at.name)
), ', ')
FROM
account_move_line_account_tax_rel aml_at_rel
LEFT JOIN
account_tax at on (at.id = aml_at_rel.account_tax_id)
WHERE
aml_at_rel.account_move_line_id = ml.id)
ELSE
''
END as taxes_description,
"""
if not only_empty_partner_line:
query_inject_move_line += """
@ -968,6 +1032,8 @@ INNER JOIN
account_journal j ON ml.journal_id = j.id
INNER JOIN
account_account a ON ml.account_id = a.id
LEFT JOIN
account_tax at ON ml.tax_line_id = at.id
"""
if is_account_line:
query_inject_move_line += """
@ -1189,48 +1255,6 @@ ORDER BY
query_inject_move_line_centralized_params
)
def _compute_has_second_currency(self):
""" Compute "has_second_currency" flag which will used for display."""
query_update_has_second_currency = """
UPDATE
report_general_ledger
SET
has_second_currency =
(
SELECT
TRUE
FROM
report_general_ledger_move_line l
INNER JOIN
report_general_ledger_account a
ON l.report_account_id = a.id
WHERE
a.report_id = %s
AND l.currency_id IS NOT NULL
LIMIT 1
)
OR
(
SELECT
TRUE
FROM
report_general_ledger_move_line l
INNER JOIN
report_general_ledger_partner p
ON l.report_partner_id = p.id
INNER JOIN
report_general_ledger_account a
ON p.report_account_id = a.id
WHERE
a.report_id = %s
AND l.currency_id IS NOT NULL
LIMIT 1
)
WHERE id = %s
"""
params = (self.id,) * 3
self.env.cr.execute(query_update_has_second_currency, params)
def _get_unaffected_earnings_account_sub_subquery_sum_initial(
self
):
@ -1345,7 +1369,8 @@ WHERE id = %s
name,
is_partner_account,
initial_balance,
final_balance
final_balance,
currency_id
)
SELECT
%(report_id)s AS report_id,
@ -1356,9 +1381,12 @@ WHERE id = %s
a.name,
False AS is_partner_account,
COALESCE(i.initial_balance, 0.0) AS initial_balance,
COALESCE(i.final_balance, 0.0) AS final_balance
COALESCE(i.final_balance, 0.0) AS final_balance,
c.id as currency_id
FROM
account_account a,
account_account a
LEFT JOIN
res_currency c ON c.id = a.currency_id,
sum_amounts i
WHERE
a.company_id = %(company_id)s

79
account_financial_report/report/general_ledger_xlsx.py

@ -15,42 +15,56 @@ class GeneralLedgerXslx(models.AbstractModel):
return _('General Ledger')
def _get_report_columns(self, report):
return {
res = {
0: {'header': _('Date'), 'field': 'date', 'width': 11},
1: {'header': _('Entry'), 'field': 'entry', 'width': 18},
2: {'header': _('Journal'), 'field': 'journal', 'width': 8},
3: {'header': _('Account'), 'field': 'account', 'width': 9},
4: {'header': _('Partner'), 'field': 'partner', 'width': 25},
5: {'header': _('Ref - Label'), 'field': 'label', 'width': 40},
6: {'header': _('Cost center'),
4: {'header': _('Taxes'),
'field': 'taxes_description',
'width': 15},
5: {'header': _('Partner'), 'field': 'partner', 'width': 25},
6: {'header': _('Ref - Label'), 'field': 'label', 'width': 40},
7: {'header': _('Cost center'),
'field': 'cost_center',
'width': 15},
7: {'header': _('Rec.'), 'field': 'matching_number', 'width': 5},
8: {'header': _('Debit'),
8: {'header': _('Rec.'), 'field': 'matching_number', 'width': 5},
9: {'header': _('Debit'),
'field': 'debit',
'field_initial_balance': 'initial_debit',
'field_final_balance': 'final_debit',
'type': 'amount',
'width': 14},
9: {'header': _('Credit'),
'field': 'credit',
'field_initial_balance': 'initial_credit',
'field_final_balance': 'final_credit',
'type': 'amount',
'width': 14},
10: {'header': _('Cumul. Bal.'),
10: {'header': _('Credit'),
'field': 'credit',
'field_initial_balance': 'initial_credit',
'field_final_balance': 'final_credit',
'type': 'amount',
'width': 14},
11: {'header': _('Cumul. Bal.'),
'field': 'cumul_balance',
'field_initial_balance': 'initial_balance',
'field_final_balance': 'final_balance',
'type': 'amount',
'width': 14},
11: {'header': _('Cur.'), 'field': 'currency_id',
'type': 'many2one', 'width': 7},
12: {'header': _('Amount cur.'),
'field': 'amount_currency',
'type': 'amount',
'width': 14},
}
if report.foreign_currency:
foreign_currency = {
12: {'header': _('Cur.'),
'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
13: {'header': _('Amount cur.'),
'field': 'amount_currency',
'field_initial_balance':
'initial_balance_foreign_currency',
'field_final_balance':
'final_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
}
res = {**res, **foreign_currency}
return res
def _get_report_filters(self, report):
return [
@ -63,6 +77,8 @@ class GeneralLedgerXslx(models.AbstractModel):
_('Hide') if report.hide_account_balance_at_0 else _('Show')],
[_('Centralize filter'),
_('Yes') if report.centralize else _('No')],
[_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')],
]
def _get_col_count_filter_name(self):
@ -91,7 +107,7 @@ class GeneralLedgerXslx(models.AbstractModel):
self.write_array_header()
# Display initial balance line for account
self.write_initial_balance(account, _('Initial balance'))
self.write_initial_balance(account)
# Display account move lines
for line in account.move_line_ids:
@ -107,30 +123,41 @@ class GeneralLedgerXslx(models.AbstractModel):
self.write_array_header()
# Display initial balance line for partner
self.write_initial_balance(partner, _('Initial balance'))
self.write_initial_balance(partner)
# Display account move lines
for line in partner.move_line_ids:
self.write_line(line)
# Display ending balance line for partner
self.write_ending_balance(partner, 'partner')
self.write_ending_balance(partner)
# Line break
self.row_pos += 1
# Display ending balance line for account
self.write_ending_balance(account, 'account')
self.write_ending_balance(account)
# 2 lines break
self.row_pos += 2
def write_ending_balance(self, my_object, type_object):
def write_initial_balance(self, my_object):
"""Specific function to write initial balance for General Ledger"""
if 'partner' in my_object._name:
label = _('Partner Initial balance')
my_object.currency_id = my_object.report_account_id.currency_id
elif 'account' in my_object._name:
label = _('Initial balance')
super(GeneralLedgerXslx, self).write_initial_balance(
my_object, label
)
def write_ending_balance(self, my_object):
"""Specific function to write ending balance for General Ledger"""
if type_object == 'partner':
if 'partner' in my_object._name:
name = my_object.name
label = _('Partner ending balance')
elif type_object == 'account':
elif 'account' in my_object._name:
name = my_object.code + ' - ' + my_object.name
label = _('Ending balance')
super(GeneralLedgerXslx, self).write_ending_balance(

810
account_financial_report/report/journal_ledger.py

@ -0,0 +1,810 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
DIGITS = (16, 2)
class ReportJournalLedger(models.TransientModel):
_name = 'report_journal_ledger'
date_from = fields.Date(
required=True
)
date_to = fields.Date(
required=True
)
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
)
move_target = fields.Selection(
selection='_get_move_targets',
default='all',
required=True,
)
sort_option = fields.Selection(
selection='_get_sort_options',
default='move_name',
required=True,
)
group_option = fields.Selection(
selection='_get_group_options',
default='journal',
required=True,
)
journal_ids = fields.Many2many(
comodel_name='account.journal',
required=True,
)
report_journal_ledger_ids = fields.One2many(
comodel_name='report_journal_ledger_journal',
inverse_name='report_id',
)
report_move_ids = fields.One2many(
comodel_name='report_journal_ledger_move',
inverse_name='report_id',
)
report_move_line_ids = fields.One2many(
comodel_name='report_journal_ledger_move_line',
inverse_name='report_id',
)
report_journal_ledger_tax_line_ids = fields.One2many(
comodel_name='report_journal_ledger_journal_tax_line',
inverse_name='report_id',
)
report_tax_line_ids = fields.One2many(
comodel_name='report_journal_ledger_report_tax_line',
inverse_name='report_id',
)
foreign_currency = fields.Boolean()
with_account_name = fields.Boolean()
@api.model
def _get_move_targets(self):
return self.env['journal.ledger.report.wizard']._get_move_targets()
@api.model
def _get_sort_options(self):
return self.env['journal.ledger.report.wizard']._get_sort_options()
@api.model
def _get_group_options(self):
return self.env['journal.ledger.report.wizard']._get_group_options()
@api.multi
def compute_data_for_report(self):
self.ensure_one()
self._inject_journal_values()
self._inject_move_values()
self._inject_move_line_values()
self._inject_journal_tax_values()
self._update_journal_report_total_values()
if self.group_option == 'none':
self._inject_report_tax_values()
# Refresh cache because all data are computed with SQL requests
self.invalidate_cache()
@api.multi
def _inject_journal_values(self):
self.ensure_one()
sql = """
DELETE
FROM report_journal_ledger_journal
WHERE report_id = %s
"""
params = (
self.id,
)
self.env.cr.execute(sql, params)
sql = """
INSERT INTO report_journal_ledger_journal (
create_uid,
create_date,
report_id,
journal_id,
name,
code,
company_id,
currency_id
)
SELECT
%s as create_uid,
NOW() as create_date,
%s as report_id,
aj.id as journal_id,
aj.name as name,
aj.code as code,
aj.company_id as company_id,
COALESCE(aj.currency_id, company.currency_id) as currency_id
FROM
account_journal aj
LEFT JOIN
res_company company on (company.id = aj.company_id)
WHERE
aj.id in %s
AND
aj.company_id = %s
ORDER BY
aj.name
"""
params = (
self.env.uid,
self.id,
tuple(self.journal_ids.ids),
self.company_id.id,
)
self.env.cr.execute(sql, params)
@api.multi
def _inject_move_values(self):
self.ensure_one()
sql = """
DELETE
FROM report_journal_ledger_move
WHERE report_id = %s
"""
params = (
self.id,
)
self.env.cr.execute(sql, params)
sql = self._get_inject_move_insert()
sql += self._get_inject_move_select()
sql += self._get_inject_move_where_clause()
sql += self._get_inject_move_order_by()
params = self._get_inject_move_params()
self.env.cr.execute(sql, params)
@api.multi
def _get_inject_move_insert(self):
return """
INSERT INTO report_journal_ledger_move (
create_uid,
create_date,
report_id,
report_journal_ledger_id,
move_id,
name,
company_id
)
"""
@api.multi
def _get_inject_move_select(self):
return """
SELECT
%s as create_uid,
NOW() as create_date,
rjqj.report_id as report_id,
rjqj.id as report_journal_ledger_id,
am.id as move_id,
am.name as name,
am.company_id as company_id
FROM
account_move am
INNER JOIN
report_journal_ledger_journal rjqj
on (rjqj.journal_id = am.journal_id)
"""
@api.multi
def _get_inject_move_where_clause(self):
self.ensure_one()
where_clause = """
WHERE
rjqj.report_id = %s
AND
am.date >= %s
AND
am.date <= %s
"""
if self.move_target != 'all':
where_clause += """
AND
am.state = %s
"""
return where_clause
@api.multi
def _get_inject_move_order_by(self):
self.ensure_one()
order_by = """
ORDER BY
"""
if self.sort_option == 'move_name':
order_by += " am.name"
elif self.sort_option == 'date':
order_by += " am.date, am.name"
return order_by
@api.multi
def _get_inject_move_params(self):
params = [
self.env.uid,
self.id,
self.date_from,
self.date_to
]
if self.move_target != 'all':
params.append(self.move_target)
return tuple(params)
@api.multi
def _inject_move_line_values(self):
self.ensure_one()
sql = """
DELETE
FROM report_journal_ledger_move_line
WHERE report_id = %s
"""
params = (
self.id,
)
self.env.cr.execute(sql, params)
sql = """
INSERT INTO report_journal_ledger_move_line (
create_uid,
create_date,
report_id,
report_journal_ledger_id,
report_move_id,
move_line_id,
account_id,
account,
account_code,
account_type,
partner_id,
partner,
date,
entry,
label,
debit,
credit,
company_currency_id,
amount_currency,
currency_id,
currency_name,
tax_id,
taxes_description,
company_id
)
SELECT
%s as create_uid,
NOW() as create_date,
rjqm.report_id as report_id,
rjqm.report_journal_ledger_id as report_journal_ledger_id,
rjqm.id as report_move_id,
aml.id as move_line_id,
aml.account_id as account_id,
aa.name as account,
aa.code as account_code,
aa.internal_type as account_type,
aml.partner_id as partner_id,
p.name as partner,
aml.date as date,
rjqm.name as entry,
aml.name as label,
aml.debit as debit,
aml.credit as credit,
aml.company_currency_id as currency_id,
aml.amount_currency as amount_currency,
aml.currency_id as currency_id,
currency.name as currency_name,
aml.tax_line_id as tax_id,
CASE
WHEN
aml.tax_line_id is not null
THEN
COALESCE(at.description, at.name)
WHEN
aml.tax_line_id is null
THEN
(SELECT
array_to_string(
array_agg(COALESCE(at.description, at.name)
), ', ')
FROM
account_move_line_account_tax_rel aml_at_rel
LEFT JOIN
account_tax at on (at.id = aml_at_rel.account_tax_id)
WHERE
aml_at_rel.account_move_line_id = aml.id)
ELSE
''
END as taxes_description,
aml.company_id as company_id
FROM
account_move_line aml
INNER JOIN
report_journal_ledger_move rjqm
on (rjqm.move_id = aml.move_id)
LEFT JOIN
account_account aa
on (aa.id = aml.account_id)
LEFT JOIN
res_partner p
on (p.id = aml.partner_id)
LEFT JOIN
account_tax at
on (at.id = aml.tax_line_id)
LEFT JOIN
res_currency currency
on (currency.id = aml.currency_id)
WHERE
rjqm.report_id = %s
"""
params = (
self.env.uid,
self.id,
)
self.env.cr.execute(sql, params)
@api.multi
def _inject_report_tax_values(self):
self.ensure_one()
sql_distinct_tax_id = """
SELECT
distinct(jrqjtl.tax_id)
FROM
report_journal_ledger_journal_tax_line jrqjtl
WHERE
jrqjtl.report_id = %s
"""
self.env.cr.execute(sql_distinct_tax_id, (self.id,))
rows = self.env.cr.fetchall()
tax_ids = set([row[0] for row in rows])
sql = """
INSERT INTO report_journal_ledger_report_tax_line (
create_uid,
create_date,
report_id,
tax_id,
tax_name,
tax_code,
base_debit,
base_credit,
tax_debit,
tax_credit
)
SELECT
%s as create_uid,
NOW() as create_date,
%s as report_id,
%s as tax_id,
at.name as tax_name,
at.description as tax_code,
(
SELECT sum(base_debit)
FROM report_journal_ledger_journal_tax_line jrqjtl2
WHERE jrqjtl2.report_id = %s
AND jrqjtl2.tax_id = %s
) as base_debit,
(
SELECT sum(base_credit)
FROM report_journal_ledger_journal_tax_line jrqjtl2
WHERE jrqjtl2.report_id = %s
AND jrqjtl2.tax_id = %s
) as base_credit,
(
SELECT sum(tax_debit)
FROM report_journal_ledger_journal_tax_line jrqjtl2
WHERE jrqjtl2.report_id = %s
AND jrqjtl2.tax_id = %s
) as tax_debit,
(
SELECT sum(tax_credit)
FROM report_journal_ledger_journal_tax_line jrqjtl2
WHERE jrqjtl2.report_id = %s
AND jrqjtl2.tax_id = %s
) as tax_credit
FROM
report_journal_ledger_journal_tax_line jrqjtl
LEFT JOIN
account_tax at
on (at.id = jrqjtl.tax_id)
WHERE
jrqjtl.report_id = %s
AND
jrqjtl.tax_id = %s
"""
for tax_id in tax_ids:
params = (
self.env.uid,
self.id,
tax_id,
self.id,
tax_id,
self.id,
tax_id,
self.id,
tax_id,
self.id,
tax_id,
self.id,
tax_id,
)
self.env.cr.execute(sql, params)
@api.multi
def _inject_journal_tax_values(self):
self.ensure_one()
sql = """
DELETE
FROM report_journal_ledger_journal_tax_line
WHERE report_id = %s
"""
params = (
self.id,
)
self.env.cr.execute(sql, params)
sql_distinct_tax_id = """
SELECT
distinct(jrqml.tax_id)
FROM
report_journal_ledger_move_line jrqml
WHERE
jrqml.report_journal_ledger_id = %s
"""
tax_ids_by_journal_id = {}
for report_journal in self.report_journal_ledger_ids:
if report_journal.id not in tax_ids_by_journal_id:
tax_ids_by_journal_id[report_journal.id] = []
self.env.cr.execute(sql_distinct_tax_id, (report_journal.id,))
rows = self.env.cr.fetchall()
tax_ids_by_journal_id[report_journal.id].extend([
row[0] for row in rows if row[0]
])
sql = """
INSERT INTO report_journal_ledger_journal_tax_line (
create_uid,
create_date,
report_id,
report_journal_ledger_id,
tax_id,
tax_name,
tax_code,
base_debit,
base_credit,
tax_debit,
tax_credit
)
SELECT
%s as create_uid,
NOW() as create_date,
%s as report_id,
%s as report_journal_ledger_id,
%s as tax_id,
at.name as tax_name,
at.description as tax_code,
(
SELECT sum(debit)
FROM report_journal_ledger_move_line jrqml2
WHERE jrqml2.report_journal_ledger_id = %s
AND (
SELECT
count(*)
FROM
account_move_line_account_tax_rel aml_at_rel
WHERE
aml_at_rel.account_move_line_id =
jrqml2.move_line_id
AND
aml_at_rel.account_tax_id = %s
) > 0
) as base_debit,
(
SELECT sum(credit)
FROM report_journal_ledger_move_line jrqml2
WHERE jrqml2.report_journal_ledger_id = %s
AND (
SELECT
count(*)
FROM
account_move_line_account_tax_rel aml_at_rel
WHERE
aml_at_rel.account_move_line_id =
jrqml2.move_line_id
AND
aml_at_rel.account_tax_id = %s
) > 0
) as base_credit,
(
SELECT sum(debit)
FROM report_journal_ledger_move_line jrqml2
WHERE jrqml2.report_journal_ledger_id = %s
AND jrqml2.tax_id = %s
) as tax_debit,
(
SELECT sum(credit)
FROM report_journal_ledger_move_line jrqml2
WHERE jrqml2.report_journal_ledger_id = %s
AND jrqml2.tax_id = %s
) as tax_credit
FROM
report_journal_ledger_journal rjqj
LEFT JOIN
account_tax at
on (at.id = %s)
WHERE
rjqj.id = %s
"""
for report_journal_ledger_id in tax_ids_by_journal_id:
tax_ids = tax_ids_by_journal_id[report_journal_ledger_id]
for tax_id in tax_ids:
params = (
self.env.uid,
self.id,
report_journal_ledger_id,
tax_id,
report_journal_ledger_id,
tax_id,
report_journal_ledger_id,
tax_id,
report_journal_ledger_id,
tax_id,
report_journal_ledger_id,
tax_id,
tax_id,
report_journal_ledger_id,
)
self.env.cr.execute(sql, params)
@api.multi
def _update_journal_report_total_values(self):
self.ensure_one()
sql = """
UPDATE
report_journal_ledger_journal rjqj
SET
debit = (
SELECT sum(rjqml.debit)
FROM report_journal_ledger_move_line rjqml
WHERE rjqml.report_journal_ledger_id = rjqj.id
),
credit = (
SELECT sum(rjqml.credit)
FROM report_journal_ledger_move_line rjqml
WHERE rjqml.report_journal_ledger_id = rjqj.id
)
WHERE
rjqj.report_id = %s
"""
self.env.cr.execute(sql, (self.id,))
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_journal_ledger_xlsx'
else:
report_name = 'account_financial_report.' \
'report_journal_ledger_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_journal_ledger').render(
rcontext)
return result
@api.model
def get_html(self, given_context=None):
return self._get_html()
class ReportJournalLedgerJournal(models.TransientModel):
_name = 'report_journal_ledger_journal'
name = fields.Char(
required=True,
)
code = fields.Char()
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
)
journal_id = fields.Many2one(
comodel_name='account.journal',
required=True,
ondelete='cascade',
)
report_move_ids = fields.One2many(
comodel_name='report_journal_ledger_move',
inverse_name='report_journal_ledger_id',
)
report_tax_line_ids = fields.One2many(
comodel_name='report_journal_ledger_journal_tax_line',
inverse_name='report_journal_ledger_id',
)
debit = fields.Float(
digits=DIGITS,
)
credit = fields.Float(
digits=DIGITS,
)
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
)
currency_id = fields.Many2one(
comodel_name='res.currency',
)
class ReportJournalLedgerMove(models.TransientModel):
_name = 'report_journal_ledger_move'
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
)
report_journal_ledger_id = fields.Many2one(
comodel_name='report_journal_ledger_journal',
required=True,
ondelete='cascade',
)
move_id = fields.Many2one(
comodel_name='account.move',
required=True,
ondelete='cascade',
)
report_move_line_ids = fields.One2many(
comodel_name='report_journal_ledger_move_line',
inverse_name='report_move_id',
)
name = fields.Char()
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
)
class ReportJournalLedgerMoveLine(models.TransientModel):
_name = 'report_journal_ledger_move_line'
_order = 'partner_id desc, account_id desc'
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
)
report_journal_ledger_id = fields.Many2one(
comodel_name='report_journal_ledger_journal',
required=True,
ondelete='cascade',
)
report_move_id = fields.Many2one(
comodel_name='report_journal_ledger_move',
required=True,
ondelete='cascade',
)
move_line_id = fields.Many2one(
comodel_name='account.move.line',
required=True,
ondelete='cascade',
)
account_id = fields.Many2one(
comodel_name='account.account'
)
account = fields.Char()
account_code = fields.Char()
account_type = fields.Char()
partner = fields.Char()
partner_id = fields.Many2one(
comodel_name='res.partner',
)
date = fields.Date()
entry = fields.Char()
label = fields.Char()
debit = fields.Float(
digits=DIGITS,
)
credit = fields.Float(
digits=DIGITS,
)
company_currency_id = fields.Many2one(
comodel_name='res.currency',
)
amount_currency = fields.Monetary(
currency_field='currency_id',
)
currency_id = fields.Many2one(
comodel_name='res.currency',
)
currency_name = fields.Char()
taxes_description = fields.Char()
tax_id = fields.Many2one(
comodel_name='account.tax'
)
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
)
class ReportJournalLedgerReportTaxLine(models.TransientModel):
_name = 'report_journal_ledger_report_tax_line'
_order = 'tax_code'
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
)
tax_id = fields.Many2one(
comodel_name='account.tax'
)
tax_name = fields.Char()
tax_code = fields.Char()
base_debit = fields.Float(
digits=DIGITS,
)
base_credit = fields.Float(
digits=DIGITS,
)
base_balance = fields.Float(
digits=DIGITS,
compute='_compute_base_balance',
)
tax_debit = fields.Float(
digits=DIGITS,
)
tax_credit = fields.Float(
digits=DIGITS,
)
tax_balance = fields.Float(
digits=DIGITS,
compute='_compute_tax_balance'
)
@api.multi
def _compute_base_balance(self):
for rec in self:
rec.base_balance = rec.base_debit - rec.base_credit
@api.multi
def _compute_tax_balance(self):
for rec in self:
rec.tax_balance = rec.tax_debit - rec.tax_credit
class ReportJournalLedgerJournalTaxLine(models.TransientModel):
_name = 'report_journal_ledger_journal_tax_line'
_inherit = 'report_journal_ledger_report_tax_line'
_order = 'tax_code'
report_journal_ledger_id = fields.Many2one(
comodel_name='report_journal_ledger_journal',
required=True,
ondelete='cascade',
)

249
account_financial_report/report/journal_ledger_xlsx.py

@ -0,0 +1,249 @@
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, models
class JournalLedgerXslx(models.AbstractModel):
_name = 'report.a_f_r.report_journal_ledger_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
def _get_report_name(self):
return _('Journal Ledger')
def _get_report_columns(self, report):
columns = [
{
'header': _('Entry'),
'field': 'entry',
'width': 18
},
{
'header': _('Date'),
'field': 'date',
'width': 11
},
{
'header': _('Account'),
'field': 'account_code',
'width': 9
},
]
if report.with_account_name:
columns.append({
'header': _('Account Name'),
'field': 'account',
'width': 15
})
columns += [
{
'header': _('Partner'),
'field': 'partner',
'width': 25
},
{
'header': _('Ref - Label'),
'field': 'label',
'width': 40
},
{
'header': _('Taxes'),
'field': 'taxes_description',
'width': 11
},
{
'header': _('Debit'),
'field': 'debit',
'type': 'amount',
'width': 14,
},
{
'header': _('Credit'),
'field': 'credit',
'type': 'amount',
'width': 14
}
]
if report.foreign_currency:
columns += [
{
'header': _('Currency'),
'field': 'currency_id',
'type': 'many2one',
'width': 14
},
{
'header': _('Amount Currency'),
'field': 'amount_currency',
'type': 'amount',
'width': 18
},
]
columns_as_dict = {}
for i, column in enumerate(columns):
columns_as_dict[i] = column
return columns_as_dict
def _get_journal_tax_columns(self, report):
return {
0: {
'header': _('Name'),
'field': 'tax_name',
'width': 35
},
1: {
'header': _('Description'),
'field': 'tax_code',
'width': 18
},
2: {
'header': _('Base Debit'),
'field': 'base_debit',
'type': 'amount',
'width': 14
},
3: {
'header': _('Base Credit'),
'field': 'base_credit',
'type': 'amount',
'width': 14
},
4: {
'header': _('Base Balance'),
'field': 'base_balance',
'type': 'amount',
'width': 14
},
5: {
'header': _('Tax Debit'),
'field': 'tax_debit',
'type': 'amount',
'width': 14
},
6: {
'header': _('Tax Credit'),
'field': 'tax_credit',
'type': 'amount',
'width': 14
},
7: {
'header': _('Tax Balance'),
'field': 'tax_balance',
'type': 'amount',
'width': 14
},
}
def _get_col_count_filter_name(self):
return 2
def _get_col_count_filter_value(self):
return 3
def _get_report_filters(self, report):
target_label_by_value = {
value: label
for value, label in
self.env['journal.ledger.report.wizard']._get_move_targets()
}
sort_option_label_by_value = {
value: label
for value, label in
self.env['journal.ledger.report.wizard']._get_sort_options()
}
return [
[
_('Company'),
report.company_id.name
],
[
_('Date range filter'),
_('From: %s To: %s') % (report.date_from, report.date_to)
],
[
_('Target moves filter'),
_("%s") % target_label_by_value[report.move_target],
],
[
_('Entries sorted by'),
_("%s") % sort_option_label_by_value[report.sort_option],
],
[
_('Journals'),
', '.join([
"%s - %s" % (report_journal.code, report_journal.name)
for report_journal in report.report_journal_ledger_ids
])
]
]
def _generate_report_content(self, workbook, report):
group_option = report.group_option
if group_option == 'journal':
for report_journal in report.report_journal_ledger_ids:
self._generate_journal_content(workbook, report_journal)
elif group_option == 'none':
self._generate_no_group_content(workbook, report)
def _generate_no_group_content(self, workbook, report):
self._generate_moves_content(
workbook, report, "Report", report.report_move_ids)
self._generate_no_group_taxes_summary(workbook, report)
def _generate_journal_content(self, workbook, report_journal):
sheet_name = "%s (%s) - %s" % (
report_journal.code,
report_journal.currency_id.name,
report_journal.name,
)
self._generate_moves_content(
workbook, report_journal.report_id, sheet_name,
report_journal.report_move_ids)
self._generate_journal_taxes_summary(workbook, report_journal)
def _generate_no_group_taxes_summary(self, workbook, report):
self._generate_taxes_summary(
workbook, report, "Tax Report", report.report_tax_line_ids)
def _generate_journal_taxes_summary(self, workbook, report_journal):
sheet_name = "Tax - %s (%s) - %s" % (
report_journal.code,
report_journal.currency_id.name,
report_journal.name,
)
report = report_journal.report_id
self._generate_taxes_summary(
workbook, report, sheet_name, report_journal.report_tax_line_ids)
def _generate_moves_content(self, workbook, report, sheet_name, moves):
self.workbook = workbook
self.sheet = workbook.add_worksheet(sheet_name)
self._set_column_width()
self.row_pos = 1
self.write_array_title(sheet_name)
self.row_pos += 2
self.write_array_header()
for move in moves:
for line in move.report_move_line_ids:
self.write_line(line)
self.row_pos += 1
def _generate_taxes_summary(self, workbook, report, sheet_name, tax_lines):
self.workbook = workbook
self.sheet = workbook.add_worksheet(sheet_name)
self.row_pos = 1
self.write_array_title(sheet_name)
self.row_pos += 2

230
account_financial_report/report/open_items.py

@ -22,13 +22,11 @@ class OpenItemsReport(models.TransientModel):
date_at = fields.Date()
only_posted_moves = fields.Boolean()
hide_account_balance_at_0 = fields.Boolean()
foreign_currency = fields.Boolean()
company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner')
# Flag fields, used for report display
has_second_currency = fields.Boolean()
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_open_items_account',
@ -56,7 +54,11 @@ class OpenItemsReportAccount(models.TransientModel):
# Data fields, used for report display
code = fields.Char()
name = fields.Char()
currency_id = fields.Many2one('res.currency')
final_amount_residual = fields.Float(digits=(16, 2))
final_amount_total_due = fields.Float(digits=(16, 2))
final_amount_residual_currency = fields.Float(digits=(16, 2))
final_amount_total_due_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
partner_ids = fields.One2many(
@ -83,7 +85,11 @@ class OpenItemsReportPartner(models.TransientModel):
# Data fields, used for report display
name = fields.Char()
currency_id = fields.Many2one('res.currency')
final_amount_residual = fields.Float(digits=(16, 2))
final_amount_total_due = fields.Float(digits=(16, 2))
final_amount_residual_currency = fields.Float(digits=(16, 2))
final_amount_total_due_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
move_line_ids = fields.One2many(
@ -182,10 +188,8 @@ class OpenItemsReportCompute(models.TransientModel):
self._clean_partners_and_accounts(
only_delete_account_balance_at_0=True
)
# Compute display flag
self._compute_has_second_currency()
# Refresh cache because all data are computed with SQL requests
self.refresh()
self.invalidate_cache()
def _inject_account_values(self):
"""Inject report values for report_open_items_account."""
@ -197,11 +201,14 @@ WITH
a.id,
a.code,
a.name,
a.user_type_id
a.user_type_id,
c.id as currency_id
FROM
account_account a
INNER JOIN
account_move_line ml ON a.id = ml.account_id AND ml.date <= %s
LEFT JOIN
res_currency c ON a.currency_id = c.id
"""
if self.filter_partner_ids:
query_inject_account += """
@ -230,7 +237,7 @@ WITH
"""
query_inject_account += """
GROUP BY
a.id
a.id, c.id
)
INSERT INTO
report_open_items_account
@ -239,6 +246,7 @@ INSERT INTO
create_uid,
create_date,
account_id,
currency_id,
code,
name
)
@ -247,6 +255,7 @@ SELECT
%s AS create_uid,
NOW() AS create_date,
a.id AS account_id,
a.currency_id,
a.code,
a.name
FROM
@ -621,7 +630,25 @@ ORDER BY
""" Compute cumulative amount for
report_open_items_partner and report_open_items_account.
"""
query_compute_partners_cumul = """
self._compute_partner_cumul()
self._compute_account_cumul()
def _compute_partner_cumul(self):
where_condition_partner_by_account = """
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
)"""
query_computer_partner_residual_cumul = """
UPDATE
report_open_items_partner
SET
@ -634,6 +661,31 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account
params_compute_partners_residual_cumul = (self.id,)
self.env.cr.execute(query_computer_partner_residual_cumul,
params_compute_partners_residual_cumul)
query_compute_partners_due_cumul = """
UPDATE
report_open_items_partner
SET
final_amount_total_due =
(
SELECT
SUM(rml.amount_total_due) AS final_amount_total_due
FROM
report_open_items_move_line rml
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
# Manage currency in partner
where_condition_partner_by_account_cur = """
WHERE
id IN
(
@ -645,13 +697,67 @@ WHERE
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cumul,
params_compute_partners_cumul)
query_compute_accounts_cumul = """
query_compute_partners_cur_id_cumul = """
UPDATE
report_open_items_partner
SET
currency_id =
(
SELECT
MAX(currency_id) as currency_id
FROM
report_open_items_move_line rml
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
params_compute_partners_cur_id_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_id_cumul,
params_compute_partners_cur_id_cumul)
query_compute_partners_cur_residual_cumul = """
UPDATE
report_open_items_partner
SET
final_amount_residual_currency =
(
SELECT
SUM(rml.amount_residual_currency)
AS final_amount_residual_currency
FROM
report_open_items_move_line rml
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
params_compute_partners_cur_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_residual_cumul,
params_compute_partners_cur_residual_cumul)
query_compute_partners_cur_due_cumul = """
UPDATE
report_open_items_partner
SET
final_amount_total_due_currency =
(
SELECT
SUM(rml.amount_total_due_currency)
AS final_amount_total_due_currency
FROM
report_open_items_move_line rml
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
params_compute_partners_cur_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_due_cumul,
params_compute_partners_cur_due_cumul)
def _compute_account_cumul(self):
query_compute_accounts_residual_cumul = """
UPDATE
report_open_items_account
SET
@ -667,9 +773,71 @@ SET
WHERE
report_id = %s
"""
params_compute_accounts_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_cumul,
params_compute_accounts_cumul)
params_compute_accounts_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_residual_cumul,
params_compute_accounts_residual_cumul)
query_compute_accounts_cur_residual_cumul = """
UPDATE
report_open_items_account
SET
final_amount_residual_currency =
(
SELECT
SUM(rp.final_amount_residual_currency)
AS final_amount_residual_currency
FROM
report_open_items_partner rp
WHERE
rp.report_account_id = report_open_items_account.id
)
WHERE
report_id = %s
"""
params_compute_accounts_cur_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_cur_residual_cumul,
params_compute_accounts_cur_residual_cumul)
query_compute_accounts_due_cumul = """
UPDATE
report_open_items_account
SET
final_amount_total_due =
(
SELECT
SUM(rp.final_amount_total_due) AS final_amount_total_due
FROM
report_open_items_partner rp
WHERE
rp.report_account_id = report_open_items_account.id
)
WHERE
report_id = %s
"""
params_compute_accounts_due_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_due_cumul,
params_compute_accounts_due_cumul)
query_compute_accounts_cur_due_cumul = """
UPDATE
report_open_items_account
SET
final_amount_total_due_currency =
(
SELECT
SUM(rp.final_amount_total_due_currency)
AS final_amount_total_due_currency
FROM
report_open_items_partner rp
WHERE
rp.report_account_id = report_open_items_account.id
)
WHERE
report_id = %s
"""
params_compute_accounts_cur_due_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_cur_due_cumul,
params_compute_accounts_cur_due_cumul)
def _clean_partners_and_accounts(self,
only_delete_account_balance_at_0=False):
@ -746,31 +914,3 @@ WHERE
"""
params_clean_accounts = (self.id,)
self.env.cr.execute(query_clean_accounts, params_clean_accounts)
def _compute_has_second_currency(self):
""" Compute "has_second_currency" flag which will used for display."""
query_update_has_second_currency = """
UPDATE
report_open_items
SET
has_second_currency =
(
SELECT
TRUE
FROM
report_open_items_move_line l
INNER JOIN
report_open_items_partner p
ON l.report_partner_id = p.id
INNER JOIN
report_open_items_account a
ON p.report_account_id = a.id
WHERE
a.report_id = %s
AND l.currency_id IS NOT NULL
LIMIT 1
)
WHERE id = %s
"""
params = (self.id,) * 2
self.env.cr.execute(query_update_has_second_currency, params)

35
account_financial_report/report/open_items_xlsx.py

@ -13,7 +13,7 @@ class OpenItemsXslx(models.AbstractModel):
return _('Open Items')
def _get_report_columns(self, report):
return {
res = {
0: {'header': _('Date'), 'field': 'date', 'width': 11},
1: {'header': _('Entry'), 'field': 'entry', 'width': 18},
2: {'header': _('Journal'), 'field': 'journal', 'width': 8},
@ -30,17 +30,27 @@ class OpenItemsXslx(models.AbstractModel):
'field_final_balance': 'final_amount_residual',
'type': 'amount',
'width': 14},
9: {'header': _('Cur.'), 'field': 'currency_id',
'type': 'many2one', 'width': 7},
10: {'header': _('Cur. Original'),
'field': 'amount_total_due_currency',
'type': 'amount',
'width': 14},
11: {'header': _('Cur. Residual'),
'field': 'amount_residual_currency',
'type': 'amount',
'width': 14},
}
if report.foreign_currency:
foreign_currency = {
9: {'header': _('Cur.'), 'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
10: {'header': _('Cur. Original'),
'field': 'amount_total_due_currency',
'field_final_balance':
'final_amount_total_due_currency',
'type': 'amount_currency',
'width': 14},
11: {'header': _('Cur. Residual'),
'field': 'amount_residual_currency',
'field_final_balance':
'final_amount_residual_currency',
'type': 'amount_currency',
'width': 14},
}
res = {**res, **foreign_currency}
return res
def _get_report_filters(self, report):
return [
@ -50,6 +60,8 @@ class OpenItemsXslx(models.AbstractModel):
'All entries')],
[_('Account balance at 0 filter'),
_('Hide') if report.hide_account_balance_at_0 else _('Show')],
[_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')],
]
def _get_col_count_filter_name(self):
@ -99,6 +111,7 @@ class OpenItemsXslx(models.AbstractModel):
if type_object == 'partner':
name = my_object.name
label = _('Partner ending balance')
my_object.currency_id = my_object.report_account_id.currency_id
elif type_object == 'account':
name = my_object.code + ' - ' + my_object.name
label = _('Ending balance')

203
account_financial_report/report/templates/general_ledger.xml

@ -14,7 +14,7 @@
<template id="report_general_ledger_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_cost_center" t-value="o.show_cost_center"/>
<t t-set="has_second_currency" t-value="o.has_second_currency"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/>
<!-- Defines global variables used by internal layout -->
<t t-set="title">General Ledger</t>
<t t-set="company_name" t-value="o.company_id.name"/>
@ -109,35 +109,41 @@
<div class="act_as_thead">
<div class="act_as_row labels">
<!--## date-->
<div class="act_as_cell first_column" style="width: 5.74%;">
<div class="act_as_cell first_column" style="width: 3.51%;">
Date</div>
<!--## move-->
<div class="act_as_cell" style="width: 8.77%">Entry</div>
<div class="act_as_cell" style="width: 8.03%">Entry</div>
<!--## journal-->
<div class="act_as_cell" style="width: 4.51%;">Journal</div>
<div class="act_as_cell" style="width: 4.13%;">Journal</div>
<!--## account code-->
<div class="act_as_cell" style="width: 5.19%;">Account</div>
<div class="act_as_cell" style="width: 4.75%;">Account</div>
<!--## account code-->
<div class="act_as_cell" style="width: 8.89%;">Taxes</div>
<!--## partner-->
<div class="act_as_cell" style="width: 13.11%;">Partner
<div class="act_as_cell" style="width: 12.01%;">Partner
</div>
<!--## ref - label-->
<div class="act_as_cell" style="width: 25%;">Ref -
<div class="act_as_cell" style="width: 22.9%;">Ref -
Label</div>
<t t-if="show_cost_center">
<!--## cost_center-->
<div class="act_as_cell" style="width: 8.77%;">Cost
<div class="act_as_cell" style="width: 8.03%;">Cost
center</div>
</t>
<!--## matching_number-->
<div class="act_as_cell" style="width: 2.63%;">Rec.</div>
<div class="act_as_cell" style="width: 2.41%;">Rec.</div>
<!--## debit-->
<div class="act_as_cell amount" style="width: 6.57%;">Debit</div>
<div class="act_as_cell amount" style="width: 6.02%;">Debit</div>
<!--## credit-->
<div class="act_as_cell amount" style="width: 6.57%;">Credit</div>
<div class="act_as_cell amount" style="width: 6.02%;">Credit</div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 6.57%;">Cumul. Bal.</div>
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">Amount cur.</div>
<div class="act_as_cell amount" style="width: 6.02%;">Cumul. Bal.</div>
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" style="width: 2.08%;">Cur.</div>
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 5.19%;">Amount cur.</div>
</t>
</div>
</div>
@ -151,6 +157,8 @@
<div class="act_as_cell"/>
<!--## account code-->
<div class="act_as_cell"/>
<!--## taxes-->
<div class="act_as_cell"/>
<!--## partner-->
<div class="act_as_cell"/>
<!--## ref - label-->
@ -162,7 +170,7 @@
<!--## matching_number-->
<div class="act_as_cell"/>
<!--## debit-->
<div class="act_as_cell amount">
<div class="act_as_cell amount">
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
@ -171,7 +179,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -185,7 +193,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -201,7 +209,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -215,7 +223,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -230,7 +238,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -243,14 +251,50 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
</t>
</div>
<!--## amount_currency-->
<div class="act_as_cell"/>
<t t-if="foreign_currency">
<t t-if="account.account_id.currency_id.id">
<div class="act_as_cell amount" style="width: 2.08%;">
<span t-field="account.account_id.currency_id.display_name"/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>
</span>
</t>
</div>
</t>
<t t-if="not account.account_id.currency_id.id">
<div class="act_as_cell" style="width: 2.08%;"/>
<div class="act_as_cell" style="width: 5.19%;"/>
</t>
</t>
</div>
<!-- Display each lines -->
@ -301,6 +345,8 @@
<t t-raw="line.account"/></a>
</span>
</div>
<!--## taxes-->
<div class="act_as_cell left"><span t-field="line.taxes_description"/></div>
<!--## partner-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'res.partner'"/>
@ -323,9 +369,9 @@
</span>
</div>
<!--## cost_center-->
<t t-if="show_cost_center">
<t t-if="show_cost_center">
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account_analytic_account'"/>
<t t-set="res_model" t-value="'account.analytic.account'"/>
<span t-if="line.cost_center">
<a t-att-data-active-id="line.move_line_id.analytic_account_id.id"
t-att-data-res-model="res_model"
@ -336,7 +382,7 @@
</t>
<!--## matching_number-->
<div class="act_as_cell">
<t t-set="res_model" t-value="'account_full_reconcile'"/>
<t t-set="res_model" t-value="'account.full.reconcile'"/>
<span t-if="line.matching_number">
<a t-att-data-active-id="line.move_line_id.full_reconcile_id.id"
t-att-data-res-model="res_model"
@ -350,7 +396,7 @@
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
class="o_account_financial_reports_web_action_monetary"
style="color: black;">
<t t-raw="line.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -361,38 +407,47 @@
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
class="o_account_financial_reports_web_action_monetary"
style="color: black;">
<t t-raw="line.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
</div>
<!--## balance cumulated-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'"/>
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
class="o_account_financial_reports_web_action_monetary"
style="color: black;">
<t t-raw="line.cumul_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
</div>
<t t-if="line.currency_id">
<!--## amount_currency-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'"/>
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.amount_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</div>
</t>
<t t-if="not line.currency_id">
<!--## amount_currency-->
<div class="act_as_cell"/>
<t t-if="foreign_currency">
<t t-if="line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.08%;">
<span t-field="line.currency_id.display_name"/>
</div>
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-set="res_model" t-value="'account.move.line'"/>
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.amount_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</div>
</t>
<t t-if="not line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.08%;"/>
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 5.19%;"/>
</t>
</t>
</div>
</t>
@ -406,36 +461,72 @@
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column"
style="width: 33.81%;"><span
style="width: 41.32%;"><span
t-field="account_or_partner_object.code"/> - <span t-field="account_or_partner_object.name"/></div>
<div class="act_as_cell right"
style="width: 28.51%;">Ending balance</div>
style="width: 22.9%;">Ending balance</div>
</t>
<t t-if='type == "partner_type"'>
<div class="act_as_cell first_column" style="width: 33.81%;"/>
<div class="act_as_cell right" style="width: 28.51%;">Partner ending balance</div>
<div class="act_as_cell first_column" style="width: 41.32%;"/>
<div class="act_as_cell right" style="width: 22.9%;">Partner ending balance</div>
</t>
<t t-if="show_cost_center">
<!--## cost_center-->
<div class="act_as_cell" style="width: 8.77%"/>
<div class="act_as_cell" style="width: 8.03%"/>
</t>
<!--## matching_number-->
<div class="act_as_cell" style="width: 2.63%;"/>
<div class="act_as_cell" style="width: 2.41%;"/>
<!--## debit-->
<div class="act_as_cell amount" style="width: 6.57%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span t-field="account_or_partner_object.final_debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</div>
<!--## credit-->
<div class="act_as_cell amount" style="width: 6.57%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span t-field="account_or_partner_object.final_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 6.57%;">
<div class="act_as_cell amount" style="width: 6.02%;">
<span t-field="account_or_partner_object.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</div>
<!--## currency_name + amount_currency-->
<div class="act_as_cell" style="width: 6.57%;"/>
<t t-if="foreign_currency">
<t t-if="account.account_id.currency_id.id">
<div class="act_as_cell amount" style="width: 2.08%;">
<span t-field="account.account_id.currency_id.display_name"/>
</div>
<div class="act_as_cell amount" style="width: 5.19%;">
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.account_id.currency_id}"/></a>
</span>
</t>
<t t-if="type == 'partner_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
style="color: black;">
<t t-raw="account_or_partner_object.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.report_account_id.currency_id}"/></a>
</span>
</t>
</div>
</t>
<t t-if="not account.account_id.currency_id ">
<div class="act_as_cell amount" style="width: 2.08%;"/>
<div class="act_as_cell amount" style="width: 5.19%;"/>
</t>
</t>
</div>
</div>
</template>

463
account_financial_report/report/templates/journal_ledger.xml

@ -0,0 +1,463 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_journal_ledger_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout">
<t t-call="account_financial_report.report_journal_ledger_base"/>
</t>
</t>
</t>
</template>
<template id="report_journal_ledger_base">
<t t-set="title">Journal Ledger</t>
<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_account_name" t-value="o.with_account_name"/>
<div class="page">
<t t-if="o.group_option == 'none'">
<div class="page_break">
<t t-call="account_financial_report.report_journal_all"/>
<br/>
<t t-call="account_financial_report.report_journal_all_taxes"/>
</div>
</t>
<t t-if="o.group_option == 'journal'">
<t t-foreach="o.report_journal_ledger_ids" t-as="journal">
<div class="page_break">
<t t-call="account_financial_report.report_journal_ledger_journal"/>
<br/>
<t t-call="account_financial_report.report_journal_ledger_journal_taxes"/>
<br/>
</div>
</t>
</t>
</div>
</template>
<template id="account_financial_report.report_journal_all">
<div class="act_as_table list_table" style="margin-top: 10px;"/>
<div class="act_as_table data_table" style="width: 100%;">
<t t-call="account_financial_report.report_journal_ledger_journal_table_header"/>
<t t-foreach="o.report_move_ids" t-as="move">
<t t-call="account_financial_report.report_journal_move"/>
</t>
</div>
</template>
<template id="account_financial_report.report_journal_ledger_journal">
<div class="act_as_table list_table" style="margin-top: 10px;"/>
<div class="act_as_caption account_title" style="width: 100%;">
<span t-field="journal.name"/> (<span t-field="journal.currency_id.display_name"/>) - <span t-field="o.date_from"/> to <span t-field="o.date_to"/> - <span t-field="o.move_target"/> Moves
</div>
<div class="act_as_table data_table" style="width: 100%;">
<t t-call="account_financial_report.report_journal_ledger_journal_table_header"/>
<t t-call="account_financial_report.report_journal_ledger_journal_first_line"/>
<t t-foreach="journal.report_move_ids" t-as="move">
<t t-call="account_financial_report.report_journal_move"/>
</t>
</div>
</template>
<template id="account_financial_report.report_journal_ledger_journal_table_header">
<t t-if="not display_account_name">
<t t-set="account_column_style">
width: 8.11%;
</t>
<t t-set="label_column_style">
width: 38.92%;
</t>
</t>
<t t-else="">
<t t-set="account_column_style">
width: 23.78%;
</t>
<t t-set="label_column_style">
width: 23.24%;
</t>
</t>
<div class="act_as_thead">
<div class="act_as_row labels">
<div class="act_as_cell first_column"
name="entry"
style="width: 7.57%;">
Entry
</div>
<div class="act_as_cell"
name="date"
style="width: 5.41%;">
Date
</div>
<div class="act_as_cell"
name="account" t-att-style="account_column_style">
Account
</div>
<div class="act_as_cell"
name="partner"
style="width: 15.14%;">
Partner
</div>
<div class="act_as_cell"
name="label" t-att-style="label_column_style">
Ref - Label
</div>
<div class="act_as_cell"
name="taxes"
style="width: 7.57%;">
Taxes
</div>
<div class="act_as_cell"
name="debit"
style="width: 8.65%;">
Debit
</div>
<div class="act_as_cell"
name="credit"
style="width: 8.65%;">
Credit
</div>
<t t-if="display_currency">
<div class="act_as_cell"
name="currency_name"
style="width: 2.16%;">
Cur.
</div>
<div class="act_as_cell"
name="amount_currency"
style="width: 6.49%;">
Amount Cur.
</div>
</t>
</div>
</div>
</template>
<template id="account_financial_report.report_journal_ledger_journal_first_line">
<div class="act_as_row lines">
<div class="act_as_cell"
name="entry"/>
<div class="act_as_cell"
name="date"/>
<div class="act_as_cell"
name="account"/>
<div class="act_as_cell"
name="partner"/>
<div class="act_as_cell"
name="label"/>
<div class="act_as_cell"
name="taxes"/>
<div class="act_as_cell amount"
name="debit">
<b><span t-field="journal.debit"/></b>
</div>
<div class="act_as_cell amount"
name="credit">
<b><span t-field="journal.credit"/></b>
</div>
<t t-if="display_currency">
<div class="act_as_cell"
name="currency_name">
</div>
<div class="act_as_cell amount"
name="amount_currency">
</div>
</t>
</div>
<div style="width: 100%"/>
</template>
<template id="account_financial_report.report_journal_move">
<t t-set="display_move_info" t-value="True"/>
<t t-set="last_partner" t-eval="None"/>
<t t-set="display_partner" t-eval="True"/>
<t t-foreach="move.report_move_line_ids" t-as="move_line">
<div class="act_as_row lines">
<t t-set="current_partner" t-value="move_line.partner_id"/>
<t t-set="display_partner" t-value="current_partner != last_partner"/>
<t t-call="account_financial_report.report_journal_move_line"/>
<t t-set="last_partner" t-value="current_partner"/>
<t t-set="display_move_info" t-value="False"/>
</div>
</t>
</template>
<template id="account_financial_report.report_journal_move_line">
<div class="act_as_cell left"
name="entry">
<span t-if="display_move_info" t-field="move_line.entry"/>
</div>
<div class="act_as_cell left"
name="date">
<span t-if="display_move_info" t-field="move_line.date"/>
</div>
<div class="act_as_cell left"
name="account">
<span t-field="move_line.account_code"/>
<span t-if="display_account_name">
- <span t-field="move_line.account"/>
</span>
</div>
<div class="act_as_cell left"
name="partner">
<span t-if="display_partner" t-field="move_line.partner"/>
</div>
<div class="act_as_cell left"
name="label">
<span t-field="move_line.label"/>
</div>
<div class="act_as_cell left"
name="taxes">
<span t-field="move_line.taxes_description"/>
</div>
<div class="act_as_cell amount"
name="debit">
<t t-if="move_line.debit">
<span t-field="move_line.debit"/>
</t>
</div>
<div class="act_as_cell amount"
name="credit">
<t t-if="move_line.credit">
<span t-field="move_line.credit"/>
</t>
</div>
<t t-if="display_currency">
<div class="act_as_cell"
name="currency_name">
<t t-if="move_line.currency_name">
<span t-field="move_line.currency_name"/>
</t>
</div>
<div class="act_as_cell amount"
name="amount_currency">
<t t-if="move_line.amount_currency">
<span t-field="move_line.amount_currency"/>
</t>
</div>
</t>
</template>
<template id="account_financial_report.report_journal_ledger_journal_taxes">
<b>Taxes summary</b>
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_thead">
<div class="act_as_row labels">
<div class="act_as_cell first_column"
name="name"
style="width: 30.97%;">
Name
</div>
<div class="act_as_cell"
name="description"
style="width: 13.27%;">
Description
</div>
<div class="act_as_cell"
name="base_amount"
style="width: 27.88%;">
Base Amount
</div>
<div class="act_as_cell"
name="tax_amount"
style="width: 27.88%;">
Tax Amount
</div>
</div>
</div>
</div>
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_row labels">
<div class="act_as_cell first_column"
name="name"
style="width: 30.97%;"/>
<div class="act_as_cell"
name="description"
style="width: 13.27%;"/>
<div class="act_as_cell"
name="base_debit"
style="width: 9.29%;">
Debit
</div>
<div class="act_as_cell"
name="base_credit"
style="width: 9.29%;">
Credit
</div>
<div class="act_as_cell"
name="base_balance"
style="width: 9.29%;">
Balance
</div>
<div class="act_as_cell"
name="tax_debit"
style="width: 9.29%;">
Debit
</div>
<div class="act_as_cell"
name="tax_credit"
style="width: 9.29%;">
Credit
</div>
<div class="act_as_cell"
name="tax_balance"
style="width: 9.29%;">
Balance
</div>
</div>
<t t-foreach="journal.report_tax_line_ids" t-as="tax_line">
<div class="act_as_row lines">
<div class="act_as_cell left"
name="tax_name">
<span t-field="tax_line.tax_name"/>
</div>
<div class="act_as_cell left"
name="tax_code">
<span t-field="tax_line.tax_code"/>
</div>
<div class="act_as_cell amount"
name="base_debit">
<span t-field="tax_line.base_debit"/>
</div>
<div class="act_as_cell amount"
name="base_credit">
<span t-field="tax_line.base_credit"/>
</div>
<div class="act_as_cell amount"
name="base_balance">
<span t-field="tax_line.base_balance"/>
</div>
<div class="act_as_cell amount"
name="tax_debit">
<span t-field="tax_line.tax_debit"/>
</div>
<div class="act_as_cell amount"
name="tax_credit">
<span t-field="tax_line.tax_credit"/>
</div>
<div class="act_as_cell amount"
name="tax_balance">
<span t-field="tax_line.tax_balance"/>
</div>
</div>
</t>
</div>
</template>
<template id="account_financial_report.report_journal_all_taxes">
<b>Taxes summary</b>
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_thead">
<div class="act_as_row labels">
<div class="act_as_cell first_column"
name="name"
style="width: 30.97%;">
Name
</div>
<div class="act_as_cell"
name="description"
style="width: 13.27%;">
Description
</div>
<div class="act_as_cell"
name="base_amount"
style="width: 27.88%;">
Base Amount
</div>
<div class="act_as_cell"
name="tax_amount"
style="width: 27.88%;">
Tax Amount
</div>
</div>
</div>
</div>
<div class="act_as_table data_table" style="width: 100%;">10
<div class="act_as_row labels">
<div class="act_as_cell first_column"
name="name"
style="width: 30.97%;"/>
<div class="act_as_cell"
name="description"
style="width: 13.27%;"/>
<div class="act_as_cell"
name="base_debit"
style="width: 9.29%;">
Debit
</div>
<div class="act_as_cell"
name="base_credit"
style="width: 9.29%;">
Credit
</div>
<div class="act_as_cell"
name="base_balance"
style="width: 9.29%;">
Balance
</div>
<div class="act_as_cell"
name="tax_debit"
style="width: 9.29%;">
Debit
</div>
<div class="act_as_cell"
name="tax_credit"
style="width: 9.29%;">
Credit
</div>
<div class="act_as_cell"
name="tax_balance"
style="width: 9.29%;">
Balance
</div>
</div>
<t t-foreach="o.report_tax_line_ids" t-as="tax_line">
<div class="act_as_row lines">
<div class="act_as_cell left"
name="tax_name">
<span t-field="tax_line.tax_name"/>
</div>
<div class="act_as_cell left"
name="tax_code">
<span t-field="tax_line.tax_code"/>
</div>
<div class="act_as_cell amount"
name="base_debit">
<span t-field="tax_line.base_debit"/>
</div>
<div class="act_as_cell amount"
name="base_credit">
<span t-field="tax_line.base_credit"/>
</div>
<div class="act_as_cell amount"
name="base_balance">
<span t-field="tax_line.base_balance"/>
</div>
<div class="act_as_cell amount"
name="tax_debit">
<span t-field="tax_line.tax_debit"/>
</div>
<div class="act_as_cell amount"
name="tax_credit">
<span t-field="tax_line.tax_credit"/>
</div>
<div class="act_as_cell amount"
name="tax_balance">
<span t-field="tax_line.tax_balance"/>
</div>
</div>
</t>
</div>
</template>
</odoo>

89
account_financial_report/report/templates/open_items.xml

@ -13,7 +13,7 @@
<template id="account_financial_report.report_open_items_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="has_second_currency" t-value="o.has_second_currency"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/>
<!-- Defines global variables used by internal layout -->
@ -93,7 +93,7 @@
<div class="act_as_thead">
<div class="act_as_row labels">
<!--## date-->
<div class="act_as_cell first_column" style="width: 6.76%;">
<div class="act_as_cell first_column" style="width: 4.51%;">
Date</div>
<!--## move-->
<div class="act_as_cell" style="width: 9.76%;">Entry</div>
@ -115,10 +115,14 @@
</div>
<!--## amount_residual-->
<div class="act_as_cell" style="width: 6.57%;">Residual</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">Cur. Original</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">Cur. Residual</div>
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" style="width: 2.25%;">Cur.</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">Cur. Original</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">Cur. Residual</div>
</t>
</div>
</div>
@ -178,21 +182,29 @@
<div class="act_as_cell amount">
<span t-field="line.amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</div>
<t t-if="line.currency_id">
<!--## amount_total_due_currency-->
<div class="act_as_cell amount">
<span t-field="line.amount_total_due_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/>
</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount">
<span t-field="line.amount_residual_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/>
</div>
</t>
<t t-if="not line.currency_id">
<!--## amount_total_due_currency-->
<div class="act_as_cell"/>
<!--## amount_residual_currency-->
<div class="act_as_cell"/>
<t t-if="foreign_currency">
<t t-if="line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount">
<span t-field="line.currency_id.display_name"/>
</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount">
<span t-field="line.amount_total_due_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/>
</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount">
<span t-field="line.amount_residual_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/>
</div>
</t>
<t t-if="not line.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell"/>
<!--## amount_total_due_currency-->
<div class="act_as_cell"/>
<!--## amount_residual_currency-->
<div class="act_as_cell"/>
</t>
</t>
</div>
</t>
@ -205,22 +217,22 @@
<div class="act_as_row labels" style="font-weight: bold;">
<!--## date-->
<t t-if='type == "account_type"'>
<div class="act_as_cell first_column" style="width: 37.37%;">
<div class="act_as_cell first_column" style="width: 36.34%;">
<span t-field="account_or_partner_object.code"/>
-
<span t-field="account_or_partner_object.name"/>
</div>
<div class="act_as_cell right" style="width: 29.47%;">Ending
<div class="act_as_cell right" style="width: 28.66%;">Ending
balance</div>
</t>
<t t-if='type == "partner_type"'>
<div class="act_as_cell first_column"
style="width: 37.37%;"/>
style="width: 36.34%;"/>
<div class="act_as_cell right"
style="width: 29.47%;">Partner ending balance</div>
style="width: 28.66%;">Partner ending balance</div>
</t>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.26%;"/>
<div class="act_as_cell" style="width: 6.47%;"/>
<!--## amount_total_due-->
<div class="act_as_cell amount" style="width: 6.57%;"/>
<!--## amount_currency-->
@ -228,7 +240,30 @@
<span t-field="account_or_partner_object.final_amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</div>
<!--## amount_total_due_currency + amount_residual_currency -->
<div class="act_as_cell" style="width: 13.14%;"/>
<t t-if="foreign_currency">
<t t-if="account_or_partner_object.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell amount" style="width: 2.25%;">
<span t-field="account_or_partner_object.currency_id.display_name"/>
</div>
<!--## amount_total_due_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<span t-field="account_or_partner_object.final_amount_total_due_currency" t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.currency_id}"/>
</div>
<!--## amount_residual_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<span t-field="account_or_partner_object.final_amount_residual_currency" t-options="{'widget': 'monetary', 'display_currency': account_or_partner_object.currency_id}"/>
</div>
</t>
<t t-if="not account_or_partner_object.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell"/>
<!--## amount_total_due_currency-->
<div class="act_as_cell"/>
<!--## amount_residual_currency-->
<div class="act_as_cell"/>
</t>
</t>
</div>
</div>
</template>

179
account_financial_report/report/templates/trial_balance.xml

@ -13,7 +13,8 @@
<template id="account_financial_report.report_trial_balance_base">
<!-- Saved flag fields into variables, used to define columns display -->
<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"/>
<!-- Defines global variables used by internal layout -->
<t t-set="title">Trial Balance</t>
<t t-set="company_name" t-value="o.company_id.name"/>
@ -144,6 +145,13 @@
<div class="act_as_cell" style="width: 9.64%;">Credit</div>
<!--## Ending balance-->
<div class="act_as_cell" style="width: 9.64%;">Ending balance</div>
<t t-if="foreign_currency">
<!--## currency_name-->
<div class="act_as_cell" style="width: 4.43%;">Cur.</div>
<!--## amount_currency-->
<div class="act_as_cell" style="width: 8.86%;">Initial blance cur.</div>
<div class="act_as_cell" style="width: 8.86%;">Ending blance cur.</div>
</t>
</div>
</div>
</template>
@ -179,6 +187,7 @@
<!--## Account/Partner-->
<div class="act_as_cell left">
<t t-if="type == 'account_type'">
<t t-set="account_or_partner_line" t-value="line"/>
<t t-if="line.account_id">
<t t-set="res_model" t-value="'account.account'"/>
<span>
@ -199,8 +208,9 @@
<t t-att-style="style" t-raw="line.name"/></a>
</span>
</t>
</t>
</t>
<t t-if="type == 'partner_type'">
<t t-set="account_or_partner_line" t-value="line.report_account_id"/>
<t t-set="res_model" t-value="'res.partner'"/>
<span>
<a t-att-data-active-id="line.partner_id.id"
@ -214,14 +224,14 @@
<!--## Initial balance-->
<div class="act_as_cell amount">
<t t-if="type == 'account_type'">
<t t-if="line.account_id">
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -233,7 +243,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -247,7 +257,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -265,7 +275,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -279,7 +289,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -295,7 +305,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -313,7 +323,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -327,7 +337,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -343,7 +353,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -358,7 +368,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -369,7 +379,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -382,12 +392,104 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
</t>
</div>
<t t-if="foreign_currency">
<t t-if="account_or_partner_line.currency_id">
<!--## currency_name-->
<div class="act_as_cell" style="width: 4.43%;">
<span t-field="account_or_partner_line.currency_id.display_name"/>
</div>
<!--## Initial balance cur.-->
<div class="act_as_cell amount">
<t t-if="type == 'account_type'">
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</t>
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</t>
</t>
<t t-if="type == 'partner_type'">
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.report_account_id.currency_id}"/></a>
</span>
</t>
</div>
<!--## Ending balance cur.-->
<div class="act_as_cell amount">
<t t-if="type == 'account_type'">
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</t>
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.currency_id}"/></a>
</span>
</t>
</t>
<t t-if="type == 'partner_type'">
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="line.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': line.report_account_id.currency_id}"/></a>
</span>
</t>
</div>
</t>
<t t-if="not account_or_partner_line.currency_id.id">
<!--## balance_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell"/>
<div class="act_as_cell"/>
</t>
</t>
</div>
</template>
@ -414,7 +516,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="account.initial_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -429,7 +531,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="account.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -444,7 +546,7 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="account.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
@ -456,11 +558,50 @@
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style" >
<t t-att-style="style" t-raw="account.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
</span>
</div>
<t t-if="foreign_currency">
<t t-if="account.currency_id.id">
<!--## currency_name-->
<div class="act_as_cell" style="width: 4.43%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id)]"/>
<span t-field="account.currency_id.display_name"/>
</div>
<!--## balance_currency-->
<div class="act_as_cell amount" style="width: 8.86%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&lt;', o.date_from)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style">
<t t-att-style="style" t-raw="account.initial_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>
</span>
</div>
<div class="act_as_cell amount" style="width: 8.86%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id)]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_monetary_multi"
t-att-style="style" >
<t t-att-style="style" t-raw="account.final_balance_foreign_currency" t-options="{'widget': 'monetary', 'display_currency': account.account_id.currency_id}"/></a>
</span>
</div>
</t>
<t t-if="not account.currency_id.id">
<div class="act_as_cell" style="width: 4.43%;"/>
<div class="act_as_cell" style="width: 8.86%;"/>
<div class="act_as_cell" style="width: 8.86%;"/>
</t>
</t>
</div>
</div>
</template>

4
account_financial_report/report/templates/vat_report.xml

@ -4,7 +4,7 @@
<template id="account_financial_report.report_vat_report_qweb">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="account_financial_report.internal_layout" t-lang="user.lang">
<t t-call="account_financial_report.internal_layout">
<t t-call="account_financial_report.report_vat_report_base"/>
</t>
</t>
@ -17,8 +17,6 @@
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'"/>
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_vat_report_filters"/>
<div class="page_break"/>

61
account_financial_report/report/trial_balance.py

@ -24,6 +24,7 @@ class TrialBalanceReport(models.TransientModel):
fy_start_date = fields.Date()
only_posted_moves = fields.Boolean()
hide_account_balance_at_0 = fields.Boolean()
foreign_currency = fields.Boolean()
company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner')
@ -85,10 +86,13 @@ class TrialBalanceReportAccount(models.TransientModel):
code = fields.Char()
name = fields.Char()
currency_id = fields.Many2one('res.currency')
initial_balance = fields.Float(digits=(16, 2))
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
debit = fields.Float(digits=(16, 2))
credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
partner_ids = fields.One2many(
@ -115,10 +119,13 @@ class TrialBalanceReportPartner(models.TransientModel):
# Data fields, used for report display
name = fields.Char()
currency_id = fields.Many2one('res.currency')
initial_balance = fields.Float(digits=(16, 2))
initial_balance_foreign_currency = fields.Float(digits=(16, 2))
debit = fields.Float(digits=(16, 2))
credit = fields.Float(digits=(16, 2))
final_balance = fields.Float(digits=(16, 2))
final_balance_foreign_currency = fields.Float(digits=(16, 2))
@api.model
def _generate_order_by(self, order_spec, query):
@ -176,6 +183,7 @@ class TrialBalanceReportCompute(models.TransientModel):
'date_to': self.date_to,
'only_posted_moves': self.only_posted_moves,
'hide_account_balance_at_0': self.hide_account_balance_at_0,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
@ -236,7 +244,10 @@ INSERT INTO
initial_balance,
debit,
credit,
final_balance
final_balance,
currency_id,
initial_balance_foreign_currency,
final_balance_foreign_currency
)
SELECT
%s AS report_id,
@ -249,7 +260,12 @@ SELECT
coalesce(rag.initial_balance, 0) AS initial_balance,
coalesce(rag.final_debit - rag.initial_debit, 0) AS debit,
coalesce(rag.final_credit - rag.initial_credit, 0) AS credit,
coalesce(rag.final_balance, 0) AS final_balance
coalesce(rag.final_balance, 0) AS final_balance,
rag.currency_id AS currency_id,
coalesce(rag.initial_balance_foreign_currency, 0)
AS initial_balance_foreign_currency,
coalesce(rag.final_balance_foreign_currency, 0)
AS final_balance_foreign_currency
FROM
account_account acc
LEFT OUTER JOIN report_general_ledger_account AS rag
@ -280,9 +296,11 @@ INSERT INTO
partner_id,
name,
initial_balance,
initial_balance_foreign_currency,
debit,
credit,
final_balance
final_balance,
final_balance_foreign_currency
)
SELECT
ra.id AS report_account_id,
@ -291,9 +309,11 @@ SELECT
rpg.partner_id,
rpg.name,
rpg.initial_balance AS initial_balance,
rpg.initial_balance_foreign_currency AS initial_balance_foreign_currency,
rpg.final_debit - rpg.initial_debit AS debit,
rpg.final_credit - rpg.initial_credit AS credit,
rpg.final_balance AS final_balance
rpg.final_balance AS final_balance,
rpg.final_balance_foreign_currency AS final_balance_foreign_currency
FROM
report_general_ledger_partner rpg
INNER JOIN
@ -351,30 +371,40 @@ FROM
query_update_account_group = """
WITH computed AS (WITH RECURSIVE cte AS (
SELECT account_group_id, code, account_group_id AS parent_id,
initial_balance, debit, credit, final_balance
initial_balance, initial_balance_foreign_currency, debit, credit,
final_balance, final_balance_foreign_currency
FROM report_trial_balance_account
WHERE report_id = %s
GROUP BY report_trial_balance_account.id
UNION ALL
SELECT c.account_group_id, c.code, p.account_group_id,
p.initial_balance, p.debit, p.credit, p.final_balance
p.initial_balance, p.initial_balance_foreign_currency, p.debit, p.credit,
p.final_balance, p.final_balance_foreign_currency
FROM cte c
JOIN report_trial_balance_account p USING (parent_id)
WHERE p.report_id = %s
)
SELECT account_group_id, code,
sum(initial_balance) AS initial_balance, sum(debit) AS debit,
sum(credit) AS credit, sum(final_balance) AS final_balance
sum(initial_balance) AS initial_balance,
sum(initial_balance_foreign_currency) AS initial_balance_foreign_currency,
sum(debit) AS debit,
sum(credit) AS credit,
sum(final_balance) AS final_balance,
sum(final_balance_foreign_currency) AS final_balance_foreign_currency
FROM cte
GROUP BY cte.account_group_id, cte.code
ORDER BY account_group_id
)
UPDATE report_trial_balance_account
SET initial_balance = computed.initial_balance,
initial_balance_foreign_currency =
computed.initial_balance_foreign_currency,
debit = computed.debit,
credit = computed.credit,
final_balance = computed.final_balance
final_balance = computed.final_balance,
final_balance_foreign_currency =
computed.final_balance_foreign_currency
FROM computed
WHERE report_trial_balance_account.account_group_id = computed.account_group_id
AND report_trial_balance_account.report_id = %s
@ -431,9 +461,13 @@ WITH RECURSIVE accgroup AS
(SELECT
accgroup.id,
coalesce(sum(ra.initial_balance),0) as initial_balance,
coalesce(sum(ra.initial_balance_foreign_currency),0)
as initial_balance_foreign_currency,
coalesce(sum(ra.debit),0) as debit,
coalesce(sum(ra.credit),0) as credit,
coalesce(sum(ra.final_balance),0) as final_balance
coalesce(sum(ra.final_balance),0) as final_balance,
coalesce(sum(ra.final_balance_foreign_currency),0)
as final_balance_foreign_currency
FROM
account_group accgroup
LEFT OUTER JOIN account_account AS acc
@ -445,9 +479,14 @@ WITH RECURSIVE accgroup AS
)
UPDATE report_trial_balance_account
SET initial_balance = accgroup.initial_balance,
initial_balance_foreign_currency =
accgroup.initial_balance_foreign_currency,
debit = accgroup.debit,
credit = accgroup.credit,
final_balance = accgroup.final_balance
final_balance = accgroup.final_balance,
final_balance_foreign_currency =
accgroup.final_balance_foreign_currency
FROM accgroup
WHERE report_trial_balance_account.account_group_id = accgroup.id
"""

67
account_financial_report/report/trial_balance_xlsx.py

@ -15,7 +15,7 @@ class TrialBalanceXslx(models.AbstractModel):
def _get_report_columns(self, report):
if not report.show_partner_details:
return {
res = {
0: {'header': _('Code'), 'field': 'code', 'width': 10},
1: {'header': _('Account'), 'field': 'name', 'width': 60},
2: {'header': _('Initial balance'),
@ -35,8 +35,25 @@ class TrialBalanceXslx(models.AbstractModel):
'type': 'amount',
'width': 14},
}
if report.foreign_currency:
foreign_currency = {
6: {'header': _('Cur.'),
'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
7: {'header': _('Initial balance'),
'field': 'initial_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
8: {'header': _('Ending balance'),
'field': 'final_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
}
res = {**res, **foreign_currency}
return res
else:
return {
res = {
0: {'header': _('Partner'), 'field': 'name', 'width': 70},
1: {'header': _('Initial balance'),
'field': 'initial_balance',
@ -55,6 +72,23 @@ class TrialBalanceXslx(models.AbstractModel):
'type': 'amount',
'width': 14},
}
if report.foreign_currency:
foreign_currency = {
5: {'header': _('Cur.'),
'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
6: {'header': _('Initial balance'),
'field': 'initial_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
7: {'header': _('Ending balance'),
'field': 'final_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
}
res = {**res, **foreign_currency}
return res
def _get_report_filters(self, report):
return [
@ -65,6 +99,8 @@ class TrialBalanceXslx(models.AbstractModel):
'All entries')],
[_('Account balance at 0 filter'),
_('Hide') if report.hide_account_balance_at_0 else _('Show')],
[_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')],
]
def _get_col_count_filter_name(self):
@ -83,7 +119,7 @@ class TrialBalanceXslx(models.AbstractModel):
for account in report.account_ids:
if not report.show_partner_details:
# Display account lines
self.write_line(account)
self.write_line(account, 'account')
else:
# Write account title
@ -95,7 +131,7 @@ class TrialBalanceXslx(models.AbstractModel):
# For each partner
for partner in account.partner_ids:
# Display partner lines
self.write_line(partner)
self.write_line(partner, 'partner')
# Display account footer line
self.write_account_footer(account,
@ -104,8 +140,19 @@ class TrialBalanceXslx(models.AbstractModel):
# Line break
self.row_pos += 2
def write_line(self, line_object, type_object):
"""Write a line on current line using all defined columns field name.
Columns are defined with `_get_report_columns` method.
"""
if type_object == 'partner':
line_object.currency_id = line_object.report_account_id.currency_id
elif type_object == 'account':
line_object.currency_id = line_object.currency_id
super(TrialBalanceXslx, self).write_line(line_object)
def write_account_footer(self, account, name_value):
"""Specific function to write account footer for Trial Balance"""
format_amt = self._get_currency_amt_header_format(account)
for col_pos, column in self.columns.items():
if column['field'] == 'name':
value = name_value
@ -118,4 +165,16 @@ class TrialBalanceXslx(models.AbstractModel):
elif cell_type == 'amount':
self.sheet.write_number(self.row_pos, col_pos, float(value),
self.format_header_amount)
elif cell_type == 'many2one':
self.sheet.write_string(
self.row_pos, col_pos, value.name or '',
self.format_header_right)
elif cell_type == 'amount_currency' and account.currency_id:
self.sheet.write_number(
self.row_pos, col_pos, float(value),
format_amt)
else:
self.sheet.write_string(
self.row_pos, col_pos, '',
self.format_header_right)
self.row_pos += 1

31
account_financial_report/reports.xml

@ -10,7 +10,7 @@
string="General Ledger"
report_type="qweb-pdf"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger"
file="account_financial_report.report_general_ledger_qweb"
/>
<report
id="action_report_general_ledger_html"
@ -18,7 +18,25 @@
string="General Ledger"
report_type="qweb-html"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger"
file="account_financial_report.report_general_ledger_html"
/>
<!-- Journal Ledger -->
<report
id="action_report_journal_ledger_qweb"
model="report_journal_ledger"
string="Journal Ledger"
report_type="qweb-pdf"
name="account_financial_report.report_journal_ledger_qweb"
file="account_financial_report.report_journal_ledger_qweb"
/>
<report
id="action_report_journal_ledger_html"
model="report_journal_ledger"
string="Journal Ledger"
report_type="qweb-html"
name="account_financial_report.report_journal_ledger_qweb"
file="account_financial_report.report_journal_ledger_html"
/>
<!-- Trial Balance -->
@ -144,6 +162,15 @@
<field name="report_file">report_general_ledger</field>
</record>
<record id="action_report_journal_ledger_xlsx" model="ir.actions.report">
<field name="name">Journal Ledger XLSX</field>
<field name="model">report_journal_ledger</field>
<field name="type">ir.actions.report</field>
<field name="report_name">a_f_r.report_journal_ledger_xlsx</field>
<field name="report_type">xlsx</field>
<field name="report_file">report_journal_ledger</field>
</record>
<record id="action_report_trial_balance_xlsx" model="ir.actions.report">
<field name="name">Trial Balance XLSX</field>
<field name="model">report_trial_balance</field>

3
account_financial_report/static/src/css/report.css

@ -28,7 +28,7 @@ body, table, td, span, div {
.list_table, .data_table, .totals_table, .list_table .act_as_row {
border-left:0px;
border-right:0px;
text-align:left;
text-align:center;
font-size:10px;
padding-right:3px;
padding-left:3px;
@ -75,7 +75,6 @@ body, table, td, span, div {
text-align:right;
}
.list_table .act_as_cell{
padding-left: 5px;
/* border-right:1px solid lightGrey; uncomment to active column lines */
}
.list_table .act_as_cell.first_column {

13
account_financial_report/static/src/js/account_financial_report_backend.js

@ -62,14 +62,13 @@ var report_backend = Widget.extend(ControlPanelMixin, {
},
// Updates the control panel and render the elements that have yet to be rendered
update_cp: function() {
if (!this.$buttons) {
if (this.$buttons) {
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
cp_content: {$buttons: this.$buttons},
};
return this.update_control_panel(status);
}
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
cp_content: {$buttons: this.$buttons},
};
return this.update_control_panel(status);
},
do_show: function() {
this._super();

27
account_financial_report/static/src/js/account_financial_report_widgets.js

@ -2,7 +2,6 @@ odoo.define('account_financial_report.account_financial_report_widget', function
(require) {
'use strict';
var core = require('web.core');
var Widget = require('web.Widget');
@ -10,8 +9,10 @@ var accountFinancialReportWidget = Widget.extend({
events: {
'click .o_account_financial_reports_web_action': 'boundLink',
'click .o_account_financial_reports_web_action_multi': 'boundLinkmulti',
'click .o_account_financial_reports_web_action_monetary': 'boundLinkMonetary',
'click .o_account_financial_reports_web_action_monetary_multi': 'boundLinkMonetarymulti',
},
init: function(parent) {
init: function() {
this._super.apply(this, arguments);
},
start: function() {
@ -39,6 +40,28 @@ var accountFinancialReportWidget = Widget.extend({
target: 'current'
});
},
boundLinkMonetary: function(e) {
var res_model = $(e.target.parentElement).data('res-model');
var res_id = $(e.target.parentElement).data('active-id');
return this.do_action({
type: 'ir.actions.act_window',
res_model: res_model,
res_id: res_id,
views: [[false, 'form']],
target: 'current'
});
},
boundLinkMonetarymulti: function(e) {
var res_model = $(e.target.parentElement).data('res-model');
var domain = $(e.target.parentElement).data('domain');
return this.do_action({
type: 'ir.actions.act_window',
res_model: res_model,
domain: domain,
views: [[false, "list"], [false, "form"]],
target: 'current'
});
},
});
return accountFinancialReportWidget;

2
account_financial_report/tests/__init__.py

@ -4,8 +4,10 @@
from . import abstract_test
from . import abstract_test_tax_report
from . import abstract_test_foreign_currency
from . import test_aged_partner_balance
from . import test_general_ledger
from . import test_journal_ledger
from . import test_open_items
from . import test_trial_balance
from . import test_vat_report

2
account_financial_report/tests/abstract_test.py

@ -12,7 +12,7 @@ _logger = logging.getLogger(__name__)
class AbstractTest(common.TransactionCase):
"""Common technical tests for all reports."""
at_install = False
at_install = True
post_install = True
accounts = {}

78
account_financial_report/tests/abstract_test_foreign_currency.py

@ -0,0 +1,78 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from . import abstract_test
_logger = logging.getLogger(__name__)
class AbstractTestForeignCurrency(abstract_test.AbstractTest):
"""Common technical tests for all reports."""
def _chart_template_create(self):
super(AbstractTestForeignCurrency, self)._chart_template_create()
# Account for foreign payments
self.account_type_other = self.env['account.account.type'].create(
{'name': 'foreign expenses',
'type': 'other',
})
act = self.env['account.account.template'].create({
'code': '0012',
'name': 'Foreign Expenses',
'user_type_id': self.account_type_other.id,
'chart_template_id': self.chart.id,
'currency_id': self.env.ref('base.EUR').id,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'foreign expenses',
})
return True
def _add_chart_of_accounts(self):
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts()
self.foreign_expense = self.env['account.account'].search(
[('currency_id', '=', self.env.ref('base.EUR').id)], limit=1)
self.foreign_currency_id = self.foreign_expense.currency_id
return True
def _journals_create(self):
super(AbstractTestForeignCurrency, self)._journals_create()
self.journal_foreign_purchases = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for purchase',
'type': 'purchase',
'code': 'TFORPUR',
'default_debit_account_id': self.foreign_expense.id,
'default_credit_account_id': self.foreign_expense.id,
'currency_id': self.foreign_currency_id.id,
})
return True
def _invoice_create(self):
super(AbstractTestForeignCurrency, self)._invoice_create()
# vendor bill foreign currency
foreign_vendor_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
'currency_id': self.foreign_currency_id.id,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
'currency_id': self.foreign_currency_id.id,
})]
self.foreign_invoice_in = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'in_invoice',
'invoice_line_ids': foreign_vendor_invoice_lines,
'account_id': self.partner.property_account_payable_id.id,
'journal_id': self.journal_foreign_purchases.id,
})
self.foreign_invoice_in.action_invoice_open()
return True

5
account_financial_report/tests/test_general_ledger.py

@ -5,10 +5,10 @@
import time
from odoo.tests import common
from . import abstract_test
from . import abstract_test_foreign_currency as a_t_f_c
class TestGeneralLedger(abstract_test.AbstractTest):
class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
@ -35,6 +35,7 @@ class TestGeneralLedger(abstract_test.AbstractTest):
'date_to': time.strftime('%Y-12-31'),
'company_id': self.company.id,
'fy_start_date': time.strftime('%Y-01-01'),
'foreign_currency': True,
}
def _getAdditionalFiltersToBeTested(self):

366
account_financial_report/tests/test_journal_ledger.py

@ -0,0 +1,366 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import time
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo.fields import Date
from odoo.tests.common import TransactionCase
from . import abstract_test_foreign_currency as a_t_f_c
class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env['report_journal_ledger']
def _getQwebReportName(self):
return 'account_financial_report.report_journal_ledger_qweb'
def _getXlsxReportName(self):
return 'a_f_r.report_journal_ledger_xlsx'
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_journal_ledger_xlsx'
def _getReportTitle(self):
return 'Odoo'
def _getBaseFilters(self):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
}
def _getAdditionalFiltersToBeTested(self):
return [
{'move_target': "All",
'sort_option': "Date",
'group_option': "Journal",
'with_account_name': True,
'foreign_currency': True},
]
def test_02_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = 'qweb-html'
report_action = self.report.print_report(report_type)
self.assertDictContainsSubset(
{
'type': 'ir.actions.report',
'report_name': self.qweb_report_name,
'report_type': 'qweb-html',
},
report_action
)
# Check if report template is correct
report = self.env['ir.actions.report'].search(
[('report_name', '=', self.qweb_report_name),
('report_type', '=', report_type)], limit=1)
self.assertEqual(report.report_type, 'qweb-html')
rep = report.render(self.report.ids, {})
self.assertTrue(self.report_title.encode('utf8') in rep[0])
self.assertTrue(
self.report.journal_ids[0].name.encode('utf8') in rep[0]
)
def test_04_compute_data(self):
return True
class TestJournalReport(TransactionCase):
def setUp(self):
super(TestJournalReport, self).setUp()
self.AccountObj = self.env['account.account']
self.InvoiceObj = self.env['account.invoice']
self.JournalObj = self.env['account.journal']
self.JournalReportObj = self.env['journal.ledger.report.wizard']
self.MoveObj = self.env['account.move']
self.ReportJournalLedger = self.env['report_journal_ledger']
self.TaxObj = self.env['account.tax']
self.company = self.env.ref('base.main_company')
today = datetime.today()
last_year = today - relativedelta(years=1)
self.previous_fy_date_start = Date.to_string(
last_year.replace(month=1, day=1))
self.previous_fy_date_end = Date.to_string(
last_year.replace(month=12, day=31))
self.fy_date_start = Date.to_string(
today.replace(month=1, day=1))
self.fy_date_end = Date.to_string(
today.replace(month=12, day=31))
self.receivable_account = self.AccountObj.search([
('user_type_id.name', '=', 'Receivable')
], limit=1)
self.income_account = self.AccountObj.search([
('user_type_id.name', '=', 'Income')
], limit=1)
self.payable_account = self.AccountObj.search([
('user_type_id.name', '=', 'Payable')
], limit=1)
self.journal_sale = self.JournalObj.create({
'name': "Test journal sale",
'code': "TST-JRNL-S",
'type': 'sale',
'company_id': self.company.id,
})
self.journal_purchase = self.JournalObj.create({
'name': "Test journal purchase",
'code': "TST-JRNL-P",
'type': 'sale',
'company_id': self.company.id,
})
self.tax_15_s = self.TaxObj.create({
'sequence': 30,
'name': 'Tax 15.0% (Percentage of Price)',
'amount': 15.0,
'amount_type': 'percent',
'include_base_amount': False,
'type_tax_use': 'sale',
})
self.tax_20_s = self.TaxObj.create({
'sequence': 30,
'name': 'Tax 20.0% (Percentage of Price)',
'amount': 20.0,
'amount_type': 'percent',
'include_base_amount': False,
'type_tax_use': 'sale',
})
self.tax_15_p = self.TaxObj.create({
'sequence': 30,
'name': 'Tax 15.0% (Percentage of Price)',
'amount': 15.0,
'amount_type': 'percent',
'include_base_amount': False,
'type_tax_use': 'purchase',
})
self.tax_20_p = self.TaxObj.create({
'sequence': 30,
'name': 'Tax 20.0% (Percentage of Price)',
'amount': 20.0,
'amount_type': 'percent',
'include_base_amount': False,
'type_tax_use': 'purchase',
})
self.partner_2 = self.env.ref('base.res_partner_2')
def _add_move(
self, date, journal,
receivable_debit, receivable_credit, income_debit, income_credit):
move_name = 'move name'
move_vals = {
'journal_id': journal.id,
'date': date,
'line_ids': [
(0, 0, {
'name': move_name,
'debit': receivable_debit,
'credit': receivable_credit,
'account_id': self.receivable_account.id
}),
(0, 0, {
'name': move_name,
'debit': income_debit,
'credit': income_credit,
'account_id': self.income_account.id
}),
]
}
return self.MoveObj.create(move_vals)
def check_report_journal_debit_credit(
self, report, expected_debit, expected_credit):
self.assertEqual(
expected_debit,
sum([journal.debit for journal in
report.report_journal_ledger_ids])
)
self.assertEqual(
expected_credit,
sum([journal.credit for journal in
report.report_journal_ledger_ids])
)
def check_report_journal_debit_credit_taxes(
self, report,
expected_base_debit, expected_base_credit,
expected_tax_debit, expected_tax_credit):
self.assertEqual(
expected_base_debit,
sum([
journal.base_debit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_base_credit,
sum([
journal.base_credit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_tax_debit,
sum([
journal.tax_debit
for journal in report.report_journal_ledger_tax_line_ids
])
)
self.assertEqual(
expected_tax_credit,
sum([
journal.tax_credit
for journal in report.report_journal_ledger_tax_line_ids
])
)
def test_01_test_total(self):
today_date = Date.today()
last_year_date = Date.to_string(
datetime.today() - relativedelta(years=1))
move1 = self._add_move(
today_date, self.journal_sale,
0, 100, 100, 0)
move2 = self._add_move(
last_year_date, self.journal_sale,
0, 100, 100, 0)
report = self.ReportJournalLedger.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move3 = self._add_move(
today_date, self.journal_sale,
0, 100, 100, 0)
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
report.move_target = 'posted'
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 0, 0)
move1.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move2.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 100, 100)
move3.post()
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 200, 200)
report.date_from = self.previous_fy_date_start
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 300, 300)
def test_02_test_taxes_out_invoice(self):
invoice_values = {
'journal_id': self.journal_sale.id,
'partner_id': self.partner_2.id,
'type': 'out_invoice',
'invoice_line_ids': [
(0, 0, {
'quantity': 1.0,
'price_unit': 100,
'account_id': self.receivable_account.id,
'name': "Test",
'invoice_line_tax_ids': [(6, 0, [self.tax_15_s.id])],
}),
(0, 0, {
'quantity': 1.0,
'price_unit': 100,
'account_id': self.receivable_account.id,
'name': "Test",
'invoice_line_tax_ids': [(6, 0, [
self.tax_15_s.id, self.tax_20_s.id
])],
})
]
}
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 0, 300, 0, 50)
def test_03_test_taxes_in_invoice(self):
invoice_values = {
'journal_id': self.journal_sale.id,
'partner_id': self.partner_2.id,
'type': 'in_invoice',
'invoice_line_ids': [
(0, 0, {
'quantity': 1.0,
'price_unit': 100,
'account_id': self.payable_account.id,
'name': "Test",
'invoice_line_tax_ids': [(6, 0, [self.tax_15_p.id])],
}),
(0, 0, {
'quantity': 1.0,
'price_unit': 100,
'account_id': self.payable_account.id,
'name': "Test",
'invoice_line_tax_ids': [(6, 0, [
self.tax_15_p.id, self.tax_20_p.id
])],
})
]
}
invoice = self.InvoiceObj.create(invoice_values)
invoice.action_invoice_open()
report = self.ReportJournalLedger.create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
})
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 250, 250)
self.check_report_journal_debit_credit_taxes(report, 300, 0, 50, 0)

5
account_financial_report/tests/test_open_items.py

@ -3,10 +3,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from . import abstract_test
from . import abstract_test_foreign_currency as a_t_f_c
class TestOpenItems(abstract_test.AbstractTest):
class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for Open Items Report.
"""
@ -30,6 +30,7 @@ class TestOpenItems(abstract_test.AbstractTest):
return {
'date_at': time.strftime('%Y-12-31'),
'company_id': self.company.id,
'foreign_currency': True,
}
def _getAdditionalFiltersToBeTested(self):

6
account_financial_report/tests/test_trial_balance.py

@ -5,10 +5,10 @@
import time
from odoo.tests import common
from . import abstract_test
from . import abstract_test_foreign_currency as a_t_f_c
class TestTrialBalance(abstract_test.AbstractTest):
class TestTrialBalance(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for Trial Balance Report.
"""
@ -34,6 +34,8 @@ class TestTrialBalance(abstract_test.AbstractTest):
'date_to': time.strftime('%Y-12-31'),
'company_id': self.company.id,
'fy_start_date': time.strftime('%Y-01-01'),
'foreign_currency': True,
'show_partner_details': True,
}
def _getAdditionalFiltersToBeTested(self):

2
account_financial_report/tests/test_vat_report.py

@ -31,7 +31,7 @@ class TestVAT(abstract_test_tax_report.AbstractTest):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'company_id': self.env.user.company_id.id
'company_id': self.env.user.company_id.id,
}
def _getAdditionalFiltersToBeTested(self):

9
account_financial_report/view/report_journal_ledger.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_journal_ledger">
<div class="o_account_financial_reports_page">
<t t-call="account_financial_report.report_buttons"/>
<t t-call="account_financial_report.report_journal_ledger_base"/>
</div>
</template>
</odoo>

6
account_financial_report/view/report_template.xml

@ -24,6 +24,12 @@
<field name="context" eval="{'active_model': 'report_general_ledger'}" />
</record>
<record id="action_report_journal_ledger" model="ir.actions.client">
<field name="name">Journal</field>
<field name="tag">account_financial_report_backend</field>
<field name="context" eval="{'active_model': 'report_journal_ledger'}" />
</record>
<record id="action_report_open_items" model="ir.actions.client">
<field name="name">Open Items</field>
<field name="tag">account_financial_report_backend</field>

1
account_financial_report/wizard/__init__.py

@ -1,5 +1,6 @@
from . import aged_partner_balance_wizard
from . import general_ledger_wizard
from . import journal_ledger_wizard
from . import open_items_wizard
from . import trial_balance_wizard
from . import vat_report_wizard

2
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -9,7 +9,7 @@ from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
class AgedPartnerBalance(models.TransientModel):
class AgedPartnerBalanceWizard(models.TransientModel):
"""Aged partner balance report wizard."""
_name = 'aged.partner.balance.wizard'

7
account_financial_report/wizard/general_ledger_wizard.py

@ -63,6 +63,12 @@ class GeneralLedgerReportWizard(models.TransientModel):
readonly=True,
string='Not only one unaffected earnings account'
)
foreign_currency = fields.Boolean(
string='Show foreign currency',
help='Display foreign currency for move lines, unless '
'account currency is not setup through chart of accounts '
'will display initial and final balance in that currency.'
)
@api.depends('date_from')
def _compute_fy_start_date(self):
@ -147,6 +153,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
'hide_account_balance_at_0': self.hide_account_balance_at_0,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],

1
account_financial_report/wizard/general_ledger_wizard_view.xml

@ -22,6 +22,7 @@
<field name="target_move" widget="radio"/>
<field name="centralize"/>
<field name="hide_account_balance_at_0"/>
<field name="foreign_currency"/>
</group>
</group>
<label for="cost_center_ids" groups="analytic.group_analytic_accounting"/>

142
account_financial_report/wizard/journal_ledger_wizard.py

@ -0,0 +1,142 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
class JournalLedgerReportWizard(models.TransientModel):
"""Journal Ledger report wizard."""
_name = 'journal.ledger.report.wizard'
_description = "Journal Ledger Report Wizard"
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
string='Company',
required=True,
ondelete='cascade',
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range',
domain="['|', "
"('company_id', '=', False),"
"('company_id', '=', company_id)]",
)
date_from = fields.Date(
string="Start date",
required=True
)
date_to = fields.Date(
string="End date",
required=True
)
journal_ids = fields.Many2many(
comodel_name='account.journal',
string="Journals",
domain="[('company_id', '=', company_id)]",
required=True,
)
move_target = fields.Selection(
selection='_get_move_targets',
default='all',
required=True,
)
foreign_currency = fields.Boolean()
sort_option = fields.Selection(
selection='_get_sort_options',
string="Sort entries by",
default='move_name',
required=True,
)
group_option = fields.Selection(
selection='_get_group_options',
string="Group entries by",
default='journal',
required=True,
)
with_account_name = fields.Boolean(
default=False,
)
@api.model
def _get_move_targets(self):
return [
('all', _("All")),
('posted', _("Posted")),
('draft', _("Not Posted"))
]
@api.model
def _get_sort_options(self):
return [
('move_name', _("Entry number")),
('date', _("Date")),
]
@api.model
def _get_group_options(self):
return [
('journal', _("Journal")),
('none', _("No group")),
]
@api.onchange('date_range_id')
def onchange_date_range_id(self):
self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_journal_ledger')
vals = action.read()[0]
context1 = vals.get('context', {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_journal_ledger']
report = model.create(self._prepare_report_journal_ledger())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
vals['context'] = context1
return vals
@api.multi
def button_export_pdf(self):
self.ensure_one()
report_type = 'qweb-pdf'
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
return self._export(report_type)
@api.multi
def _prepare_report_journal_ledger(self):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'move_target': self.move_target,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'journal_ids': [(6, 0, self.journal_ids.ids)],
'sort_option': self.sort_option,
'group_option': self.group_option,
'with_account_name': self.with_account_name,
}
def _export(self, report_type):
"""Default export is PDF."""
self.ensure_one()
model = self.env['report_journal_ledger']
report = model.create(self._prepare_report_journal_ledger())
report.compute_data_for_report()
return report.print_report(report_type)

66
account_financial_report/wizard/journal_ledger_wizard_view.xml

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="journal_ledger_wizard" model="ir.ui.view">
<field name="name">Journal Ledger</field>
<field name="model">journal.ledger.report.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<separator string="Periods"/>
<group>
<group>
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group/>
</group>
<separator string="Options"/>
<group name="options">
<group>
<field name="move_target" widget="radio" options="{'horizontal': true}"/>
<field name="sort_option"/>
<field name="group_option"/>
<field name="foreign_currency"/>
<field name="with_account_name"/>
</group>
<group/>
</group>
<separator string="Journals"/>
<group>
<field name="journal_ids" widget="many2many_tags"/>
</group>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
or
<button name="button_export_pdf" string="Export PDF" type="object"/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<act_window id="action_journal_ledger_wizard"
name="Journal Ledger"
res_model="journal.ledger.report.wizard"
view_type="form"
view_mode="form"
view_id="journal_ledger_wizard"
target="new" />
</odoo>

7
account_financial_report/wizard/open_items_wizard.py

@ -45,6 +45,12 @@ class OpenItemsReportWizard(models.TransientModel):
comodel_name='res.partner',
string='Filter partners',
)
foreign_currency = fields.Boolean(
string='Show foreign currency',
help='Display foreign currency for move lines, unless '
'account currency is not setup through chart of accounts '
'will display initial and final balance in that currency.'
)
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
def onchange_type_accounts_only(self):
@ -97,6 +103,7 @@ class OpenItemsReportWizard(models.TransientModel):
'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted',
'hide_account_balance_at_0': self.hide_account_balance_at_0,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],

1
account_financial_report/wizard/open_items_wizard_view.xml

@ -17,6 +17,7 @@
<group name="other_filters">
<field name="target_move" widget="radio"/>
<field name="hide_account_balance_at_0"/>
<field name="foreign_currency"/>
</group>
</group>
<label for="partner_ids"/>

8
account_financial_report/wizard/trial_balance_wizard.py

@ -60,6 +60,13 @@ class TrialBalanceReportWizard(models.TransientModel):
string='Not only one unaffected earnings account'
)
foreign_currency = fields.Boolean(
string='Show foreign currency',
help='Display foreign currency for move lines, unless '
'account currency is not setup through chart of accounts '
'will display initial and final balance in that currency.'
)
@api.depends('date_from')
def _compute_fy_start_date(self):
for wiz in self.filtered('date_from'):
@ -146,6 +153,7 @@ class TrialBalanceReportWizard(models.TransientModel):
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
'hide_account_balance_at_0': self.hide_account_balance_at_0,
'foreign_currency': self.foreign_currency,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],

1
account_financial_report/wizard/trial_balance_wizard_view.xml

@ -23,6 +23,7 @@
<field name="hide_account_balance_at_0"/>
<field name="show_partner_details"/>
<field name="hierarchy_on" widget="radio" attrs="{'invisible':[('show_partner_details','=',True)]}"/>
<field name="foreign_currency"/>
</group>
</group>
<label for="partner_ids" attrs="{'invisible':[('show_partner_details','!=',True)]}"/>

Loading…
Cancel
Save