Browse Source

[IMP] account_financial_report: black, isort, prettier

pull/744/head
Tom Blauwendraat 4 years ago
parent
commit
d3cc0209de
  1. 1
      account_financial_report/__init__.py
  2. 80
      account_financial_report/__manifest__.py
  3. 24
      account_financial_report/menuitems.xml
  4. 11
      account_financial_report/models/account.py
  5. 41
      account_financial_report/models/account_group.py
  6. 15
      account_financial_report/models/account_move_line.py
  7. 10
      account_financial_report/report/abstract_report.py
  8. 270
      account_financial_report/report/abstract_report_xlsx.py
  9. 125
      account_financial_report/report/aged_partner_balance.py
  10. 346
      account_financial_report/report/aged_partner_balance_xlsx.py
  11. 485
      account_financial_report/report/general_ledger.py
  12. 158
      account_financial_report/report/general_ledger_xlsx.py
  13. 299
      account_financial_report/report/journal_ledger.py
  14. 202
      account_financial_report/report/journal_ledger_xlsx.py
  15. 217
      account_financial_report/report/open_items.py
  16. 117
      account_financial_report/report/open_items_xlsx.py
  17. 526
      account_financial_report/report/templates/aged_partner_balance.xml
  18. 622
      account_financial_report/report/templates/general_ledger.xml
  19. 474
      account_financial_report/report/templates/journal_ledger.xml
  20. 24
      account_financial_report/report/templates/layouts.xml
  21. 180
      account_financial_report/report/templates/open_items.xml
  22. 944
      account_financial_report/report/templates/trial_balance.xml
  23. 179
      account_financial_report/report/templates/vat_report.xml
  24. 245
      account_financial_report/report/trial_balance.py
  25. 257
      account_financial_report/report/trial_balance_xlsx.py
  26. 132
      account_financial_report/report/vat_report.py
  27. 26
      account_financial_report/report/vat_report_xlsx.py
  28. 202
      account_financial_report/reports.xml
  29. 74
      account_financial_report/static/src/css/report.css
  30. 77
      account_financial_report/static/src/js/account_financial_report_backend.js
  31. 96
      account_financial_report/static/src/js/account_financial_report_widgets.js
  32. 1
      account_financial_report/tests/__init__.py
  33. 475
      account_financial_report/tests/abstract_test.py
  34. 110
      account_financial_report/tests/abstract_test_foreign_currency.py
  35. 62
      account_financial_report/tests/abstract_test_tax_report.py
  36. 22
      account_financial_report/tests/test_aged_partner_balance.py
  37. 574
      account_financial_report/tests/test_general_ledger.py
  38. 500
      account_financial_report/tests/test_journal_ledger.py
  39. 44
      account_financial_report/tests/test_open_items.py
  40. 911
      account_financial_report/tests/test_trial_balance.py
  41. 494
      account_financial_report/tests/test_vat_report.py
  42. 6
      account_financial_report/view/account_view.xml
  43. 6
      account_financial_report/view/report_aged_partner_balance.xml
  44. 6
      account_financial_report/view/report_general_ledger.xml
  45. 6
      account_financial_report/view/report_journal_ledger.xml
  46. 6
      account_financial_report/view/report_open_items.xml
  47. 49
      account_financial_report/view/report_template.xml
  48. 8
      account_financial_report/view/report_trial_balance.xml
  49. 6
      account_financial_report/view/report_vat_report.xml
  50. 29
      account_financial_report/wizard/abstract_wizard.py
  51. 92
      account_financial_report/wizard/aged_partner_balance_wizard.py
  52. 82
      account_financial_report/wizard/aged_partner_balance_wizard_view.xml
  53. 265
      account_financial_report/wizard/general_ledger_wizard.py
  54. 198
      account_financial_report/wizard/general_ledger_wizard_view.xml
  55. 122
      account_financial_report/wizard/journal_ledger_wizard.py
  56. 82
      account_financial_report/wizard/journal_ledger_wizard_view.xml
  57. 117
      account_financial_report/wizard/open_items_wizard.py
  58. 105
      account_financial_report/wizard/open_items_wizard_view.xml
  59. 236
      account_financial_report/wizard/trial_balance_wizard.py
  60. 164
      account_financial_report/wizard/trial_balance_wizard_view.xml
  61. 98
      account_financial_report/wizard/vat_report_wizard.py
  62. 75
      account_financial_report/wizard/vat_report_wizard_view.xml
  63. 1
      setup/account_financial_report/odoo/addons/account_financial_report
  64. 6
      setup/account_financial_report/setup.py

1
account_financial_report/__init__.py

@ -1,4 +1,3 @@
# Author: Damien Crier
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

80
account_financial_report/__manifest__.py

@ -3,48 +3,44 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Financial Reports',
'version': '12.0.1.4.1',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'
'initOS GmbH,'
'redCOR AG,'
'Eficent,'
'Odoo Community Association (OCA)',
"name": "Account Financial Reports",
"version": "12.0.1.4.1",
"category": "Reporting",
"summary": "OCA Financial Reports",
"author": "Camptocamp SA,"
"initOS GmbH,"
"redCOR AG,"
"Eficent,"
"Odoo Community Association (OCA)",
"website": "https://odoo-community.org/",
'depends': [
'account',
'date_range',
'report_xlsx',
"depends": ["account", "date_range", "report_xlsx",],
"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",
"menuitems.xml",
"reports.xml",
"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",
"view/report_vat_report.xml",
],
'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',
'menuitems.xml',
'reports.xml',
'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',
'view/report_vat_report.xml',
],
'installable': True,
'application': True,
'auto_install': False,
'license': 'AGPL-3',
"installable": True,
"application": True,
"auto_install": False,
"license": "AGPL-3",
}

24
account_financial_report/menuitems.xml

@ -1,53 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<menuitem
parent="account.menu_finance_reports"
id="menu_oca_reports"
name="OCA accounting reports"
groups="account.group_account_manager,account.group_account_user"
/>
/>
<menuitem
parent="menu_oca_reports"
action="action_general_ledger_wizard"
id="menu_general_ledger_wizard"
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"
id="menu_trial_balance_wizard"
sequence="20"
/>
/>
<menuitem
parent="menu_oca_reports"
action="action_open_items_wizard"
id="menu_open_items_wizard"
sequence="30"
/>
/>
<menuitem
parent="menu_oca_reports"
action="action_aged_partner_balance_wizard"
id="menu_aged_partner_balance_wizard"
sequence="40"
/>
/>
<menuitem
parent="menu_oca_reports"
action="action_vat_report_wizard"
id="menu_vat_report_wizard"
sequence="50"
/>
/>
</odoo>

11
account_financial_report/models/account.py

@ -1,13 +1,14 @@
# © 2011 Guewen Baconnier (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
from odoo import models, fields
from odoo import fields, models
class AccountAccount(models.Model):
_inherit = 'account.account'
_inherit = "account.account"
centralized = fields.Boolean(
'Centralized',
"Centralized",
help="If flagged, no details will be displayed in "
"the General Ledger report (the webkit one only), "
"only centralized amounts per period.")
"the General Ledger report (the webkit one only), "
"only centralized amounts per period.",
)

41
account_financial_report/models/account_group.py

@ -5,27 +5,24 @@ from odoo import api, fields, models
class AccountGroup(models.Model):
_inherit = 'account.group'
_inherit = "account.group"
group_child_ids = fields.One2many(
comodel_name='account.group',
inverse_name='parent_id',
string='Child Groups')
level = fields.Integer(
string='Level',
compute='_compute_level',
store=True)
comodel_name="account.group", inverse_name="parent_id", string="Child Groups"
)
level = fields.Integer(string="Level", compute="_compute_level", store=True)
account_ids = fields.One2many(
comodel_name='account.account',
inverse_name='group_id',
string="Accounts")
comodel_name="account.account", inverse_name="group_id", string="Accounts"
)
compute_account_ids = fields.Many2many(
'account.account',
compute='_compute_group_accounts',
string="Compute accounts", store=True)
"account.account",
compute="_compute_group_accounts",
string="Compute accounts",
store=True,
)
@api.multi
@api.depends('parent_id', 'parent_id.level')
@api.depends("parent_id", "parent_id.level")
def _compute_level(self):
for group in self:
if not group.parent_id:
@ -34,13 +31,17 @@ class AccountGroup(models.Model):
group.level = group.parent_id.level + 1
@api.multi
@api.depends('code_prefix', 'account_ids', 'account_ids.code',
'group_child_ids', 'group_child_ids.account_ids.code')
@api.depends(
"code_prefix",
"account_ids",
"account_ids.code",
"group_child_ids",
"group_child_ids.account_ids.code",
)
def _compute_group_accounts(self):
account_obj = self.env['account.account']
account_obj = self.env["account.account"]
accounts = account_obj.search([])
for group in self:
prefix = group.code_prefix if group.code_prefix else group.name
gr_acc = accounts.filtered(
lambda a: a.code.startswith(prefix)).ids
gr_acc = accounts.filtered(lambda a: a.code.startswith(prefix)).ids
group.compute_account_ids = [(6, 0, gr_acc)]

15
account_financial_report/models/account_move_line.py

@ -4,7 +4,7 @@ from odoo import api, models
class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
_inherit = "account.move.line"
@api.model_cr
def init(self):
@ -21,10 +21,13 @@ class AccountMoveLine(models.Model):
By adding the following index, performances are strongly increased.
:return:
"""
self._cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = '
'%s',
('account_move_line_account_id_partner_id_index',))
self._cr.execute(
"SELECT indexname FROM pg_indexes WHERE indexname = " "%s",
("account_move_line_account_id_partner_id_index",),
)
if not self._cr.fetchone():
self._cr.execute("""
self._cr.execute(
"""
CREATE INDEX account_move_line_account_id_partner_id_index
ON account_move_line (account_id, partner_id)""")
ON account_move_line (account_id, partner_id)"""
)

10
account_financial_report/report/abstract_report.py

@ -1,17 +1,19 @@
# Copyright 2018 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from psycopg2.extensions import AsIs
from odoo import models
class AbstractReport(models.AbstractModel):
_name = 'account_financial_report_abstract'
_description = 'Abstract Report'
_name = "account_financial_report_abstract"
_description = "Abstract Report"
def _transient_clean_rows_older_than(self, seconds):
assert self._transient, \
assert self._transient, (
"Model %s is not transient, it cannot be vacuumed!" % self._name
)
# Never delete rows used in last 5 minutes
seconds = max(seconds, 300)
query = (

270
account_financial_report/report/abstract_report_xlsx.py

@ -1,16 +1,15 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
import datetime
from odoo import models
from odoo.tools import format_date
class AbstractReportXslx(models.AbstractModel):
_name = 'report.account_financial_report.abstract_report_xlsx'
_inherit = 'report.report_xlsx.abstract'
_name = "report.account_financial_report.abstract_report_xlsx"
_inherit = "report.report_xlsx.abstract"
def __init__(self, pool, cr):
# main sheet which will contains report
@ -35,7 +34,7 @@ class AbstractReportXslx(models.AbstractModel):
self.format_percent_bold_italic = None
def get_workbook_options(self):
return {'constant_memory': True}
return {"constant_memory": True}
def generate_xlsx_report(self, workbook, data, objects):
report = objects
@ -76,58 +75,57 @@ class AbstractReportXslx(models.AbstractModel):
* format_amount
* format_percent_bold_italic
"""
self.format_bold = workbook.add_format({'bold': True})
self.format_right = workbook.add_format({'align': 'right'})
self.format_left = workbook.add_format({'align': 'left'})
self.format_bold = workbook.add_format({"bold": True})
self.format_right = workbook.add_format({"align": "right"})
self.format_left = workbook.add_format({"align": "left"})
self.format_right_bold_italic = workbook.add_format(
{'align': 'right', 'bold': True, 'italic': True}
{"align": "right", "bold": True, "italic": True}
)
self.format_header_left = workbook.add_format(
{'bold': True,
'border': True,
'bg_color': '#FFFFCC'})
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
)
self.format_header_center = workbook.add_format(
{'bold': True,
'align': 'center',
'border': True,
'bg_color': '#FFFFCC'})
{"bold": True, "align": "center", "border": True, "bg_color": "#FFFFCC"}
)
self.format_header_right = workbook.add_format(
{'bold': True,
'align': 'right',
'border': True,
'bg_color': '#FFFFCC'})
{"bold": True, "align": "right", "border": True, "bg_color": "#FFFFCC"}
)
self.format_header_amount = workbook.add_format(
{'bold': True,
'border': True,
'bg_color': '#FFFFCC'})
currency_id = self.env['res.company']._get_user_currency()
{"bold": True, "border": True, "bg_color": "#FFFFCC"}
)
currency_id = self.env["res.company"]._get_user_currency()
self.format_header_amount.set_num_format(
'#,##0.'+'0'*currency_id.decimal_places)
"#,##0." + "0" * currency_id.decimal_places
)
self.format_amount = workbook.add_format()
self.format_amount.set_num_format(
'#,##0.'+'0'*currency_id.decimal_places)
self.format_amount_bold = workbook.add_format({'bold': True})
self.format_amount.set_num_format("#,##0." + "0" * currency_id.decimal_places)
self.format_amount_bold = workbook.add_format({"bold": True})
self.format_amount_bold.set_num_format(
'#,##0.' + '0' * currency_id.decimal_places)
"#,##0." + "0" * currency_id.decimal_places
)
self.format_percent_bold_italic = workbook.add_format(
{'bold': True, 'italic': True}
{"bold": True, "italic": True}
)
self.format_percent_bold_italic.set_num_format('#,##0.00%')
self.format_percent_bold_italic.set_num_format("#,##0.00%")
def _set_column_width(self):
"""Set width for all defined columns.
Columns are defined with `_get_report_columns` method.
"""
for position, column in self.columns.items():
self.sheet.set_column(position, position, column['width'])
self.sheet.set_column(position, position, column["width"])
def _write_report_title(self, title):
"""Write report title on current line using all defined columns width.
Columns are defined with `_get_report_columns` method.
"""
self.sheet.merge_range(
self.row_pos, 0, self.row_pos, len(self.columns) - 1,
title, self.format_bold
self.row_pos,
0,
self.row_pos,
len(self.columns) - 1,
title,
self.format_bold,
)
self.row_pos += 3
@ -138,8 +136,12 @@ class AbstractReportXslx(models.AbstractModel):
if footer:
self.row_pos += 1
self.sheet.merge_range(
self.row_pos, 0, self.row_pos, len(self.columns) - 1,
footer, self.format_left
self.row_pos,
0,
self.row_pos,
len(self.columns) - 1,
footer,
self.format_left,
)
self.row_pos += 1
@ -156,13 +158,20 @@ class AbstractReportXslx(models.AbstractModel):
col_value = col_name + col_count_filter_name + 1
for title, value in filters:
self.sheet.merge_range(
self.row_pos, col_name,
self.row_pos, col_name + col_count_filter_name - 1,
title, self.format_header_left)
self.row_pos,
col_name,
self.row_pos,
col_name + col_count_filter_name - 1,
title,
self.format_header_left,
)
self.sheet.merge_range(
self.row_pos, col_value,
self.row_pos, col_value + col_count_filter_value - 1,
value)
self.row_pos,
col_value,
self.row_pos,
col_value + col_count_filter_value - 1,
value,
)
self.row_pos += 1
self.row_pos += 2
@ -171,8 +180,12 @@ class AbstractReportXslx(models.AbstractModel):
Columns are defined with `_get_report_columns` method.
"""
self.sheet.merge_range(
self.row_pos, 0, self.row_pos, len(self.columns) - 1,
title, self.format_bold
self.row_pos,
0,
self.row_pos,
len(self.columns) - 1,
title,
self.format_bold,
)
self.row_pos += 1
@ -181,8 +194,9 @@ class AbstractReportXslx(models.AbstractModel):
Columns are defined with `_get_report_columns` method.
"""
for col_pos, column in self.columns.items():
self.sheet.write(self.row_pos, col_pos, column['header'],
self.format_header_center)
self.sheet.write(
self.row_pos, col_pos, column["header"], self.format_header_center
)
self.row_pos += 1
def write_line(self, line_object):
@ -190,30 +204,36 @@ class AbstractReportXslx(models.AbstractModel):
Columns are defined with `_get_report_columns` method.
"""
for col_pos, column in self.columns.items():
value = getattr(line_object, column['field'])
value = getattr(line_object, column["field"])
if isinstance(value, datetime.date):
value = format_date(self.env, value)
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
cell_type = column.get("type", "string")
if cell_type == "many2one":
self.sheet.write_string(
self.row_pos, col_pos, value.name or '', self.format_right)
elif cell_type == 'string':
if hasattr(line_object, 'account_group_id') and \
line_object.account_group_id:
self.sheet.write_string(self.row_pos, col_pos, value or '',
self.format_bold)
self.row_pos, col_pos, value.name or "", self.format_right
)
elif cell_type == "string":
if (
hasattr(line_object, "account_group_id")
and line_object.account_group_id
):
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_bold
)
else:
self.sheet.write_string(self.row_pos, col_pos, value or '')
elif cell_type == 'amount':
if hasattr(line_object, 'account_group_id') and \
line_object.account_group_id:
self.sheet.write_string(self.row_pos, col_pos, value or "")
elif cell_type == "amount":
if (
hasattr(line_object, "account_group_id")
and line_object.account_group_id
):
cell_format = self.format_amount_bold
else:
cell_format = self.format_amount
self.sheet.write_number(
self.row_pos, col_pos, float(value), cell_format
)
elif cell_type == 'amount_currency':
elif cell_type == "amount_currency":
if line_object.currency_id:
format_amt = self._get_currency_amt_format(line_object)
self.sheet.write_number(
@ -230,32 +250,28 @@ class AbstractReportXslx(models.AbstractModel):
col_pos_label = self._get_col_pos_initial_balance_label()
self.sheet.write(self.row_pos, col_pos_label, label, self.format_right)
for col_pos, column in self.columns.items():
if column.get('field_initial_balance'):
value = getattr(my_object, column['field_initial_balance'])
cell_type = column.get('type', 'string')
if cell_type == 'string':
self.sheet.write_string(self.row_pos, col_pos, value or '')
elif cell_type == 'amount':
if column.get("field_initial_balance"):
value = getattr(my_object, column["field_initial_balance"])
cell_type = column.get("type", "string")
if 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':
elif cell_type == "amount_currency":
if my_object.currency_id:
format_amt = self._get_currency_amt_format(
my_object)
format_amt = self._get_currency_amt_format(my_object)
self.sheet.write_number(
self.row_pos, col_pos,
float(value), format_amt
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':
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, col_pos, value.name or "", self.format_right
)
self.row_pos += 1
@ -266,85 +282,85 @@ class AbstractReportXslx(models.AbstractModel):
Columns are defined with `_get_report_columns` method.
"""
for i in range(0, len(self.columns)):
self.sheet.write(self.row_pos, i, '', self.format_header_right)
self.sheet.write(self.row_pos, i, "", self.format_header_right)
row_count_name = self._get_col_count_final_balance_name()
col_pos_label = self._get_col_pos_final_balance_label()
self.sheet.merge_range(
self.row_pos, 0, self.row_pos, row_count_name - 1, name,
self.format_header_left
self.row_pos,
0,
self.row_pos,
row_count_name - 1,
name,
self.format_header_left,
)
self.sheet.write(self.row_pos, col_pos_label, label,
self.format_header_right)
self.sheet.write(self.row_pos, col_pos_label, label, self.format_header_right)
for col_pos, column in self.columns.items():
if column.get('field_final_balance'):
value = getattr(my_object, column['field_final_balance'])
cell_type = column.get('type', 'string')
if cell_type == 'string':
self.sheet.write_string(self.row_pos, col_pos, value or '',
self.format_header_right)
elif cell_type == 'amount':
if column.get("field_final_balance"):
value = getattr(my_object, column["field_final_balance"])
cell_type = column.get("type", "string")
if cell_type == "string":
self.sheet.write_string(
self.row_pos, col_pos, value or "", self.format_header_right
)
elif cell_type == "amount":
self.sheet.write_number(
self.row_pos, col_pos, float(value),
self.format_header_amount
self.row_pos, col_pos, float(value), self.format_header_amount
)
elif cell_type == 'amount_currency':
elif cell_type == "amount_currency":
if my_object.currency_id:
format_amt = self._get_currency_amt_header_format(
my_object)
format_amt = self._get_currency_amt_header_format(my_object)
self.sheet.write_number(
self.row_pos, col_pos, float(value),
format_amt
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':
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,
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. """
if hasattr(line_object, 'account_group_id') and \
line_object.account_group_id:
format_amt = getattr(self, 'format_amount_bold')
field_prefix = 'format_amount_bold'
if hasattr(line_object, "account_group_id") and line_object.account_group_id:
format_amt = getattr(self, "format_amount_bold")
field_prefix = "format_amount_bold"
else:
format_amt = getattr(self, 'format_amount')
field_prefix = 'format_amount'
format_amt = getattr(self, "format_amount")
field_prefix = "format_amount"
if line_object.currency_id:
field_name = \
'%s_%s' % (field_prefix, line_object.currency_id.name)
field_name = "{}_{}".format(field_prefix, 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)
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')
format_amt = getattr(self, "format_header_amount")
if line_object.currency_id:
field_name = \
'format_header_amount_%s' % line_object.currency_id.name
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)
{"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
@ -356,8 +372,10 @@ class AbstractReportXslx(models.AbstractModel):
def _get_report_complete_name(self, report, prefix):
if report.company_id:
suffix = ' - %s - %s' % (
report.company_id.name, report.company_id.currency_id.name)
suffix = " - {} - {}".format(
report.company_id.name,
report.company_id.currency_id.name,
)
return prefix + suffix
return prefix

125
account_financial_report/report/aged_partner_balance.py

@ -1,7 +1,7 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo import api, fields, models
class AgedPartnerBalanceReport(models.TransientModel):
@ -17,43 +17,37 @@ class AgedPartnerBalanceReport(models.TransientModel):
If "show_move_line_details" is selected
"""
_name = 'report_aged_partner_balance'
_inherit = 'account_financial_report_abstract'
_name = "report_aged_partner_balance"
_inherit = "account_financial_report_abstract"
# Filters fields, used for data computation
date_at = fields.Date()
only_posted_moves = 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')
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")
show_move_line_details = fields.Boolean()
# Open Items Report Data fields, used as base for compute the data reports
open_items_id = fields.Many2one(comodel_name='report_open_items')
open_items_id = fields.Many2one(comodel_name="report_open_items")
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_aged_partner_balance_account',
inverse_name='report_id'
comodel_name="report_aged_partner_balance_account", inverse_name="report_id"
)
class AgedPartnerBalanceReportAccount(models.TransientModel):
_name = 'report_aged_partner_balance_account'
_inherit = 'account_financial_report_abstract'
_order = 'code ASC'
_name = "report_aged_partner_balance_account"
_inherit = "account_financial_report_abstract"
_order = "code ASC"
report_id = fields.Many2one(
comodel_name='report_aged_partner_balance',
ondelete='cascade',
index=True
comodel_name="report_aged_partner_balance", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
account_id = fields.Many2one(
'account.account',
index=True
)
account_id = fields.Many2one("account.account", index=True)
# Data fields, used for report display
code = fields.Char()
@ -76,38 +70,35 @@ class AgedPartnerBalanceReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_aged_partner_balance_partner',
inverse_name='report_account_id'
comodel_name="report_aged_partner_balance_partner",
inverse_name="report_account_id",
)
class AgedPartnerBalanceReportPartner(models.TransientModel):
_name = 'report_aged_partner_balance_partner'
_inherit = 'account_financial_report_abstract'
_name = "report_aged_partner_balance_partner"
_inherit = "account_financial_report_abstract"
report_account_id = fields.Many2one(
comodel_name='report_aged_partner_balance_account',
ondelete='cascade',
index=True
comodel_name="report_aged_partner_balance_account",
ondelete="cascade",
index=True,
)
# Data fields, used to keep link with real object
partner_id = fields.Many2one(
'res.partner',
index=True
)
partner_id = fields.Many2one("res.partner", index=True)
# Data fields, used for report display
name = fields.Char()
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_aged_partner_balance_move_line',
inverse_name='report_partner_id'
comodel_name="report_aged_partner_balance_move_line",
inverse_name="report_partner_id",
)
line_ids = fields.One2many(
comodel_name='report_aged_partner_balance_line',
inverse_name='report_partner_id'
comodel_name="report_aged_partner_balance_line",
inverse_name="report_partner_id",
)
@api.model
@ -126,13 +117,13 @@ ORDER BY
class AgedPartnerBalanceReportLine(models.TransientModel):
_name = 'report_aged_partner_balance_line'
_inherit = 'account_financial_report_abstract'
_name = "report_aged_partner_balance_line"
_inherit = "account_financial_report_abstract"
report_partner_id = fields.Many2one(
comodel_name='report_aged_partner_balance_partner',
ondelete='cascade',
index=True
comodel_name="report_aged_partner_balance_partner",
ondelete="cascade",
index=True,
)
# Data fields, used for report display
@ -147,17 +138,17 @@ class AgedPartnerBalanceReportLine(models.TransientModel):
class AgedPartnerBalanceReportMoveLine(models.TransientModel):
_name = 'report_aged_partner_balance_move_line'
_inherit = 'account_financial_report_abstract'
_name = "report_aged_partner_balance_move_line"
_inherit = "account_financial_report_abstract"
report_partner_id = fields.Many2one(
comodel_name='report_aged_partner_balance_partner',
ondelete='cascade',
index=True
comodel_name="report_aged_partner_balance_partner",
ondelete="cascade",
index=True,
)
# Data fields, used to keep link with real object
move_line_id = fields.Many2one('account.move.line')
move_line_id = fields.Many2one("account.move.line")
# Data fields, used for report display
date = fields.Date()
@ -182,31 +173,31 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_aged_partner_balance'
_inherit = "report_aged_partner_balance"
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_aged_partner_balance_xlsx'
if report_type == "xlsx":
report_name = "a_f_r.report_aged_partner_balance_xlsx"
else:
report_name = 'account_financial_report.' \
'report_aged_partner_balance_qweb'
report = self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1)
report_name = "account_financial_report." "report_aged_partner_balance_qweb"
report = self.env["ir.actions.report"].search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
return report.report_action(self, config=False)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
report = self.browse(context.get("active_id"))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_aged_partner_balance').render(
rcontext)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_aged_partner_balance"
).render(rcontext)
return result
@api.model
@ -216,11 +207,11 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
def _prepare_report_open_items(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.only_posted_moves,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.filter_account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
"date_at": self.date_at,
"only_posted_moves": self.only_posted_moves,
"company_id": self.company_id.id,
"filter_account_ids": [(6, 0, self.filter_account_ids.ids)],
"filter_partner_ids": [(6, 0, self.filter_partner_ids.ids)],
}
@api.multi
@ -229,7 +220,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
# Compute Open Items Report Data.
# The data of Aged Partner Balance Report
# are based on Open Items Report data.
model = self.env['report_open_items']
model = self.env["report_open_items"]
self.open_items_id = model.create(self._prepare_report_open_items())
self.open_items_id.compute_data_for_report()
@ -550,8 +541,7 @@ AND ra.report_id = %s
self.open_items_id.id,
self.id,
)
self.env.cr.execute(query_inject_move_line,
query_inject_move_line_params)
self.env.cr.execute(query_inject_move_line, query_inject_move_line_params)
def _compute_accounts_cumul(self):
""" Compute cumulative amount for
@ -629,5 +619,4 @@ WHERE
id = c.report_account_id
"""
params_compute_accounts_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_cumul,
params_compute_accounts_cumul)
self.env.cr.execute(query_compute_accounts_cumul, params_compute_accounts_cumul)

346
account_financial_report/report/aged_partner_balance_xlsx.py

@ -1,4 +1,3 @@
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@ -7,123 +6,154 @@ from odoo import _, models
class AgedPartnerBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_aged_partner_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
_name = "report.a_f_r.report_aged_partner_balance_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('Aged Partner Balance')
report_name = _("Aged Partner Balance")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
if not report.show_move_line_details:
return {
0: {'header': _('Partner'), 'field': 'partner', 'width': 70},
1: {'header': _('Residual'),
'field': 'amount_residual',
'field_footer_total': 'cumul_amount_residual',
'type': 'amount',
'width': 14},
2: {'header': _('Current'),
'field': 'current',
'field_footer_total': 'cumul_current',
'field_footer_percent': 'percent_current',
'type': 'amount',
'width': 14},
3: {'header': _(u'Age ≤ 30 d.'),
'field': 'age_30_days',
'field_footer_total': 'cumul_age_30_days',
'field_footer_percent': 'percent_age_30_days',
'type': 'amount',
'width': 14},
4: {'header': _(u'Age ≤ 60 d.'),
'field': 'age_60_days',
'field_footer_total': 'cumul_age_60_days',
'field_footer_percent': 'percent_age_60_days',
'type': 'amount',
'width': 14},
5: {'header': _(u'Age ≤ 90 d.'),
'field': 'age_90_days',
'field_footer_total': 'cumul_age_90_days',
'field_footer_percent': 'percent_age_90_days',
'type': 'amount',
'width': 14},
6: {'header': _(u'Age ≤ 120 d.'),
'field': 'age_120_days',
'field_footer_total': 'cumul_age_120_days',
'field_footer_percent': 'percent_age_120_days',
'type': 'amount',
'width': 14},
7: {'header': _('Older'),
'field': 'older',
'field_footer_total': 'cumul_older',
'field_footer_percent': 'percent_older',
'type': 'amount',
'width': 14},
0: {"header": _("Partner"), "field": "partner", "width": 70},
1: {
"header": _("Residual"),
"field": "amount_residual",
"field_footer_total": "cumul_amount_residual",
"type": "amount",
"width": 14,
},
2: {
"header": _("Current"),
"field": "current",
"field_footer_total": "cumul_current",
"field_footer_percent": "percent_current",
"type": "amount",
"width": 14,
},
3: {
"header": _(u"Age ≤ 30 d."),
"field": "age_30_days",
"field_footer_total": "cumul_age_30_days",
"field_footer_percent": "percent_age_30_days",
"type": "amount",
"width": 14,
},
4: {
"header": _(u"Age ≤ 60 d."),
"field": "age_60_days",
"field_footer_total": "cumul_age_60_days",
"field_footer_percent": "percent_age_60_days",
"type": "amount",
"width": 14,
},
5: {
"header": _(u"Age ≤ 90 d."),
"field": "age_90_days",
"field_footer_total": "cumul_age_90_days",
"field_footer_percent": "percent_age_90_days",
"type": "amount",
"width": 14,
},
6: {
"header": _(u"Age ≤ 120 d."),
"field": "age_120_days",
"field_footer_total": "cumul_age_120_days",
"field_footer_percent": "percent_age_120_days",
"type": "amount",
"width": 14,
},
7: {
"header": _("Older"),
"field": "older",
"field_footer_total": "cumul_older",
"field_footer_percent": "percent_older",
"type": "amount",
"width": 14,
},
}
return {
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': _('Due date'), 'field': 'date_due', 'width': 11},
7: {'header': _('Residual'),
'field': 'amount_residual',
'field_footer_total': 'cumul_amount_residual',
'field_final_balance': 'amount_residual',
'type': 'amount',
'width': 14},
8: {'header': _('Current'),
'field': 'current',
'field_footer_total': 'cumul_current',
'field_footer_percent': 'percent_current',
'field_final_balance': 'current',
'type': 'amount',
'width': 14},
9: {'header': _(u'Age ≤ 30 d.'),
'field': 'age_30_days',
'field_footer_total': 'cumul_age_30_days',
'field_footer_percent': 'percent_age_30_days',
'field_final_balance': 'age_30_days',
'type': 'amount',
'width': 14},
10: {'header': _(u'Age ≤ 60 d.'),
'field': 'age_60_days',
'field_footer_total': 'cumul_age_60_days',
'field_footer_percent': 'percent_age_60_days',
'field_final_balance': 'age_60_days',
'type': 'amount',
'width': 14},
11: {'header': _(u'Age ≤ 90 d.'),
'field': 'age_90_days',
'field_footer_total': 'cumul_age_90_days',
'field_footer_percent': 'percent_age_90_days',
'field_final_balance': 'age_90_days',
'type': 'amount',
'width': 14},
12: {'header': _(u'Age ≤ 120 d.'),
'field': 'age_120_days',
'field_footer_total': 'cumul_age_120_days',
'field_footer_percent': 'percent_age_120_days',
'field_final_balance': 'age_120_days',
'type': 'amount',
'width': 14},
13: {'header': _('Older'),
'field': 'older',
'field_footer_total': 'cumul_older',
'field_footer_percent': 'percent_older',
'field_final_balance': 'older',
'type': 'amount',
'width': 14},
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": _("Due date"), "field": "date_due", "width": 11},
7: {
"header": _("Residual"),
"field": "amount_residual",
"field_footer_total": "cumul_amount_residual",
"field_final_balance": "amount_residual",
"type": "amount",
"width": 14,
},
8: {
"header": _("Current"),
"field": "current",
"field_footer_total": "cumul_current",
"field_footer_percent": "percent_current",
"field_final_balance": "current",
"type": "amount",
"width": 14,
},
9: {
"header": _(u"Age ≤ 30 d."),
"field": "age_30_days",
"field_footer_total": "cumul_age_30_days",
"field_footer_percent": "percent_age_30_days",
"field_final_balance": "age_30_days",
"type": "amount",
"width": 14,
},
10: {
"header": _(u"Age ≤ 60 d."),
"field": "age_60_days",
"field_footer_total": "cumul_age_60_days",
"field_footer_percent": "percent_age_60_days",
"field_final_balance": "age_60_days",
"type": "amount",
"width": 14,
},
11: {
"header": _(u"Age ≤ 90 d."),
"field": "age_90_days",
"field_footer_total": "cumul_age_90_days",
"field_footer_percent": "percent_age_90_days",
"field_final_balance": "age_90_days",
"type": "amount",
"width": 14,
},
12: {
"header": _(u"Age ≤ 120 d."),
"field": "age_120_days",
"field_footer_total": "cumul_age_120_days",
"field_footer_percent": "percent_age_120_days",
"field_final_balance": "age_120_days",
"type": "amount",
"width": 14,
},
13: {
"header": _("Older"),
"field": "older",
"field_footer_total": "cumul_older",
"field_footer_percent": "percent_older",
"field_final_balance": "older",
"type": "amount",
"width": 14,
},
}
def _get_report_filters(self, report):
return [
[_('Date at filter'), report.date_at],
[_('Target moves filter'),
_('All posted entries') if report.only_posted_moves else _(
'All entries')],
[_("Date at filter"), report.date_at],
[
_("Target moves filter"),
_("All posted entries")
if report.only_posted_moves
else _("All entries"),
],
]
def _get_col_count_filter_name(self):
@ -146,7 +176,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
# For each account
for account in report.account_ids:
# Write account title
self.write_array_title(account.code + ' - ' + account.name)
self.write_array_title(account.code + " - " + account.name)
# Display array header for partners lines
self.write_array_header()
@ -156,20 +186,24 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
self.write_line(partner.line_ids)
# Display account lines
self.write_account_footer(report,
account,
_('Total'),
'field_footer_total',
self.format_header_right,
self.format_header_amount,
False)
self.write_account_footer(report,
account,
_('Percents'),
'field_footer_percent',
self.format_right_bold_italic,
self.format_percent_bold_italic,
True)
self.write_account_footer(
report,
account,
_("Total"),
"field_footer_total",
self.format_header_right,
self.format_header_amount,
False,
)
self.write_account_footer(
report,
account,
_("Percents"),
"field_footer_percent",
self.format_right_bold_italic,
self.format_percent_bold_italic,
True,
)
# 2 lines break
self.row_pos += 2
@ -177,7 +211,7 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
# For each account
for account in report.account_ids:
# Write account title
self.write_array_title(account.code + ' - ' + account.name)
self.write_array_title(account.code + " - " + account.name)
# For each partner
for partner in account.partner_ids:
@ -198,20 +232,24 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
self.row_pos += 1
# Display account lines
self.write_account_footer(report,
account,
_('Total'),
'field_footer_total',
self.format_header_right,
self.format_header_amount,
False)
self.write_account_footer(report,
account,
_('Percents'),
'field_footer_percent',
self.format_right_bold_italic,
self.format_percent_bold_italic,
True)
self.write_account_footer(
report,
account,
_("Total"),
"field_footer_total",
self.format_header_right,
self.format_header_amount,
False,
)
self.write_account_footer(
report,
account,
_("Percents"),
"field_footer_percent",
self.format_right_bold_italic,
self.format_percent_bold_italic,
True,
)
# 2 lines break
self.row_pos += 2
@ -222,13 +260,19 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
for Aged Partner Balance
"""
name = None
label = _('Partner cumul aged balance')
super(AgedPartnerBalanceXslx, self).write_ending_balance(
my_object, name, label
)
label = _("Partner cumul aged balance")
super(AgedPartnerBalanceXslx, self).write_ending_balance(my_object, name, label)
def write_account_footer(self, report, account, label, field_name,
string_format, amount_format, amount_is_percent):
def write_account_footer(
self,
report,
account,
label,
field_name,
string_format,
amount_format,
amount_is_percent,
):
"""
Specific function to write account footer for Aged Partner Balance
"""
@ -239,19 +283,19 @@ class AgedPartnerBalanceXslx(models.AbstractModel):
value = label
else:
value = getattr(account, column[field_name])
cell_type = column.get('type', 'string')
if cell_type == 'string' or col_pos == col_pos_footer_label:
self.sheet.write_string(self.row_pos, col_pos, value or '',
string_format)
elif cell_type == 'amount':
cell_type = column.get("type", "string")
if cell_type == "string" or col_pos == col_pos_footer_label:
self.sheet.write_string(
self.row_pos, col_pos, value or "", string_format
)
elif cell_type == "amount":
number = float(value)
if amount_is_percent:
number /= 100
self.sheet.write_number(self.row_pos, col_pos,
number,
amount_format)
self.sheet.write_number(
self.row_pos, col_pos, number, amount_format
)
else:
self.sheet.write_string(self.row_pos, col_pos, '',
string_format)
self.sheet.write_string(self.row_pos, col_pos, "", string_format)
self.row_pos += 1

485
account_financial_report/report/general_ledger.py

@ -1,8 +1,7 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api, _
from odoo import _, api, fields, models
class GeneralLedgerReport(models.TransientModel):
@ -21,8 +20,8 @@ class GeneralLedgerReport(models.TransientModel):
For receivable/payable and not centralized accounts
"""
_name = 'report_general_ledger'
_inherit = 'account_financial_report_abstract'
_name = "report_general_ledger"
_inherit = "account_financial_report_abstract"
# Filters fields, used for data computation
date_from = fields.Date()
@ -32,71 +31,60 @@ class GeneralLedgerReport(models.TransientModel):
hide_account_at_0 = fields.Boolean()
foreign_currency = fields.Boolean()
show_analytic_tags = 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')
filter_cost_center_ids = fields.Many2many(
comodel_name='account.analytic.account'
)
filter_analytic_tag_ids = fields.Many2many(
comodel_name='account.analytic.tag',
)
filter_journal_ids = fields.Many2many(
comodel_name='account.journal',
)
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")
filter_cost_center_ids = fields.Many2many(comodel_name="account.analytic.account")
filter_analytic_tag_ids = fields.Many2many(comodel_name="account.analytic.tag",)
filter_journal_ids = fields.Many2many(comodel_name="account.journal",)
centralize = fields.Boolean()
# Flag fields, used for report display
show_cost_center = fields.Boolean(
default=lambda self: self.env.user.has_group(
'analytic.group_analytic_accounting'
"analytic.group_analytic_accounting"
)
)
partner_ungrouped = fields.Boolean(
string='Partner ungrouped',
help='If set moves are not grouped by partner in any case'
string="Partner ungrouped",
help="If set moves are not grouped by partner in any case",
)
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_general_ledger_account',
inverse_name='report_id'
comodel_name="report_general_ledger_account", inverse_name="report_id"
)
# Compute of unaffected earnings account
@api.depends('company_id')
@api.depends("company_id")
def _compute_unaffected_earnings_account(self):
account_type = self.env.ref('account.data_unaffected_earnings')
self.unaffected_earnings_account = self.env['account.account'].search(
account_type = self.env.ref("account.data_unaffected_earnings")
self.unaffected_earnings_account = self.env["account.account"].search(
[
('user_type_id', '=', account_type.id),
('company_id', '=', self.company_id.id)
])
("user_type_id", "=", account_type.id),
("company_id", "=", self.company_id.id),
]
)
unaffected_earnings_account = fields.Many2one(
comodel_name='account.account',
compute='_compute_unaffected_earnings_account',
store=True
comodel_name="account.account",
compute="_compute_unaffected_earnings_account",
store=True,
)
class GeneralLedgerReportAccount(models.TransientModel):
_name = 'report_general_ledger_account'
_inherit = 'account_financial_report_abstract'
_order = 'code ASC'
_name = "report_general_ledger_account"
_inherit = "account_financial_report_abstract"
_order = "code ASC"
report_id = fields.Many2one(
comodel_name='report_general_ledger',
ondelete='cascade',
index=True
comodel_name="report_general_ledger", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
account_id = fields.Many2one(
'account.account',
index=True
)
account_id = fields.Many2one("account.account", index=True)
# Data fields, used for report display
code = fields.Char()
@ -104,7 +92,7 @@ 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')
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))
@ -116,38 +104,31 @@ class GeneralLedgerReportAccount(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_general_ledger_move_line',
inverse_name='report_account_id'
comodel_name="report_general_ledger_move_line", inverse_name="report_account_id"
)
partner_ids = fields.One2many(
comodel_name='report_general_ledger_partner',
inverse_name='report_account_id'
comodel_name="report_general_ledger_partner", inverse_name="report_account_id"
)
class GeneralLedgerReportPartner(models.TransientModel):
_name = 'report_general_ledger_partner'
_inherit = 'account_financial_report_abstract'
_name = "report_general_ledger_partner"
_inherit = "account_financial_report_abstract"
report_account_id = fields.Many2one(
comodel_name='report_general_ledger_account',
ondelete='cascade',
index=True
comodel_name="report_general_ledger_account", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
partner_id = fields.Many2one(
'res.partner',
index=True
)
partner_id = fields.Many2one("res.partner", index=True)
# Data fields, used for report display
name = fields.Char()
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')
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))
@ -156,8 +137,7 @@ class GeneralLedgerReportPartner(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_general_ledger_move_line',
inverse_name='report_partner_id'
comodel_name="report_general_ledger_move_line", inverse_name="report_partner_id"
)
@api.model
@ -176,22 +156,18 @@ ORDER BY
class GeneralLedgerReportMoveLine(models.TransientModel):
_name = 'report_general_ledger_move_line'
_inherit = 'account_financial_report_abstract'
_name = "report_general_ledger_move_line"
_inherit = "account_financial_report_abstract"
report_account_id = fields.Many2one(
comodel_name='report_general_ledger_account',
ondelete='cascade',
index=True
comodel_name="report_general_ledger_account", ondelete="cascade", index=True
)
report_partner_id = fields.Many2one(
comodel_name='report_general_ledger_partner',
ondelete='cascade',
index=True
comodel_name="report_general_ledger_partner", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
move_line_id = fields.Many2one('account.move.line')
move_line_id = fields.Many2one("account.move.line")
# Data fields, used for report display
date = fields.Date()
@ -207,7 +183,7 @@ class GeneralLedgerReportMoveLine(models.TransientModel):
debit = fields.Float(digits=(16, 2))
credit = fields.Float(digits=(16, 2))
cumul_balance = fields.Float(digits=(16, 2))
currency_id = fields.Many2one('res.currency')
currency_id = fields.Many2one("res.currency")
amount_currency = fields.Float(digits=(16, 2))
@ -216,31 +192,34 @@ class GeneralLedgerReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_general_ledger'
_inherit = "report_general_ledger"
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_general_ledger_xlsx'
if report_type == "xlsx":
report_name = "a_f_r.report_general_ledger_xlsx"
else:
report_name = 'account_financial_report.' \
'report_general_ledger_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
report_name = "account_financial_report." "report_general_ledger_qweb"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, config=False)
)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
report = self.browse(context.get("active_id"))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_general_ledger').render(
rcontext)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_general_ledger"
).render(rcontext)
return result
@api.model
@ -248,9 +227,7 @@ class GeneralLedgerReportCompute(models.TransientModel):
return self._get_html()
@api.multi
def compute_data_for_report(self,
with_line_details=True,
with_partners=True):
def compute_data_for_report(self, with_line_details=True, with_partners=True):
self.ensure_one()
# Compute report data
self._inject_account_values()
@ -260,9 +237,10 @@ class GeneralLedgerReportCompute(models.TransientModel):
if not self.filter_partner_ids:
self._inject_partner_values(only_empty_partner=True)
# Add unaffected earnings account
if (not self.filter_account_ids or
self.unaffected_earnings_account.id in
self.filter_account_ids.ids):
if (
not self.filter_account_ids
or self.unaffected_earnings_account.id in self.filter_account_ids.ids
):
self._inject_unaffected_earnings_account_values()
# Call this function even if we don't want line details because,
@ -276,13 +254,14 @@ class GeneralLedgerReportCompute(models.TransientModel):
if with_line_details:
self._inject_line_not_centralized_values(
is_account_line=False,
is_partner_line=True)
is_account_line=False, is_partner_line=True
)
self._inject_line_not_centralized_values(
is_account_line=False,
is_partner_line=True,
only_empty_partner_line=True)
only_empty_partner_line=True,
)
if self.centralize:
self._inject_line_centralized_values()
@ -295,7 +274,8 @@ class GeneralLedgerReportCompute(models.TransientModel):
self.invalidate_cache()
def _get_account_sub_subquery_sum_amounts(
self, include_initial_balance, date_included):
self, include_initial_balance, date_included
):
""" Return subquery used to compute sum amounts on accounts """
sub_subquery_sum_amounts = """
SELECT
@ -339,7 +319,9 @@ class GeneralLedgerReportCompute(models.TransientModel):
sub_subquery_sum_amounts += """
AND
ml.journal_id IN %s
""" % (tuple(self.filter_journal_ids.ids,),)
""" % (
tuple(self.filter_journal_ids.ids,),
)
if self.only_posted_moves:
sub_subquery_sum_amounts += """
@ -425,9 +407,9 @@ WITH
account_account a
"""
if (
self.filter_partner_ids or
self.filter_cost_center_ids or
self.filter_analytic_tag_ids
self.filter_partner_ids
or self.filter_cost_center_ids
or self.filter_analytic_tag_ids
):
query_inject_account += """
INNER JOIN
@ -473,9 +455,9 @@ WITH
p.id IN %s
"""
if (
self.filter_partner_ids or
self.filter_cost_center_ids or
self.filter_analytic_tag_ids
self.filter_partner_ids
or self.filter_cost_center_ids
or self.filter_analytic_tag_ids
):
query_inject_account += """
GROUP BY
@ -514,9 +496,14 @@ WITH
date_included=True
)
query_inject_account += """
initial_sum_amounts AS ( """ + init_subquery + """ ),
final_sum_amounts AS ( """ + final_subquery + """ )
query_inject_account += (
"""
initial_sum_amounts AS ( """
+ init_subquery
+ """ ),
final_sum_amounts AS ( """
+ final_subquery
+ """ )
INSERT INTO
report_general_ledger_account
(
@ -572,6 +559,7 @@ WHERE
OR f.balance IS NOT NULL AND f.balance != 0
)
"""
)
if self.hide_account_at_0:
query_inject_account += """
AND
@ -579,59 +567,37 @@ AND
"""
query_inject_account_params = ()
if self.filter_cost_center_ids:
query_inject_account_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_account_params += (tuple(self.filter_cost_center_ids.ids),)
if self.filter_analytic_tag_ids:
query_inject_account_params += (
tuple(self.filter_analytic_tag_ids.ids),
)
query_inject_account_params += (tuple(self.filter_analytic_tag_ids.ids),)
query_inject_account_params += (
self.company_id.id,
self.unaffected_earnings_account.id,
)
if self.filter_account_ids:
query_inject_account_params += (
tuple(self.filter_account_ids.ids),
)
query_inject_account_params += (tuple(self.filter_account_ids.ids),)
if self.filter_partner_ids:
query_inject_account_params += (
tuple(self.filter_partner_ids.ids),
)
query_inject_account_params += (tuple(self.filter_partner_ids.ids),)
if self.filter_analytic_tag_ids:
query_inject_account_params += (
tuple(self.filter_analytic_tag_ids.ids),
)
query_inject_account_params += (tuple(self.filter_analytic_tag_ids.ids),)
query_inject_account_params += (
self.date_from,
self.fy_start_date,
)
if self.filter_cost_center_ids:
query_inject_account_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_account_params += (
self.date_from,
)
query_inject_account_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_account_params += (self.date_from,)
if self.filter_cost_center_ids:
query_inject_account_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_account_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_account_params += (
self.date_to,
self.fy_start_date,
)
if self.filter_cost_center_ids:
query_inject_account_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_account_params += (
self.date_to,
)
query_inject_account_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_account_params += (self.date_to,)
if self.filter_cost_center_ids:
query_inject_account_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_account_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_account_params += (
self.id,
self.env.uid,
@ -639,7 +605,7 @@ AND
self.env.cr.execute(query_inject_account, query_inject_account_params)
def _get_partner_sub_subquery_sum_amounts(
self, only_empty_partner, include_initial_balance, date_included
self, only_empty_partner, include_initial_balance, date_included
):
""" Return subquery used to compute sum amounts on partners """
sub_subquery_sum_amounts = """
@ -713,8 +679,9 @@ AND
"""
return sub_subquery_sum_amounts
def _get_final_partner_sub_subquery_sum_amounts(self, only_empty_partner,
date_included):
def _get_final_partner_sub_subquery_sum_amounts(
self, only_empty_partner, date_included
):
"""Return final subquery used to compute sum amounts on partners"""
subquery_sum_amounts = """
@ -733,7 +700,7 @@ AND
subquery_sum_amounts += self._get_partner_sub_subquery_sum_amounts(
only_empty_partner,
include_initial_balance=False,
date_included=date_included
date_included=date_included,
)
subquery_sum_amounts += """
UNION
@ -741,7 +708,7 @@ AND
subquery_sum_amounts += self._get_partner_sub_subquery_sum_amounts(
only_empty_partner,
include_initial_balance=True,
date_included=date_included
date_included=date_included,
)
subquery_sum_amounts += """
) sub
@ -756,7 +723,8 @@ AND
Only for "partner" accounts (payable and receivable).
"""
# pylint: disable=sql-injection
query_inject_partner = """
query_inject_partner = (
"""
WITH
accounts_partners AS
(
@ -773,7 +741,9 @@ WITH
THEN p.name || ' (' || p.ref || ')'
ELSE p.name
END,
'""" + _('No partner allocated') + """'
'"""
+ _("No partner allocated")
+ """'
) AS partner_name
FROM
report_general_ledger_account ra
@ -786,6 +756,7 @@ WITH
LEFT JOIN
res_partner p ON ml.partner_id = p.id
"""
)
if self.filter_cost_center_ids:
query_inject_partner += """
INNER JOIN
@ -834,12 +805,10 @@ WITH
"""
init_subquery = self._get_final_partner_sub_subquery_sum_amounts(
only_empty_partner,
date_included=False
only_empty_partner, date_included=False
)
final_subquery = self._get_final_partner_sub_subquery_sum_amounts(
only_empty_partner,
date_included=True
only_empty_partner, date_included=True
)
query_inject_partner += """
@ -873,9 +842,14 @@ WITH
),
"""
query_inject_partner += """
initial_sum_amounts AS ( """ + init_subquery + """ ),
final_sum_amounts AS ( """ + final_subquery + """ )
query_inject_partner += (
"""
initial_sum_amounts AS ( """
+ init_subquery
+ """ ),
final_sum_amounts AS ( """
+ final_subquery
+ """ )
INSERT INTO
report_general_ledger_partner
(
@ -916,6 +890,7 @@ LEFT JOIN
ON
(
"""
)
if not only_empty_partner:
query_inject_partner += """
ap.partner_id = i.partner_id
@ -960,65 +935,42 @@ AND
"""
query_inject_partner_params = ()
if self.filter_cost_center_ids:
query_inject_partner_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_partner_params += (tuple(self.filter_cost_center_ids.ids),)
if self.filter_analytic_tag_ids:
query_inject_partner_params += (
tuple(self.filter_analytic_tag_ids.ids),
)
query_inject_partner_params += (
self.id,
)
query_inject_partner_params += (tuple(self.filter_analytic_tag_ids.ids),)
query_inject_partner_params += (self.id,)
if self.filter_partner_ids:
query_inject_partner_params += (
tuple(self.filter_partner_ids.ids),
)
query_inject_partner_params += (tuple(self.filter_partner_ids.ids),)
if self.filter_analytic_tag_ids:
query_inject_partner_params += (
tuple(self.filter_analytic_tag_ids.ids),
)
query_inject_partner_params += (tuple(self.filter_analytic_tag_ids.ids),)
query_inject_partner_params += (
self.date_from,
self.fy_start_date,
)
if self.filter_cost_center_ids:
query_inject_partner_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_partner_params += (
self.date_from,
)
query_inject_partner_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_partner_params += (self.date_from,)
if self.filter_cost_center_ids:
query_inject_partner_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_partner_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_partner_params += (
self.date_to,
self.fy_start_date,
)
if self.filter_cost_center_ids:
query_inject_partner_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_partner_params += (
self.date_to,
)
query_inject_partner_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_partner_params += (self.date_to,)
if self.filter_cost_center_ids:
query_inject_partner_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_partner_params += (
self.env.uid,
)
query_inject_partner_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_partner_params += (self.env.uid,)
self.env.cr.execute(query_inject_partner, query_inject_partner_params)
def _inject_line_not_centralized_values(
self,
is_account_line=True,
is_partner_line=False,
only_empty_partner_line=False,
only_unaffected_earnings_account=False):
self,
is_account_line=True,
is_partner_line=False,
only_empty_partner_line=False,
only_unaffected_earnings_account=False,
):
""" Inject report values for report_general_ledger_move_line.
If centralized option have been chosen,
@ -1151,9 +1103,13 @@ SELECT
END AS partner,
"""
elif only_empty_partner_line:
query_inject_move_line += """
'""" + _('No partner allocated') + """' AS partner,
query_inject_move_line += (
"""
'"""
+ _("No partner allocated")
+ """' AS partner,
"""
)
query_inject_move_line += """
CONCAT_WS(' - ', NULLIF(ml.ref, ''), NULLIF(ml.name, '')) AS label,
aa.name AS cost_center,
@ -1243,7 +1199,7 @@ LEFT JOIN
account_analytic_account aa ON ml.analytic_account_id = aa.id
"""
if self.filter_analytic_tag_ids:
query_inject_move_line += """
query_inject_move_line += """
INNER JOIN
move_lines_on_tags ON ml.id = move_lines_on_tags.ml_id
"""
@ -1313,32 +1269,19 @@ ORDER BY
self.id,
tuple(self.filter_analytic_tag_ids.ids),
)
query_inject_move_line_params += (
self.env.uid,
)
query_inject_move_line_params += (self.env.uid,)
if self.filter_cost_center_ids:
query_inject_move_line_params += (
tuple(self.filter_cost_center_ids.ids),
)
query_inject_move_line_params += (
self.id,
)
query_inject_move_line_params += (tuple(self.filter_cost_center_ids.ids),)
query_inject_move_line_params += (self.id,)
if only_unaffected_earnings_account:
query_inject_move_line_params += (
self.unaffected_earnings_account.id,
)
query_inject_move_line_params += (self.unaffected_earnings_account.id,)
query_inject_move_line_params += (
self.date_from,
self.date_to,
)
if self.filter_journal_ids:
query_inject_move_line_params += (tuple(
self.filter_journal_ids.ids,
),)
self.env.cr.execute(
query_inject_move_line,
query_inject_move_line_params
)
query_inject_move_line_params += (tuple(self.filter_journal_ids.ids,),)
self.env.cr.execute(query_inject_move_line, query_inject_move_line_params)
def _inject_line_centralized_values(self):
""" Inject report values for report_general_ledger_move_line.
@ -1423,7 +1366,8 @@ WITH
AND
m.state = 'posted'
"""
query_inject_move_line_centralized += """
query_inject_move_line_centralized += (
"""
GROUP BY
ra.id, ml.account_id, a.code, 2, ml.currency_id, ml.journal_id
)
@ -1448,7 +1392,9 @@ SELECT
ml.date,
a.code AS account,
j.code AS journal,
'""" + _('Centralized Entries') + """' AS label,
'"""
+ _("Centralized Entries")
+ """' AS label,
ml.debit AS debit,
ml.credit AS credit,
ra.initial_balance + (
@ -1470,6 +1416,7 @@ WHERE
AND
(a.centralized IS NOT NULL AND a.centralized = TRUE)
"""
)
if self.filter_journal_ids:
query_inject_move_line_centralized += """
AND
@ -1498,12 +1445,12 @@ ORDER BY
self.id,
)
if self.filter_journal_ids:
query_inject_move_line_centralized_params += (tuple(
self.filter_journal_ids.ids,
),)
query_inject_move_line_centralized_params += (
tuple(self.filter_journal_ids.ids,),
)
self.env.cr.execute(
query_inject_move_line_centralized,
query_inject_move_line_centralized_params
query_inject_move_line_centralized_params,
)
def _compute_analytic_tags(self):
@ -1572,7 +1519,7 @@ WHERE
report_general_ledger_move_line.id = tags_values.report_id
"""
params = {
'report_id': self.id,
"report_id": self.id,
}
self.env.cr.execute(query_update_analytic_tags, params)
@ -1589,20 +1536,21 @@ WHERE
"""
self.env.cr.execute(query_unaffected_earnings_account_ids)
pl_account_ids = [r[0] for r in self.env.cr.fetchall()]
unaffected_earnings_account_ids = \
pl_account_ids + [self.unaffected_earnings_account.id]
unaffected_earnings_account_ids = pl_account_ids + [
self.unaffected_earnings_account.id
]
# Fetch the current fiscal year start date
date = fields.Datetime.from_string(self.date_from)
res = self.company_id.compute_fiscalyear_dates(date)
fy_start_date = res['date_from']
fy_start_date = res["date_from"]
query_select_previous_fy_unaffected_earnings_params = {
'date_to': fy_start_date,
'company_id': self.company_id.id,
'account_ids': tuple(unaffected_earnings_account_ids),
'analytic_tag_ids': tuple(self.filter_analytic_tag_ids.ids),
"date_to": fy_start_date,
"company_id": self.company_id.id,
"account_ids": tuple(unaffected_earnings_account_ids),
"analytic_tag_ids": tuple(self.filter_analytic_tag_ids.ids),
}
query_select_previous_fy_unaffected_earnings = ''
q_analytic_tags = ''
query_select_previous_fy_unaffected_earnings = ""
q_analytic_tags = ""
if self.filter_analytic_tag_ids:
q_analytic_tags = """
WITH move_lines_on_tags AS
@ -1642,7 +1590,8 @@ WITH move_lines_on_tags AS
AND aa.id IN %(cost_center_ids)s
"""
query_select_previous_fy_unaffected_earnings_params[
'cost_center_ids'] = tuple(self.filter_cost_center_ids.ids)
"cost_center_ids"
] = tuple(self.filter_cost_center_ids.ids)
if self.filter_analytic_tag_ids:
query_select_previous_fy_unaffected_earnings += """
INNER JOIN move_lines_on_tags ON ml.id =
@ -1657,27 +1606,29 @@ WITH move_lines_on_tags AS
query_select_previous_fy_unaffected_earnings += """
AND j.id IN %(journal_ids)s
"""
query_select_previous_fy_unaffected_earnings_params[
'journal_ids'] = tuple(self.filter_journal_ids.ids)
query_select_previous_fy_unaffected_earnings_params["journal_ids"] = tuple(
self.filter_journal_ids.ids
)
if self.only_posted_moves:
query_select_previous_fy_unaffected_earnings += """
AND am.state = 'posted'
"""
self.env.cr.execute(
query_select_previous_fy_unaffected_earnings,
query_select_previous_fy_unaffected_earnings_params)
query_select_previous_fy_unaffected_earnings_params,
)
res = self.env.cr.fetchone()
unaffected_earnings_initial_balance = res[0] or 0.0
# Now select the current period unaffected earnings,
# excluding the current period P&L.
query_select_period_unaffected_earnings_params = {
'date_from': self.date_from,
'date_to': self.date_to,
'company_id': self.company_id.id,
'unaffected_earnings_id': self.unaffected_earnings_account.id,
'analytic_tag_ids': tuple(self.filter_analytic_tag_ids.ids),
"date_from": self.date_from,
"date_to": self.date_to,
"company_id": self.company_id.id,
"unaffected_earnings_id": self.unaffected_earnings_account.id,
"analytic_tag_ids": tuple(self.filter_analytic_tag_ids.ids),
}
query_select_period_unaffected_earnings = ''
query_select_period_unaffected_earnings = ""
if self.filter_analytic_tag_ids:
query_select_period_unaffected_earnings += q_analytic_tags
query_select_period_unaffected_earnings += """
@ -1697,8 +1648,9 @@ WITH move_lines_on_tags AS
ON ml.analytic_account_id = aa.id
AND aa.id IN %(cost_center_ids)s
"""
query_select_period_unaffected_earnings_params[
'cost_center_ids'] = tuple(self.filter_cost_center_ids.ids)
query_select_period_unaffected_earnings_params["cost_center_ids"] = tuple(
self.filter_cost_center_ids.ids
)
if self.filter_analytic_tag_ids:
query_select_period_unaffected_earnings += """
INNER JOIN move_lines_on_tags
@ -1714,14 +1666,17 @@ WITH move_lines_on_tags AS
query_select_period_unaffected_earnings += """
AND j.id IN %(journal_ids)s
"""
query_select_period_unaffected_earnings_params[
'journal_ids'] = tuple(self.filter_journal_ids.ids)
query_select_period_unaffected_earnings_params["journal_ids"] = tuple(
self.filter_journal_ids.ids
)
if self.only_posted_moves:
query_select_period_unaffected_earnings += """
AND am.state = 'posted'
"""
self.env.cr.execute(query_select_period_unaffected_earnings,
query_select_period_unaffected_earnings_params)
self.env.cr.execute(
query_select_period_unaffected_earnings,
query_select_period_unaffected_earnings_params,
)
res = self.env.cr.fetchone()
unaffected_earnings_period_debit = res[0] or 0.0
unaffected_earnings_period_credit = res[1] or 0.0
@ -1760,24 +1715,30 @@ WITH move_lines_on_tags AS
%(final_balance)s
)
"""
initial_debit = unaffected_earnings_initial_balance >= 0 and \
unaffected_earnings_initial_balance or 0
initial_credit = unaffected_earnings_initial_balance < 0 and \
-1 * unaffected_earnings_initial_balance or 0
final_balance = unaffected_earnings_initial_balance + \
unaffected_earnings_period_balance
initial_debit = (
unaffected_earnings_initial_balance >= 0
and unaffected_earnings_initial_balance
or 0
)
initial_credit = (
unaffected_earnings_initial_balance < 0
and -1 * unaffected_earnings_initial_balance
or 0
)
final_balance = (
unaffected_earnings_initial_balance + unaffected_earnings_period_balance
)
query_inject_account_params = {
'report_id': self.id,
'user_id': self.env.uid,
'account_id': self.unaffected_earnings_account.id,
'code': self.unaffected_earnings_account.code,
'name': self.unaffected_earnings_account.name,
'initial_debit': initial_debit,
'initial_credit': initial_credit,
'initial_balance': unaffected_earnings_initial_balance,
'final_debit': initial_debit + unaffected_earnings_period_debit,
'final_credit': initial_credit + unaffected_earnings_period_credit,
'final_balance': final_balance,
"report_id": self.id,
"user_id": self.env.uid,
"account_id": self.unaffected_earnings_account.id,
"code": self.unaffected_earnings_account.code,
"name": self.unaffected_earnings_account.name,
"initial_debit": initial_debit,
"initial_credit": initial_credit,
"initial_balance": unaffected_earnings_initial_balance,
"final_debit": initial_debit + unaffected_earnings_period_debit,
"final_credit": initial_credit + unaffected_earnings_period_credit,
"final_balance": final_balance,
}
self.env.cr.execute(query_inject_account,
query_inject_account_params)
self.env.cr.execute(query_inject_account, query_inject_account_params)

158
account_financial_report/report/general_ledger_xlsx.py

@ -1,4 +1,3 @@
# Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA
@ -8,64 +7,67 @@ from odoo import _, models
class GeneralLedgerXslx(models.AbstractModel):
_name = 'report.a_f_r.report_general_ledger_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
_name = "report.a_f_r.report_general_ledger_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('General Ledger')
report_name = _("General Ledger")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
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': _('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},
8: {'header': _('Tags'),
'field': 'tags',
'width': 10},
9: {'header': _('Rec.'), 'field': 'matching_number', 'width': 5},
10: {'header': _('Debit'),
'field': 'debit',
'field_initial_balance': 'initial_debit',
'field_final_balance': 'final_debit',
'type': 'amount',
'width': 14},
11: {'header': _('Credit'),
'field': 'credit',
'field_initial_balance': 'initial_credit',
'field_final_balance': 'final_credit',
'type': 'amount',
'width': 14},
12: {'header': _('Cumul. Bal.'),
'field': 'cumul_balance',
'field_initial_balance': 'initial_balance',
'field_final_balance': 'final_balance',
'type': 'amount',
'width': 14},
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": _("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},
8: {"header": _("Tags"), "field": "tags", "width": 10},
9: {"header": _("Rec."), "field": "matching_number", "width": 5},
10: {
"header": _("Debit"),
"field": "debit",
"field_initial_balance": "initial_debit",
"field_final_balance": "final_debit",
"type": "amount",
"width": 14,
},
11: {
"header": _("Credit"),
"field": "credit",
"field_initial_balance": "initial_credit",
"field_final_balance": "final_credit",
"type": "amount",
"width": 14,
},
12: {
"header": _("Cumul. Bal."),
"field": "cumul_balance",
"field_initial_balance": "initial_balance",
"field_final_balance": "final_balance",
"type": "amount",
"width": 14,
},
}
if report.foreign_currency:
foreign_currency = {
13: {'header': _('Cur.'),
'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
14: {'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},
13: {
"header": _("Cur."),
"field": "currency_id",
"field_currency_balance": "currency_id",
"type": "many2one",
"width": 7,
},
14: {
"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
@ -73,29 +75,27 @@ class GeneralLedgerXslx(models.AbstractModel):
def _get_report_filters(self, report):
return [
[
_('Date range filter'),
_('From: %s To: %s') % (report.date_from, report.date_to),
],
[
_('Target moves filter'),
_('All posted entries') if report.only_posted_moves
else _('All entries'),
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
],
[
_('Account balance at 0 filter'),
_('Hide') if report.hide_account_at_0 else _('Show'),
_("Target moves filter"),
_("All posted entries")
if report.only_posted_moves
else _("All entries"),
],
[
_('Centralize filter'),
_('Yes') if report.centralize else _('No'),
_("Account balance at 0 filter"),
_("Hide") if report.hide_account_at_0 else _("Show"),
],
[_("Centralize filter"), _("Yes") if report.centralize else _("No"),],
[
_('Show analytic tags'),
_('Yes') if report.show_analytic_tags else _('No'),
_("Show analytic tags"),
_("Yes") if report.show_analytic_tags else _("No"),
],
[
_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')
_("Show foreign currency"),
_("Yes") if report.foreign_currency else _("No"),
],
]
@ -118,7 +118,7 @@ class GeneralLedgerXslx(models.AbstractModel):
# For each account
for account in report.account_ids:
# Write account title
self.write_array_title(account.code + ' - ' + account.name)
self.write_array_title(account.code + " - " + account.name)
if not account.partner_ids:
# Display array header for move lines
@ -162,23 +162,19 @@ class GeneralLedgerXslx(models.AbstractModel):
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')
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
)
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 'partner' in my_object._name:
if "partner" in my_object._name:
name = my_object.name
label = _('Partner ending balance')
elif 'account' in my_object._name:
name = my_object.code + ' - ' + my_object.name
label = _('Ending balance')
super(GeneralLedgerXslx, self).write_ending_balance(
my_object, name, label
)
label = _("Partner ending balance")
elif "account" in my_object._name:
name = my_object.code + " - " + my_object.name
label = _("Ending balance")
super(GeneralLedgerXslx, self).write_ending_balance(my_object, name, label)

299
account_financial_report/report/journal_ledger.py

@ -1,80 +1,60 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api
from odoo import api, fields, models
DIGITS = (16, 2)
class ReportJournalLedger(models.TransientModel):
_name = 'report_journal_ledger'
_inherit = 'account_financial_report_abstract'
_name = "report_journal_ledger"
_inherit = "account_financial_report_abstract"
date_from = fields.Date(
required=True
)
date_to = fields.Date(
required=True
)
date_from = fields.Date(required=True)
date_to = fields.Date(required=True)
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
comodel_name="res.company", required=True, ondelete="cascade"
)
move_target = fields.Selection(
selection='_get_move_targets',
default='all',
required=True,
selection="_get_move_targets", default="all", required=True,
)
sort_option = fields.Selection(
selection='_get_sort_options',
default='move_name',
required=True,
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,
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',
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',
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',
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',
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',
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()
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()
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()
return self.env["journal.ledger.report.wizard"]._get_group_options()
@api.multi
def compute_data_for_report(self):
@ -85,7 +65,7 @@ class ReportJournalLedger(models.TransientModel):
self._inject_journal_tax_values()
self._update_journal_report_total_values()
if self.group_option == 'none':
if self.group_option == "none":
self._inject_report_tax_values()
# Refresh cache because all data are computed with SQL requests
@ -99,9 +79,7 @@ class ReportJournalLedger(models.TransientModel):
FROM report_journal_ledger_journal
WHERE report_id = %s
"""
params = (
self.id,
)
params = (self.id,)
self.env.cr.execute(sql, params)
sql = """
INSERT INTO report_journal_ledger_journal (
@ -150,9 +128,7 @@ class ReportJournalLedger(models.TransientModel):
FROM report_journal_ledger_move
WHERE report_id = %s
"""
params = (
self.id,
)
params = (self.id,)
self.env.cr.execute(sql, params)
sql = self._get_inject_move_insert()
sql += self._get_inject_move_select()
@ -204,7 +180,7 @@ class ReportJournalLedger(models.TransientModel):
AND
am.date <= %s
"""
if self.move_target != 'all':
if self.move_target != "all":
where_clause += """
AND
am.state = %s
@ -217,22 +193,17 @@ class ReportJournalLedger(models.TransientModel):
order_by = """
ORDER BY
"""
if self.sort_option == 'move_name':
if self.sort_option == "move_name":
order_by += " am.name"
elif self.sort_option == 'date':
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
]
params = [self.env.uid, self.id, self.date_from, self.date_to]
if self.move_target != 'all':
if self.move_target != "all":
params.append(self.move_target)
return tuple(params)
@ -245,9 +216,7 @@ class ReportJournalLedger(models.TransientModel):
FROM report_journal_ledger_move_line
WHERE report_id = %s
"""
params = (
self.id,
)
params = (self.id,)
self.env.cr.execute(sql, params)
sql = """
INSERT INTO report_journal_ledger_move_line (
@ -360,7 +329,7 @@ class ReportJournalLedger(models.TransientModel):
"""
self.env.cr.execute(sql_distinct_tax_id, (self.id,))
rows = self.env.cr.fetchall()
tax_ids = set([row[0] for row in rows])
tax_ids = {row[0] for row in rows}
sql = """
INSERT INTO report_journal_ledger_report_tax_line (
@ -443,9 +412,7 @@ class ReportJournalLedger(models.TransientModel):
FROM report_journal_ledger_journal_tax_line
WHERE report_id = %s
"""
params = (
self.id,
)
params = (self.id,)
self.env.cr.execute(sql, params)
sql_distinct_tax_id = """
SELECT
@ -462,9 +429,9 @@ class ReportJournalLedger(models.TransientModel):
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]
])
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 (
@ -587,26 +554,29 @@ class ReportJournalLedger(models.TransientModel):
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_journal_ledger_xlsx'
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, config=False)
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, config=False)
)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
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)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_journal_ledger"
).render(rcontext)
return result
@api.model
@ -629,183 +599,114 @@ class ReportJournalLedger(models.TransientModel):
class ReportJournalLedgerJournal(models.TransientModel):
_name = 'report_journal_ledger_journal'
_inherit = 'account_financial_report_abstract'
_name = "report_journal_ledger_journal"
_inherit = "account_financial_report_abstract"
name = fields.Char(
required=True,
)
name = fields.Char(required=True,)
code = fields.Char()
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
comodel_name="report_journal_ledger", required=True, ondelete="cascade"
)
journal_id = fields.Many2one(
comodel_name='account.journal',
required=True,
ondelete='cascade',
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',
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,
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',
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'
_inherit = 'account_financial_report_abstract'
_name = "report_journal_ledger_move"
_inherit = "account_financial_report_abstract"
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
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',
comodel_name="report_journal_ledger_journal", required=True, ondelete="cascade",
)
move_id = fields.Many2one(
comodel_name='account.move',
required=True,
ondelete='cascade',
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',
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'
comodel_name="res.company", required=True, ondelete="cascade"
)
class ReportJournalLedgerMoveLine(models.TransientModel):
_name = 'report_journal_ledger_move_line'
_inherit = 'account_financial_report_abstract'
_order = 'partner_id desc, account_id desc'
_name = "report_journal_ledger_move_line"
_inherit = "account_financial_report_abstract"
_order = "partner_id desc, account_id desc"
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
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',
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',
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',
string='Account ID',
comodel_name="account.move.line", required=True, ondelete="cascade",
)
account_id = fields.Many2one(comodel_name="account.account", string="Account ID",)
account = fields.Char()
account_code = fields.Char()
account_type = fields.Char()
partner = fields.Char()
partner_id = fields.Many2one(
comodel_name='res.partner',
string='Partner ID',
)
partner_id = fields.Many2one(comodel_name="res.partner", string="Partner ID",)
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',
)
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'
)
tax_id = fields.Many2one(comodel_name="account.tax")
company_id = fields.Many2one(
comodel_name='res.company',
required=True,
ondelete='cascade'
comodel_name="res.company", required=True, ondelete="cascade"
)
class ReportJournalLedgerReportTaxLine(models.TransientModel):
_name = 'report_journal_ledger_report_tax_line'
_inherit = 'account_financial_report_abstract'
_order = 'tax_code'
_name = "report_journal_ledger_report_tax_line"
_inherit = "account_financial_report_abstract"
_order = "tax_code"
report_id = fields.Many2one(
comodel_name='report_journal_ledger',
required=True,
ondelete='cascade'
)
tax_id = fields.Many2one(
comodel_name='account.tax'
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'
)
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):
@ -820,12 +721,10 @@ class ReportJournalLedgerReportTaxLine(models.TransientModel):
class ReportJournalLedgerJournalTaxLine(models.TransientModel):
_name = 'report_journal_ledger_journal_tax_line'
_inherit = 'report_journal_ledger_report_tax_line'
_order = 'tax_code'
_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',
comodel_name="report_journal_ledger_journal", required=True, ondelete="cascade",
)

202
account_financial_report/report/journal_ledger_xlsx.py

@ -7,82 +7,46 @@ 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'
_name = "report.a_f_r.report_journal_ledger_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('Journal Ledger')
report_name = _("Journal Ledger")
return self._get_report_complete_name(report, report_name)
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
},
{"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.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
}
{"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": _("Currency"),
"field": "currency_id",
"type": "many2one",
"width": 14,
},
{
'header': _('Amount Currency'),
'field': 'amount_currency',
'type': 'amount',
'width': 18
"header": _("Amount Currency"),
"field": "amount_currency",
"type": "amount",
"width": 18,
},
]
@ -93,51 +57,43 @@ class JournalLedgerXslx(models.AbstractModel):
def _get_journal_tax_columns(self, report):
return {
0: {
'header': _('Name'),
'field': 'tax_name',
'width': 35
},
1: {
'header': _('Description'),
'field': 'tax_code',
'width': 18
},
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
"header": _("Base Debit"),
"field": "base_debit",
"type": "amount",
"width": 14,
},
3: {
'header': _('Base Credit'),
'field': 'base_credit',
'type': 'amount',
'width': 14
"header": _("Base Credit"),
"field": "base_credit",
"type": "amount",
"width": 14,
},
4: {
'header': _('Base Balance'),
'field': 'base_balance',
'type': 'amount',
'width': 14
"header": _("Base Balance"),
"field": "base_balance",
"type": "amount",
"width": 14,
},
5: {
'header': _('Tax Debit'),
'field': 'tax_debit',
'type': 'amount',
'width': 14
"header": _("Tax Debit"),
"field": "tax_debit",
"type": "amount",
"width": 14,
},
6: {
'header': _('Tax Credit'),
'field': 'tax_credit',
'type': 'amount',
'width': 14
"header": _("Tax Credit"),
"field": "tax_credit",
"type": "amount",
"width": 14,
},
7: {
'header': _('Tax Balance'),
'field': 'tax_balance',
'type': 'amount',
'width': 14
"header": _("Tax Balance"),
"field": "tax_balance",
"type": "amount",
"width": 14,
},
}
@ -150,80 +106,84 @@ class JournalLedgerXslx(models.AbstractModel):
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()
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()
for value, label in self.env[
"journal.ledger.report.wizard"
]._get_sort_options()
}
return [
[_("Company"), report.company_id.name],
[
_('Company'),
report.company_id.name
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
],
[
_('Date range filter'),
_('From: %s To: %s') % (report.date_from, report.date_to)
],
[
_('Target moves filter'),
_("Target moves filter"),
_("%s") % target_label_by_value[report.move_target],
],
[
_('Entries sorted by'),
_("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
])
]
_("Journals"),
", ".join(
[
"{} - {}".format(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':
if group_option == "journal":
for report_journal in report.report_journal_ledger_ids:
self._generate_journal_content(workbook, report_journal)
elif group_option == 'none':
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_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" % (
sheet_name = "{} ({}) - {}".format(
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)
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)
workbook, report, "Tax Report", report.report_tax_line_ids
)
def _generate_journal_taxes_summary(self, workbook, report_journal):
sheet_name = "Tax - %s (%s) - %s" % (
sheet_name = "Tax - {} ({}) - {}".format(
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)
workbook, report, sheet_name, report_journal.report_tax_line_ids
)
def _generate_moves_content(self, workbook, report, sheet_name, moves):
self.workbook = workbook

217
account_financial_report/report/open_items.py

@ -1,8 +1,7 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api, _
from odoo import _, api, fields, models
class OpenItemsReport(models.TransientModel):
@ -16,47 +15,41 @@ class OpenItemsReport(models.TransientModel):
**** OpenItemsReportMoveLine
"""
_name = 'report_open_items'
_inherit = 'account_financial_report_abstract'
_name = "report_open_items"
_inherit = "account_financial_report_abstract"
# Filters fields, used for data computation
date_at = fields.Date()
only_posted_moves = fields.Boolean()
hide_account_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')
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")
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_open_items_account',
inverse_name='report_id'
comodel_name="report_open_items_account", inverse_name="report_id"
)
class OpenItemsReportAccount(models.TransientModel):
_name = 'report_open_items_account'
_inherit = 'account_financial_report_abstract'
_order = 'code ASC'
_name = "report_open_items_account"
_inherit = "account_financial_report_abstract"
_order = "code ASC"
report_id = fields.Many2one(
comodel_name='report_open_items',
ondelete='cascade',
index=True
comodel_name="report_open_items", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
account_id = fields.Many2one(
'account.account',
index=True
)
account_id = fields.Many2one("account.account", index=True)
# Data fields, used for report display
code = fields.Char()
name = fields.Char()
currency_id = fields.Many2one('res.currency')
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))
@ -64,31 +57,25 @@ class OpenItemsReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_open_items_partner',
inverse_name='report_account_id'
comodel_name="report_open_items_partner", inverse_name="report_account_id"
)
class OpenItemsReportPartner(models.TransientModel):
_name = 'report_open_items_partner'
_inherit = 'account_financial_report_abstract'
_name = "report_open_items_partner"
_inherit = "account_financial_report_abstract"
report_account_id = fields.Many2one(
comodel_name='report_open_items_account',
ondelete='cascade',
index=True
comodel_name="report_open_items_account", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
partner_id = fields.Many2one(
'res.partner',
index=True
)
partner_id = fields.Many2one("res.partner", index=True)
# Data fields, used for report display
name = fields.Char()
currency_id = fields.Many2one('res.currency')
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))
@ -96,8 +83,7 @@ class OpenItemsReportPartner(models.TransientModel):
# Data fields, used to browse report data
move_line_ids = fields.One2many(
comodel_name='report_open_items_move_line',
inverse_name='report_partner_id'
comodel_name="report_open_items_move_line", inverse_name="report_partner_id"
)
@api.model
@ -116,17 +102,15 @@ ORDER BY
class OpenItemsReportMoveLine(models.TransientModel):
_name = 'report_open_items_move_line'
_inherit = 'account_financial_report_abstract'
_name = "report_open_items_move_line"
_inherit = "account_financial_report_abstract"
report_partner_id = fields.Many2one(
comodel_name='report_open_items_partner',
ondelete='cascade',
index=True
comodel_name="report_open_items_partner", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
move_line_id = fields.Many2one('account.move.line')
move_line_id = fields.Many2one("account.move.line")
# Data fields, used for report display
date = fields.Date()
@ -138,7 +122,7 @@ class OpenItemsReportMoveLine(models.TransientModel):
label = fields.Char()
amount_total_due = fields.Float(digits=(16, 2))
amount_residual = fields.Float(digits=(16, 2))
currency_id = fields.Many2one('res.currency')
currency_id = fields.Many2one("res.currency")
amount_total_due_currency = fields.Float(digits=(16, 2))
amount_residual_currency = fields.Float(digits=(16, 2))
@ -148,31 +132,34 @@ class OpenItemsReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_open_items'
_inherit = "report_open_items"
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_open_items_xlsx'
if report_type == "xlsx":
report_name = "a_f_r.report_open_items_xlsx"
else:
report_name = 'account_financial_report.' \
'report_open_items_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
report_name = "account_financial_report." "report_open_items_qweb"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, config=False)
)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
report = self.browse(context.get("active_id"))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_open_items').render(
rcontext)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_open_items"
).render(rcontext)
return result
@api.model
@ -190,9 +177,7 @@ class OpenItemsReportCompute(models.TransientModel):
self._clean_partners_and_accounts()
self._compute_partners_and_accounts_cumul()
if self.hide_account_at_0:
self._clean_partners_and_accounts(
only_delete_account_balance_at_0=True
)
self._clean_partners_and_accounts(only_delete_account_balance_at_0=True)
# Refresh cache because all data are computed with SQL requests
self.invalidate_cache()
@ -271,13 +256,9 @@ FROM
self.company_id.id,
)
if self.filter_account_ids:
query_inject_account_params += (
tuple(self.filter_account_ids.ids),
)
query_inject_account_params += (tuple(self.filter_account_ids.ids),)
if self.filter_partner_ids:
query_inject_account_params += (
tuple(self.filter_partner_ids.ids),
)
query_inject_account_params += (tuple(self.filter_partner_ids.ids),)
query_inject_account_params += (
self.id,
self.env.uid,
@ -287,7 +268,8 @@ FROM
def _inject_partner_values(self):
""" Inject report values for report_open_items_partner. """
# pylint: disable=sql-injection
query_inject_partner = """
query_inject_partner = (
"""
WITH
accounts_partners AS
(
@ -304,7 +286,9 @@ WITH
THEN p.name || ' (' || p.ref || ')'
ELSE p.name
END,
'""" + _('No partner allocated') + """'
'"""
+ _("No partner allocated")
+ """'
) AS partner_name
FROM
report_open_items_account ra
@ -315,6 +299,7 @@ WITH
INNER JOIN
account_move_line ml ON a.id = ml.account_id AND ml.date <= %s
"""
)
if self.only_posted_moves:
query_inject_partner += """
INNER JOIN
@ -361,17 +346,13 @@ FROM
self.id,
)
if self.filter_partner_ids:
query_inject_partner_params += (
tuple(self.filter_partner_ids.ids),
)
query_inject_partner_params += (
self.env.uid,
)
query_inject_partner_params += (tuple(self.filter_partner_ids.ids),)
query_inject_partner_params += (self.env.uid,)
self.env.cr.execute(query_inject_partner, query_inject_partner_params)
def _get_line_sub_query_move_lines(self,
only_empty_partner_line=False,
positive_balance=True):
def _get_line_sub_query_move_lines(
self, only_empty_partner_line=False, positive_balance=True
):
""" Return subquery used to compute sum amounts on lines """
sub_query = """
SELECT
@ -465,15 +446,13 @@ WITH
(
"""
query_inject_move_line += self._get_line_sub_query_move_lines(
only_empty_partner_line=only_empty_partner_line,
positive_balance=True
only_empty_partner_line=only_empty_partner_line, positive_balance=True
)
query_inject_move_line += """
UNION
"""
query_inject_move_line += self._get_line_sub_query_move_lines(
only_empty_partner_line=only_empty_partner_line,
positive_balance=False
only_empty_partner_line=only_empty_partner_line, positive_balance=False
)
query_inject_move_line += """
),
@ -552,9 +531,13 @@ SELECT
END AS partner,
"""
elif only_empty_partner_line:
query_inject_move_line += """
'""" + _('No partner allocated') + """' AS partner,
query_inject_move_line += (
"""
'"""
+ _("No partner allocated")
+ """' AS partner,
"""
)
query_inject_move_line += """
CONCAT_WS(' - ', NULLIF(ml.ref, ''), NULLIF(ml.name, '')) AS label,
ml.balance,
@ -620,15 +603,17 @@ ORDER BY
"""
self.env.cr.execute(
query_inject_move_line,
(self.date_at,
self.date_at,
self.id,
self.date_at,
self.date_at,
self.id,
self.env.uid,
self.id,
self.date_at,)
(
self.date_at,
self.date_at,
self.id,
self.date_at,
self.date_at,
self.id,
self.env.uid,
self.id,
self.date_at,
),
)
def _compute_partners_and_accounts_cumul(self):
@ -667,8 +652,10 @@ WHERE
)
"""
params_compute_partners_residual_cumul = (self.id,)
self.env.cr.execute(query_computer_partner_residual_cumul,
params_compute_partners_residual_cumul)
self.env.cr.execute(
query_computer_partner_residual_cumul,
params_compute_partners_residual_cumul,
)
query_compute_partners_due_cumul = """
UPDATE
@ -698,8 +685,9 @@ WHERE
)
"""
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
self.env.cr.execute(
query_compute_partners_due_cumul, params_compute_partner_due_cumul
)
# Manage currency in partner
query_compute_partners_cur_id_cumul = """
@ -730,8 +718,9 @@ WHERE
)
"""
params_compute_partners_cur_id_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_id_cumul,
params_compute_partners_cur_id_cumul)
self.env.cr.execute(
query_compute_partners_cur_id_cumul, params_compute_partners_cur_id_cumul
)
query_compute_partners_cur_residual_cumul = """
UPDATE
@ -762,8 +751,10 @@ WHERE
)
"""
params_compute_partners_cur_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_residual_cumul,
params_compute_partners_cur_residual_cumul)
self.env.cr.execute(
query_compute_partners_cur_residual_cumul,
params_compute_partners_cur_residual_cumul,
)
query_compute_partners_cur_due_cumul = """
UPDATE
@ -794,8 +785,9 @@ WHERE
)
"""
params_compute_partners_cur_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_due_cumul,
params_compute_partners_cur_due_cumul)
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 = """
@ -815,8 +807,10 @@ WHERE
report_id = %s
"""
params_compute_accounts_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_accounts_residual_cumul,
params_compute_accounts_residual_cumul)
self.env.cr.execute(
query_compute_accounts_residual_cumul,
params_compute_accounts_residual_cumul,
)
query_compute_accounts_cur_residual_cumul = """
UPDATE
@ -836,8 +830,10 @@ 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)
self.env.cr.execute(
query_compute_accounts_cur_residual_cumul,
params_compute_accounts_cur_residual_cumul,
)
query_compute_accounts_due_cumul = """
UPDATE
@ -856,8 +852,9 @@ 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)
self.env.cr.execute(
query_compute_accounts_due_cumul, params_compute_accounts_due_cumul
)
query_compute_accounts_cur_due_cumul = """
UPDATE
@ -877,11 +874,11 @@ 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)
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):
def _clean_partners_and_accounts(self, only_delete_account_balance_at_0=False):
""" Delete empty data for
report_open_items_partner and report_open_items_account.

117
account_financial_report/report/open_items_xlsx.py

@ -6,63 +6,80 @@ from odoo import _, models
class OpenItemsXslx(models.AbstractModel):
_name = 'report.a_f_r.report_open_items_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
_name = "report.a_f_r.report_open_items_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('Open Items')
report_name = _("Open Items")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
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': _('Due date'), 'field': 'date_due', 'width': 11},
7: {'header': _('Original'),
'field': 'amount_total_due',
'type': 'amount',
'width': 14},
8: {'header': _('Residual'),
'field': 'amount_residual',
'field_final_balance': 'final_amount_residual',
'type': 'amount',
'width': 14},
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": _("Due date"), "field": "date_due", "width": 11},
7: {
"header": _("Original"),
"field": "amount_total_due",
"type": "amount",
"width": 14,
},
8: {
"header": _("Residual"),
"field": "amount_residual",
"field_final_balance": "final_amount_residual",
"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},
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 [
[_('Date at filter'), report.date_at],
[_('Target moves filter'),
_('All posted entries') if report.only_posted_moves else _(
'All entries')],
[_('Account balance at 0 filter'),
_('Hide') if report.hide_account_at_0 else _('Show')],
[_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')],
[_("Date at filter"), report.date_at],
[
_("Target moves filter"),
_("All posted entries")
if report.only_posted_moves
else _("All entries"),
],
[
_("Account balance at 0 filter"),
_("Hide") if report.hide_account_at_0 else _("Show"),
],
[
_("Show foreign currency"),
_("Yes") if report.foreign_currency else _("No"),
],
]
def _get_col_count_filter_name(self):
@ -81,7 +98,7 @@ class OpenItemsXslx(models.AbstractModel):
# For each account
for account in report.account_ids:
# Write account title
self.write_array_title(account.code + ' - ' + account.name)
self.write_array_title(account.code + " - " + account.name)
# For each partner
for partner in account.partner_ids:
@ -96,24 +113,24 @@ class OpenItemsXslx(models.AbstractModel):
self.write_line(line)
# Display ending balance line for partner
self.write_ending_balance(partner, 'partner')
self.write_ending_balance(partner, "partner")
# Line break
self.row_pos += 1
# Display ending balance line for account
self.write_ending_balance(account, 'account')
self.write_ending_balance(account, "account")
# 2 lines break
self.row_pos += 2
def write_ending_balance(self, my_object, type_object):
"""Specific function to write ending balance for Open Items"""
if type_object == 'partner':
if type_object == "partner":
name = my_object.name
label = _('Partner ending balance')
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')
elif type_object == "account":
name = my_object.code + " - " + my_object.name
label = _("Ending balance")
super(OpenItemsXslx, self).write_ending_balance(my_object, name, label)

526
account_financial_report/report/templates/aged_partner_balance.xml

@ -1,87 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_aged_partner_balance_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_aged_partner_balance_base"/>
<t
t-call="account_financial_report.report_aged_partner_balance_base"
/>
</t>
</t>
</t>
</template>
<template id="report_aged_partner_balance_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_move_line_details" t-value="o.show_move_line_details"/>
<t t-set="show_move_line_details" t-value="o.show_move_line_details" />
<!-- Defines global variables used by internal layout -->
<t t-set="title">Aged Partner Balance - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="title">Aged Partner Balance - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
<h4
class="mt0"
t-esc="title or 'Odoo Report'"
style="text-align: center;"
/>
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_aged_partner_balance_filters"/>
<t t-call="account_financial_report.report_aged_partner_balance_filters" />
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;"/>
<div class="act_as_caption account_title"
style="width: 100%;">
<span t-field="account.code"/>
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%;">
<span t-field="account.code" />
-
<span t-field="account.name"/>
<span t-field="account.name" />
</div>
<!-- Display account lines -->
<t t-if="not show_move_line_details">
<div class="act_as_table data_table"
style="width: 100%;">
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display account header -->
<t t-call="account_financial_report.report_aged_partner_balance_lines_header"/>
<t
t-call="account_financial_report.report_aged_partner_balance_lines_header"
/>
<t t-foreach="account.partner_ids" t-as="partner">
<!-- Display one line per partner -->
<t t-call="account_financial_report.report_aged_partner_balance_lines"/>
<t
t-call="account_financial_report.report_aged_partner_balance_lines"
/>
</t>
</div>
<!-- Display account footer -->
<t t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"/>
<t
t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"
/>
</t>
<!-- Display account move lines -->
<t t-if="show_move_line_details">
<!-- Display account partners -->
<t t-foreach="account.partner_ids" t-as="partner">
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title">
<span t-field="partner.name"/>
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report.report_aged_partner_balance_move_lines"/>
<t
t-call="account_financial_report.report_aged_partner_balance_move_lines"
/>
<!-- Display partner footer -->
<t t-call="account_financial_report.report_aged_partner_balance_partner_ending_cumul">
<t t-set="partner_cumul_line" t-value="partner.line_ids"/>
<t
t-call="account_financial_report.report_aged_partner_balance_partner_ending_cumul"
>
<t
t-set="partner_cumul_line"
t-value="partner.line_ids"
/>
</t>
</div>
</t>
<!-- Display account footer -->
<t t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"/>
<t
t-call="account_financial_report.report_aged_partner_balance_account_ending_cumul"
/>
</t>
</div>
</t>
</div>
</template>
<template id="report_aged_partner_balance_filters">
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_row labels">
@ -90,7 +98,7 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-field="o.date_at"/>
<span t-field="o.date_at" />
</div>
<div class="act_as_cell">
<t t-if="o.only_posted_moves">All posted entries</t>
@ -99,7 +107,6 @@
</div>
</div>
</template>
<template id="report_aged_partner_balance_lines_header">
<!-- Display table headers for lines -->
<div class="act_as_thead">
@ -123,7 +130,6 @@
</div>
</div>
</template>
<template id="report_aged_partner_balance_lines">
<!-- Display each lines -->
<t t-foreach="partner.line_ids" t-as="line">
@ -131,40 +137,60 @@
<div class="act_as_row lines">
<!--## partner-->
<div class="act_as_cell left">
<span t-field="line.partner"/>
<span t-field="line.partner" />
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span t-field="line.amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount">
<span t-field="line.current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount">
<span t-field="line.age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount">
<span t-field="line.age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount">
<span t-field="line.age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount">
<span t-field="line.age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount">
<span t-field="line.older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</div>
</t>
</template>
<template id="report_aged_partner_balance_move_lines">
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display table headers for move lines -->
@ -216,180 +242,263 @@
<!--## date-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;">
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}"/></a>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}" />
</a>
</span>
</div>
<!--## move-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="'account.move'"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.entry"/></a>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="'account.move'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="'account.journal'"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.journal"/></a>
<a
t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="'account.journal'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.journal" />
</a>
</span>
</div>
<!--## account code-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="'account.account'"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.account"/></a>
<a
t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="'account.account'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.account" />
</a>
</span>
</div>
<!--## partner-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="'res.partner'"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.partner"/></a>
<a
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="'res.partner'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.label"/></a>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.label" />
</a>
</span>
</div>
<!--## date_due-->
<div class="act_as_cell left">
<span>
<a t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;">
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date_due" t-options="{'widget': 'date'}"/></a>
<a
t-att-data-active-id="line.move_line_id.id"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<!--## We don't use t-field because it throws an error on click -->
<t
t-esc="line.date_due"
t-options="{'widget': 'date'}"
/>
</a>
</span>
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<!--## current-->
<div class="act_as_cell amount">
<t t-if="line.current != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.current == 0">
<span t-field="line.current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount">
<t t-if="line.age_30_days != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_30_days == 0">
<span t-field="line.age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount">
<t t-if="line.age_60_days != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_60_days == 0">
<span t-field="line.age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount">
<t t-if="line.age_90_days != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_90_days == 0">
<span t-field="line.age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount">
<t t-if="line.age_120_days != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.age_120_days == 0">
<span t-field="line.age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
<!--## older-->
<div class="act_as_cell amount">
<t t-if="line.older != 0">
<span>
<a t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;">
<t t-raw="line.older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<a
t-att-data-domain="[('id', 'in', (line.move_line_id | line.move_line_id.matched_debit_ids.mapped('debit_move_id') | line.move_line_id.matched_credit_ids.mapped('credit_move_id')).ids)]"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
style="color: black;"
>
<t
t-raw="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
<t t-if="line.older == 0">
<span t-field="line.older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</t>
</div>
</div>
</t>
</div>
</template>
<template id="report_aged_partner_balance_partner_ending_cumul">
<!-- Display ending balance line for partner -->
<div class="act_as_table list_table" style="width: 100%;">
@ -398,39 +507,59 @@
<div class="act_as_cell right" style="width: 52.00%;">Partner
cumul aged balance</div>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.00%;"/>
<div class="act_as_cell" style="width: 6.00%;" />
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%;">
<span t-field="partner_cumul_line.older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="partner_cumul_line.older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</div>
</div>
</template>
<template id="report_aged_partner_balance_account_ending_cumul">
<!-- Display ending balance line for account -->
<div class="act_as_table list_table" style="width: 100%;">
@ -440,65 +569,107 @@
<div class="act_as_cell right" style="width: 32.52%;">Total</div>
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 9.64%;">
<span t-field="account.cumul_older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</t>
<t t-if="show_move_line_details">
<!--## total-->
<div class="act_as_cell right" style="width: 52.00%;">Total</div>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.00%;"/>
<div class="act_as_cell" style="width: 6.00%;" />
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_current" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_current"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_age_30_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_30_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_age_60_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_60_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_age_90_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_90_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_age_120_days" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_age_120_days"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%">
<span t-field="account.cumul_older" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account.cumul_older"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
</t>
</div>
@ -508,25 +679,37 @@
<div class="act_as_cell right" style="width: 32.52%;">
Percents</div>
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 9.64%;"/>
<div class="act_as_cell amount" style="width: 9.64%;" />
<!--## current-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_current"/>%
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_current"
/>%
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_age_30_days"/>%
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_age_30_days"
/>%
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_age_60_days"/>%
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_age_60_days"
/>%
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_age_90_days"/>%
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_age_90_days"
/>%
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_age_120_days"/>
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_age_120_days"
/>
%
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 9.64%;"><span t-field="account.percent_older"/>%
<div class="act_as_cell amount" style="width: 9.64%;"><span
t-field="account.percent_older"
/>%
</div>
</t>
<t t-if="show_move_line_details">
@ -534,30 +717,41 @@
<div class="act_as_cell right" style="width: 52.00%;">
Percents</div>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.00%;"/>
<div class="act_as_cell" style="width: 6.00%;" />
<!--## amount_residual-->
<div class="act_as_cell amount" style="width: 6.00%"/>
<div class="act_as_cell amount" style="width: 6.00%" />
<!--## current-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_current"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_current"
/>%
</div>
<!--## age_30_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_age_30_days"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_age_30_days"
/>%
</div>
<!--## age_60_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_age_60_days"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_age_60_days"
/>%
</div>
<!--## age_90_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_age_90_days"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_age_90_days"
/>%
</div>
<!--## age_120_days-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_age_120_days"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_age_120_days"
/>%
</div>
<!--## older-->
<div class="act_as_cell amount" style="width: 6.00%"><span t-field="account.percent_older"/>%
<div class="act_as_cell amount" style="width: 6.00%"><span
t-field="account.percent_older"
/>%
</div>
</t>
</div>
</div>
</template>
</odoo>

622
account_financial_report/report/templates/general_ledger.xml

@ -1,81 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_general_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_general_ledger_base"/>
<t t-call="account_financial_report.report_general_ledger_base" />
</t>
</t>
</t>
</template>
<template id="report_general_ledger_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="show_analytic_tags" t-value="o.show_analytic_tags"/>
<t t-set="show_cost_center" t-value="o.show_cost_center"/>
<t t-set="foreign_currency" t-value="o.foreign_currency"/>
<t t-set="show_analytic_tags" t-value="o.show_analytic_tags" />
<t t-set="show_cost_center" t-value="o.show_cost_center" />
<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-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="title">General Ledger - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
<h4
class="mt0"
t-esc="title or 'Odoo Report'"
style="text-align: center;"
/>
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_general_ledger_filters"/>
<t t-call="account_financial_report.report_general_ledger_filters" />
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;"/>
<div class="act_as_caption account_title"
style="width: 100%">
<span t-field="account.code"/> - <span t-field="account.name"/>
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="act_as_caption account_title" style="width: 100%">
<span t-field="account.code" /> - <span
t-field="account.name"
/>
</div>
<t t-if="not account.partner_ids">
<!-- Display account move lines without partner regroup -->
<t t-set="type" t-value='"account_type"'/>
<t t-call="account_financial_report.report_general_ledger_lines">
<t t-set="account_or_partner_object" t-value="account"/>
<t t-set="type" t-value='"account_type"' />
<t
t-call="account_financial_report.report_general_ledger_lines"
>
<t t-set="account_or_partner_object" t-value="account" />
</t>
</t>
<t t-if="account.partner_ids">
<!-- Display account partners -->
<t t-foreach="account.partner_ids" t-as="partner">
<t t-set="type" t-value='"partner_type"'/>
<t t-set="type" t-value='"partner_type"' />
<div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title">
<span t-field="partner.name"/>
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report.report_general_ledger_lines">
<t t-set="account_or_partner_object" t-value="partner"/>
<t
t-call="account_financial_report.report_general_ledger_lines"
>
<t
t-set="account_or_partner_object"
t-value="partner"
/>
</t>
<!-- Display partner footer -->
<t t-call="account_financial_report.report_general_ledger_ending_cumul">
<t t-set="account_or_partner_object" t-value="partner"/>
<t t-set="type" t-value='"partner_type"'/>
<t
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t
t-set="account_or_partner_object"
t-value="partner"
/>
<t t-set="type" t-value='"partner_type"' />
</t>
</div>
</t>
</t>
<!-- Display account footer -->
<t t-if="not o.filter_partner_ids" t-call="account_financial_report.report_general_ledger_ending_cumul">
<t t-set="account_or_partner_object" t-value="account"/>
<t t-set="type" t-value='"account_type"'/>
<t
t-if="not o.filter_partner_ids"
t-call="account_financial_report.report_general_ledger_ending_cumul"
>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</div>
</t>
</div>
</template>
<template id="account_financial_report.report_general_ledger_filters">
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_row labels">
@ -87,7 +101,9 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
From: <span t-field="o.date_from"/> To: <span t-field="o.date_to"/>
From: <span t-field="o.date_from" /> To: <span
t-field="o.date_to"
/>
</div>
<div class="act_as_cell">
<t t-if="o.only_posted_moves">All posted entries</t>
@ -108,10 +124,8 @@
</div>
</div>
</template>
<template id="account_financial_report.report_general_ledger_lines">
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
@ -148,411 +162,565 @@
<!--## credit-->
<div class="act_as_cell amount" style="width: 6.02%;">Credit</div>
<!--## balance cumulated-->
<div class="act_as_cell amount" style="width: 6.02%;">Cumul. Bal.</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>
<div
class="act_as_cell amount"
style="width: 5.19%;"
>Amount cur.</div>
</t>
</div>
</div>
<!-- Display first line with initial balance -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## move-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## journal-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## account code-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## taxes-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## partner-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## ref - label-->
<div class="act_as_cell amount">Initial balance</div>
<t t-if="show_cost_center">
<!--## cost_center-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
</t>
<t t-if="show_analytic_tags">
<!--## analytic tags-->
<div class="act_as_cell"></div>
<div class="act_as_cell" />
</t>
<!--## matching_number-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## debit-->
<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),
<t
t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
('debit', '&lt;&gt;', 0)]"
/>
<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_debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.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),
<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.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
('debit', '&lt;&gt;', 0)]"
/>
<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_debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
</div>
<!--## credit-->
<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),
<t
t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
('credit', '&lt;&gt;', 0)]"
/>
<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_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.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),
<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.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
('credit', '&lt;&gt;', 0)]"
/>
<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_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_credit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
</div>
<!--## balance cumulated-->
<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),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<t
t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"
/>
<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" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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"
t-options="{'widget': 'monetary', 'display_currency': res_company.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),
<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.strftime('%Y-%m-%d'))]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"
/>
<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" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</t>
</div>
<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"/>
<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)]"/>
<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>
<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),
<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)]"/>
('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>
<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%;"/>
<div class="act_as_cell" style="width: 2.08%;" />
<div class="act_as_cell" style="width: 5.19%;" />
</t>
</t>
</div>
<!-- Display each lines -->
<t t-foreach="account_or_partner_object.move_line_ids" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move.line'"/>
<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;">
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}"/></a>
<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;"
>
<!--## We don't use t-field because it throws an error on click -->
<t t-esc="line.date" t-options="{'widget': 'date'}" />
</a>
</span>
</div>
<!--## move-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move'"/>
<t t-set="res_model" t-value="'account.move'" />
<span>
<a t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.entry"/></a>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.journal'"/>
<t t-set="res_model" t-value="'account.journal'" />
<span>
<a t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.journal"/></a>
<a
t-att-data-active-id="line.move_line_id.move_id.journal_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.journal" />
</a>
</span>
</div>
<!--## account code-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.account'"/>
<t t-set="res_model" t-value="'account.account'" />
<span>
<a t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.account"/></a>
<a
t-att-data-active-id="line.move_line_id.account_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.account" />
</a>
</span>
</div>
<!--## taxes-->
<div class="act_as_cell left"><span t-field="line.taxes_description"/></div>
<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'"/>
<t t-set="res_model" t-value="'res.partner'" />
<span t-if="line.partner">
<a t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"><t t-raw="line.partner"/></a>
<a
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move.line'"/>
<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.label"/></a>
<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.label" />
</a>
</span>
</div>
<!--## 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"
class="o_account_financial_reports_web_action"
style="color: black;"><t t-raw="line.cost_center"/></a>
<a
t-att-data-active-id="line.move_line_id.analytic_account_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.cost_center" />
</a>
</span>
</div>
</t>
<t t-if="show_analytic_tags">
<!--## analytic tags-->
<div class="act_as_cell left"><span t-field="line.tags"/></div>
<div class="act_as_cell left">
<span t-field="line.tags" />
</div>
</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"
class="o_account_financial_reports_web_action"
style="color: black;"><t t-raw="line.matching_number"/></a>
<a
t-att-data-active-id="line.move_line_id.full_reconcile_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.matching_number" />
</a>
</span>
</div>
<!--## debit-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'"/>
<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_monetary"
style="color: black;">
<t t-raw="line.debit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_monetary"
style="color: black;"
>
<t
t-raw="line.debit"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<!--## credit-->
<div class="act_as_cell amount">
<t t-set="res_model" t-value="'account.move.line'"/>
<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_monetary"
style="color: black;">
<t t-raw="line.credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_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'"/>
<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_monetary"
style="color: black;">
<t t-raw="line.cumul_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
<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_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="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"/>
<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'"/>
<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>
<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%;"/>
<div class="act_as_cell amount" style="width: 2.08%;" />
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 5.19%;"/>
<div class="act_as_cell amount" style="width: 5.19%;" />
</t>
</t>
</div>
</t>
</div>
</template>
<template id="account_financial_report.report_general_ledger_ending_cumul">
<!-- Display ending balance line for account or partner -->
<div class="act_as_table list_table" style="width: 100%;">
<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: 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: 22.9%;">Ending balance</div>
<div class="act_as_cell first_column" 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: 22.9%;"
>Ending balance</div>
</t>
<t t-if='type == "partner_type"'>
<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>
<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.03%"/>
<div class="act_as_cell" style="width: 8.03%" />
</t>
<t t-if="show_analytic_tags">
<!--## analytic tags-->
<div class="act_as_cell" style="width: 4.75%;"></div>
<div class="act_as_cell" style="width: 4.75%;" />
</t>
<!--## matching_number-->
<div class="act_as_cell" style="width: 2.41%;"/>
<div class="act_as_cell" style="width: 2.41%;" />
<!--## debit-->
<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}"/>
<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.02%;">
<span t-field="account_or_partner_object.final_credit" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<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.02%;">
<span t-field="account_or_partner_object.final_balance" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="account_or_partner_object.final_balance"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## currency_name + amount_currency-->
<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"/>
<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)]"/>
<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>
<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),
<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)]"/>
('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>
<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%;"/>
<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>
</odoo>

474
account_financial_report/report/templates/journal_ledger.xml

@ -1,70 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="report_journal_ledger_qweb">
<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-call="account_financial_report.report_journal_ledger_base" />
</t>
</t>
</t>
</template>
<template id="report_journal_ledger_base">
<t t-set="display_currency" t-value="o.foreign_currency"/>
<t t-set="display_account_name" t-value="o.with_account_name"/>
<t t-set="title">Journal Ledger - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="display_currency" t-value="o.foreign_currency" />
<t t-set="display_account_name" t-value="o.with_account_name" />
<t t-set="title">Journal Ledger - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
<h4
class="mt0"
t-esc="title or 'Odoo Report'"
style="text-align: center;"
/>
</div>
<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"/>
<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/>
<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 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-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 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_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
<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-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 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">
@ -82,384 +96,302 @@
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%;">
<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%;">
<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">
<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%;">
<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">
<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%;">
<div class="act_as_cell" name="taxes" style="width: 7.57%;">
Taxes
</div>
<div class="act_as_cell"
name="debit"
style="width: 8.65%;">
<div class="act_as_cell" name="debit" style="width: 8.65%;">
Debit
</div>
<div class="act_as_cell"
name="credit"
style="width: 8.65%;">
<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%;">
<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%;">
<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 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 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 class="act_as_cell" name="currency_name">
</div>
<div class="act_as_cell amount"
name="amount_currency">
<div class="act_as_cell amount" name="amount_currency">
</div>
</t>
</div>
<div style="width: 100%"/>
<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-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"/>
<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 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 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"/>
<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 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 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 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 class="act_as_cell left" name="taxes">
<span t-field="move_line.taxes_description" />
</div>
<div class="act_as_cell amount"
name="debit">
<div class="act_as_cell amount" name="debit">
<t t-if="move_line.debit">
<span t-field="move_line.debit"/>
<span t-field="move_line.debit" />
</t>
</div>
<div class="act_as_cell amount"
name="credit">
<div class="act_as_cell amount" name="credit">
<t t-if="move_line.credit">
<span t-field="move_line.credit"/>
<span t-field="move_line.credit" />
</t>
</div>
<t t-if="display_currency">
<div class="act_as_cell"
name="currency_name">
<div class="act_as_cell" name="currency_name">
<t t-if="move_line.currency_name">
<span t-field="move_line.currency_name"/>
<span t-field="move_line.currency_name" />
</t>
</div>
<div class="act_as_cell amount"
name="amount_currency">
<div class="act_as_cell amount" name="amount_currency">
<t t-if="move_line.amount_currency">
<span t-field="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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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>
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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%;">
<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>
<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>

24
account_financial_report/report/templates/layouts.xml

@ -1,26 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="account_financial_report.internal_layout">
<div class="article">
<link href="/account_financial_report/static/src/css/report.css" rel="stylesheet"/>
<t t-raw="0" />
<link
href="/account_financial_report/static/src/css/report.css"
rel="stylesheet"
/>
<t t-raw="0" />
</div>
<div class="footer">
<div class="row">
<div class="col-6 custom_footer">
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>
<span
t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"
/>
</div>
<div class="col-6 text-right custom_footer">
<ul class="list-inline">
<li class="list-inline-item"><span class="page"/></li>
<li class="list-inline-item">
<span class="page" />
</li>
<li class="list-inline-item">/</li>
<li class="list-inline-item"><span class="topage"/></li>
<li class="list-inline-item">
<span class="topage" />
</li>
</ul>
</div>
</div>
</div>
</template>
</odoo>

180
account_financial_report/report/templates/open_items.xml

@ -1,69 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="account_financial_report.report_open_items_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_open_items_base"/>
<t t-call="account_financial_report.report_open_items_base" />
</t>
</t>
</t>
</template>
<template id="account_financial_report.report_open_items_base">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="foreign_currency" t-value="o.foreign_currency"/>
<t t-set="foreign_currency" t-value="o.foreign_currency" />
<!-- Defines global variables used by internal layout -->
<t t-set="title">Open Items - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="title">Open Items - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
<h4
class="mt0"
t-esc="title or 'Odoo Report'"
style="text-align: center;"
/>
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_open_items_filters"/>
<t t-call="account_financial_report.report_open_items_filters" />
<t t-foreach="o.account_ids" t-as="account">
<div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;" />
<div class="account_title"
style="width: 100%;">
<span t-field="account.code"/>
<div class="account_title" style="width: 100%;">
<span t-field="account.code" />
-
<span t-field="account.name"/>
<span t-field="account.name" />
</div>
<!-- Display account partners -->
<t t-foreach="account.partner_ids" t-as="partner">
<div class="page_break">
<!-- Display partner header -->
<div class="account_title">
<span t-field="partner.name"/>
<span t-field="partner.name" />
</div>
<!-- Display partner move lines -->
<t t-call="account_financial_report.report_open_items_lines"/>
<t
t-call="account_financial_report.report_open_items_lines"
/>
<!-- Display partner footer -->
<t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_object" t-value="partner"/>
<t t-set="type" t-value='"partner_type"'/>
<t
t-call="account_financial_report.report_open_items_ending_cumul"
>
<t
t-set="account_or_partner_object"
t-value="partner"
/>
<t t-set="type" t-value='"partner_type"' />
</t>
</div>
</t>
<!-- Display account footer -->
<t t-call="account_financial_report.report_open_items_ending_cumul">
<t t-set="account_or_partner_object" t-value="account"/>
<t t-set="type" t-value='"account_type"'/>
<t t-set="account_or_partner_object" t-value="account" />
<t t-set="type" t-value='"account_type"' />
</t>
</div>
</t>
</div>
</template>
<template id="account_financial_report.report_open_items_filters">
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_row labels">
@ -73,7 +77,7 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-field="o.date_at"/>
<span t-field="o.date_at" />
</div>
<div class="act_as_cell">
<t t-if="o.only_posted_moves">All posted entries</t>
@ -86,7 +90,6 @@
</div>
</div>
</template>
<template id="account_financial_report.report_open_items_lines">
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display table headers for lines -->
@ -119,98 +122,118 @@
<!--## 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>
<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>
<div
class="act_as_cell amount"
style="width: 6.57%;"
>Cur. Residual</div>
</t>
</div>
</div>
<!-- Display each lines -->
<t t-foreach="partner.move_line_ids" t-as="line">
<!-- # lines or centralized lines -->
<div class="act_as_row lines">
<!--## date-->
<div class="act_as_cell left">
<span t-field="line.date"/>
<span t-field="line.date" />
</div>
<!--## move-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'account.move'"/>
<t t-set="res_model" t-value="'account.move'" />
<span>
<a t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.entry"/>
<a
t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.entry" />
</a>
</span>
</div>
<!--## journal-->
<div class="act_as_cell left">
<span t-field="line.journal"/>
<span t-field="line.journal" />
</div>
<!--## account code-->
<div class="act_as_cell left">
<span t-field="line.account"/>
<span t-field="line.account" />
</div>
<!--## partner-->
<div class="act_as_cell left">
<t t-set="res_model" t-value="'res.partner'"/>
<t t-set="res_model" t-value="'res.partner'" />
<span t-if="line.partner">
<a t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.partner"/>
<a
t-att-data-active-id="line.move_line_id.partner_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
style="color: black;"
>
<t t-raw="line.partner" />
</a>
</span>
</div>
<!--## ref - label-->
<div class="act_as_cell left">
<span t-field="line.label"/>
<span t-field="line.label" />
</div>
<!--## date_due-->
<div class="act_as_cell left">
<span t-field="line.date_due"/>
<span t-field="line.date_due" />
</div>
<!--## amount_total_due-->
<div class="act_as_cell amount">
<span t-field="line.amount_total_due" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.amount_total_due"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<!--## amount_residual-->
<div class="act_as_cell amount">
<span t-field="line.amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<span
t-field="line.amount_residual"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</div>
<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"/>
<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}"/>
<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}"/>
<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"/>
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
</t>
</t>
</div>
</t>
</div>
</template>
<template id="account_financial_report.report_open_items_ending_cumul">
<!-- Display ending balance line for account or partner -->
<div class="act_as_table list_table" style="width: 100%;">
@ -218,54 +241,65 @@
<!--## date-->
<t t-if='type == "account_type"'>
<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.code" />
-
<span t-field="account_or_partner_object.name"/>
<span t-field="account_or_partner_object.name" />
</div>
<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: 36.34%;"/>
<div class="act_as_cell right"
style="width: 28.66%;">Partner ending balance</div>
<div class="act_as_cell first_column" style="width: 36.34%;" />
<div
class="act_as_cell right"
style="width: 28.66%;"
>Partner ending balance</div>
</t>
<!--## date_due-->
<div class="act_as_cell" style="width: 6.47%;"/>
<div class="act_as_cell" style="width: 6.47%;" />
<!--## amount_total_due-->
<div class="act_as_cell amount" style="width: 6.57%;"/>
<div class="act_as_cell amount" style="width: 6.57%;" />
<!--## amount_currency-->
<div class="act_as_cell amount" style="width: 6.57%;">
<span t-field="account_or_partner_object.final_amount_residual" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
<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 -->
<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"/>
<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}"/>
<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}"/>
<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"/>
<div class="act_as_cell" />
<!--## amount_total_due_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
<!--## amount_residual_currency-->
<div class="act_as_cell"/>
<div class="act_as_cell" />
</t>
</t>
</div>
</div>
</template>
</odoo>

944
account_financial_report/report/templates/trial_balance.xml
File diff suppressed because it is too large
View File

179
account_financial_report/report/templates/vat_report.xml

@ -1,32 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<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 t-call="account_financial_report.report_vat_report_base"/>
<t t-call="account_financial_report.report_vat_report_base" />
</t>
</t>
</t>
</template>
<template id="account_financial_report.report_vat_report_base">
<t t-set="title">VAT Report - <t t-raw="o.company_id.name"/> - <t t-raw="o.company_id.currency_id.name"/></t>
<t t-set="company_name" t-value="o.company_id.name"/>
<t t-set="title">VAT Report - <t t-raw="o.company_id.name" /> - <t
t-raw="o.company_id.currency_id.name"
/></t>
<t t-set="company_name" t-value="o.company_id.name" />
<div class="page">
<div class="row">
<h4 class="mt0" t-esc="title or 'Odoo Report'" style="text-align: center;"/>
<h4
class="mt0"
t-esc="title or 'Odoo Report'"
style="text-align: center;"
/>
</div>
<!-- Display filters -->
<t t-call="account_financial_report.report_vat_report_filters"/>
<div class="page_break"/>
<t t-call="account_financial_report.report_vat_report_filters" />
<div class="page_break" />
<div class="act_as_table data_table" style="width: 100%;">
<!-- Display table headers for lines -->
<div class="act_as_thead">
<div class="act_as_row labels">
<!--## code-->
<div class="act_as_cell first_column" style="width: 5%;">Code</div>
<div
class="act_as_cell first_column"
style="width: 5%;"
>Code</div>
<!--## name-->
<div class="act_as_cell" style="width: 65%;">Name</div>
<!--## net-->
@ -35,105 +42,156 @@
<div class="act_as_cell" style="width: 15%;">Tax</div>
</div>
</div>
<t t-foreach="o.taxtags_ids" t-as="tag">
<div class="act_as_row lines" style="font-weight: bold;">
<t t-if="tag.taxtag_id">
<t t-set="res_model" t-value="'account.account.tag'"/>
<t t-set="res_id" t-value="tag.taxtag_id.id"/>
<t t-set="res_model" t-value="'account.account.tag'" />
<t t-set="res_id" t-value="tag.taxtag_id.id" />
</t>
<t t-if="tag.taxgroup_id">
<t t-set="res_model" t-value="'account.tax.group'"/>
<t t-set="res_id" t-value="tag.taxgroup_id.id"/>
<t t-set="res_model" t-value="'account.tax.group'" />
<t t-set="res_id" t-value="tag.taxgroup_id.id" />
</t>
<div class="act_as_cell left oe_tooltip_string" style="width: 5%;">
<div
class="act_as_cell left oe_tooltip_string"
style="width: 5%;"
>
<span>
<a t-att-data-active-id="res_id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style">
<t t-att-style="style" t-raw="tag.code"/></a>
<a
t-att-data-active-id="res_id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"
>
<t t-att-style="style" t-raw="tag.code" />
</a>
</span>
</div>
<div class="act_as_cell left oe_tooltip_string" style="width: 65%;">
<div
class="act_as_cell left oe_tooltip_string"
style="width: 65%;"
>
<span>
<a t-att-data-active-id="res_id"
<a
t-att-data-active-id="res_id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"><t t-att-style="style" t-raw="tag.name"/></a>
t-att-style="style"
>
<t t-att-style="style" t-raw="tag.name" />
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t t-set="domain"
t-value="[('tax_ids', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
<t
t-set="domain"
t-value="[('tax_ids', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to)]"/>
('date', '&lt;=', o.date_to)]"
/>
<span>
<a t-att-data-domain="domain"
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style">
<t t-att-style="style" t-raw="tag.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tag.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t t-set="domain"
t-value="[('tax_line_id', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
<t
t-set="domain"
t-value="[('tax_line_id', 'in', [tax.tax_id.id for tax in tag.tax_ids]),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"/>
('tax_exigible', '=', True)]"
/>
<span>
<a t-att-data-domain="domain"
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style">
<t t-att-style="style" t-raw="tag.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tag.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
</div>
<t t-if="o.tax_detail">
<t t-foreach="tag.tax_ids" t-as="tax">
<t t-set="res_model" t-value="'account.tax'"/>
<t t-set="res_model" t-value="'account.tax'" />
<div class="act_as_row lines">
<div class="act_as_cell" style="width: 5%;"/>
<div class="act_as_cell left oe_tooltip_string" style="padding-left: 20px; width: 65%;">
<div class="act_as_cell" style="width: 5%;" />
<div
class="act_as_cell left oe_tooltip_string"
style="padding-left: 20px; width: 65%;"
>
<span>
<a t-att-data-active-id="tax.tax_id.id"
<a
t-att-data-active-id="tax.tax_id.id"
t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action"
t-att-style="style"><t t-att-style="style" t-raw="tax.name"/></a>
t-att-style="style"
>
<t t-att-style="style" t-raw="tax.name" />
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t t-set="domain"
t-value="[('tax_ids', 'in', tax.tax_id.ids),
<t
t-set="domain"
t-value="[('tax_ids', 'in', tax.tax_id.ids),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"/>
('tax_exigible', '=', True)]"
/>
<span>
<a t-att-data-domain="domain"
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style">
<t t-att-style="style" t-raw="tax.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tax.net"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
<div class="act_as_cell amount" style="width: 15%;">
<t t-set="domain"
t-value="[('tax_line_id', '=', tax.tax_id.id),
<t
t-set="domain"
t-value="[('tax_line_id', '=', tax.tax_id.id),
('date', '&gt;=', o.date_from),
('date', '&lt;=', o.date_to),
('tax_exigible', '=', True)]"/>
('tax_exigible', '=', True)]"
/>
<span>
<a t-att-data-domain="domain"
<a
t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
class="o_account_financial_reports_web_action_multi"
t-att-style="style">
<t t-att-style="style" t-raw="tax.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/></a>
t-att-style="style"
>
<t
t-att-style="style"
t-raw="tax.tax"
t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"
/>
</a>
</span>
</div>
</div>
@ -143,7 +201,6 @@
</div>
</div>
</template>
<template id="account_financial_report.report_vat_report_filters">
<div class="act_as_table data_table" style="width: 100%;">
<div class="act_as_row labels">
@ -153,13 +210,13 @@
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-field="o.date_from"/>
<span t-field="o.date_from" />
</div>
<div class="act_as_cell">
<span t-field="o.date_to"/>
<span t-field="o.date_to" />
</div>
<div class="act_as_cell">
<span t-field="o.based_on"/>
<span t-field="o.based_on" />
</div>
</div>
</div>

245
account_financial_report/report/trial_balance.py

@ -2,7 +2,7 @@
# © 2018 Forest and Biomass Romania SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo import api, fields, models
from odoo.tools import float_is_zero
@ -17,8 +17,8 @@ class TrialBalanceReport(models.TransientModel):
If "show_partner_details" is selected
"""
_name = 'report_trial_balance'
_inherit = 'account_financial_report_abstract'
_name = "report_trial_balance"
_inherit = "account_financial_report_abstract"
# Filters fields, used for data computation
date_from = fields.Date()
@ -27,84 +27,71 @@ class TrialBalanceReport(models.TransientModel):
only_posted_moves = fields.Boolean()
hide_account_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')
filter_journal_ids = fields.Many2many(comodel_name='account.journal')
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")
filter_journal_ids = fields.Many2many(comodel_name="account.journal")
show_partner_details = fields.Boolean()
hierarchy_on = fields.Selection(
[('computed', 'Computed Accounts'),
('relation', 'Child Accounts'),
('none', 'No hierarchy')],
string='Hierarchy On',
[
("computed", "Computed Accounts"),
("relation", "Child Accounts"),
("none", "No hierarchy"),
],
string="Hierarchy On",
required=True,
default='computed',
default="computed",
help="""Computed Accounts: Use when the account group have codes
that represent prefixes of the actual accounts.\n
Child Accounts: Use when your account groups are hierarchical.\n
No hierarchy: Use to display just the accounts, without any grouping.
""",
)
limit_hierarchy_level = fields.Boolean('Limit hierarchy levels')
show_hierarchy_level = fields.Integer('Hierarchy Levels to display',
default=1)
limit_hierarchy_level = fields.Boolean("Limit hierarchy levels")
show_hierarchy_level = fields.Integer("Hierarchy Levels to display", default=1)
hide_parent_hierarchy_level = fields.Boolean(
'Do not display parent levels', default=False)
"Do not display parent levels", default=False
)
# General Ledger Report Data fields,
# used as base for compute the data reports
general_ledger_id = fields.Many2one(
comodel_name='report_general_ledger'
)
general_ledger_id = fields.Many2one(comodel_name="report_general_ledger")
# Data fields, used to browse report data
account_ids = fields.One2many(
comodel_name='report_trial_balance_account',
inverse_name='report_id'
comodel_name="report_trial_balance_account", inverse_name="report_id"
)
class TrialBalanceReportAccount(models.TransientModel):
_name = 'report_trial_balance_account'
_inherit = 'account_financial_report_abstract'
_order = 'sequence, code ASC, name'
_name = "report_trial_balance_account"
_inherit = "account_financial_report_abstract"
_order = "sequence, code ASC, name"
report_id = fields.Many2one(
comodel_name='report_trial_balance',
ondelete='cascade',
index=True
comodel_name="report_trial_balance", ondelete="cascade", index=True
)
hide_line = fields.Boolean(compute='_compute_hide_line')
hide_line = fields.Boolean(compute="_compute_hide_line")
# Data fields, used to keep link with real object.
# Sequence is a Char later built with 'code_prefix' for groups
# and code_prefix + account code for accounts
sequence = fields.Char(index=True, default='1')
sequence = fields.Char(index=True, default="1")
level = fields.Integer(index=True, default=1)
# Data fields, used to keep link with real object
account_id = fields.Many2one(
'account.account',
index=True
)
account_id = fields.Many2one("account.account", index=True)
account_group_id = fields.Many2one(
'account.group',
index=True
)
parent_id = fields.Many2one(
'account.group',
index=True
)
child_account_ids = fields.Char(
string="Child accounts")
account_group_id = fields.Many2one("account.group", index=True)
parent_id = fields.Many2one("account.group", index=True)
child_account_ids = fields.Char(string="Child accounts")
compute_account_ids = fields.Many2many(
'account.account',
string="Compute accounts", store=True)
"account.account", string="Compute accounts", store=True
)
# Data fields, used for report display
code = fields.Char()
name = fields.Char()
currency_id = fields.Many2one('res.currency')
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))
@ -115,30 +102,30 @@ class TrialBalanceReportAccount(models.TransientModel):
# Data fields, used to browse report data
partner_ids = fields.One2many(
comodel_name='report_trial_balance_partner',
inverse_name='report_account_id'
comodel_name="report_trial_balance_partner", inverse_name="report_account_id"
)
@api.depends(
'currency_id',
'report_id',
'report_id.hide_account_at_0',
'report_id.limit_hierarchy_level',
'report_id.show_hierarchy_level',
'initial_balance',
'final_balance',
'debit',
'credit',
"currency_id",
"report_id",
"report_id.hide_account_at_0",
"report_id.limit_hierarchy_level",
"report_id.show_hierarchy_level",
"initial_balance",
"final_balance",
"debit",
"credit",
)
def _compute_hide_line(self):
for rec in self:
report = rec.report_id
r = (rec.currency_id or report.company_id.currency_id).rounding
if report.hide_account_at_0 and (
float_is_zero(rec.initial_balance, precision_rounding=r)
and float_is_zero(rec.final_balance, precision_rounding=r)
and float_is_zero(rec.debit, precision_rounding=r)
and float_is_zero(rec.credit, precision_rounding=r)):
float_is_zero(rec.initial_balance, precision_rounding=r)
and float_is_zero(rec.final_balance, precision_rounding=r)
and float_is_zero(rec.debit, precision_rounding=r)
and float_is_zero(rec.credit, precision_rounding=r)
):
rec.hide_line = True
elif report.limit_hierarchy_level and report.show_hierarchy_level:
if report.hide_parent_hierarchy_level:
@ -147,31 +134,28 @@ class TrialBalanceReportAccount(models.TransientModel):
rec.hide_line = True
elif rec.level and distinct_level:
rec.hide_line = True
elif not report.hide_parent_hierarchy_level and \
rec.level > report.show_hierarchy_level:
elif (
not report.hide_parent_hierarchy_level
and rec.level > report.show_hierarchy_level
):
rec.hide_line = True
class TrialBalanceReportPartner(models.TransientModel):
_name = 'report_trial_balance_partner'
_inherit = 'account_financial_report_abstract'
_name = "report_trial_balance_partner"
_inherit = "account_financial_report_abstract"
report_account_id = fields.Many2one(
comodel_name='report_trial_balance_account',
ondelete='cascade',
index=True
comodel_name="report_trial_balance_account", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
partner_id = fields.Many2one(
'res.partner',
index=True
)
partner_id = fields.Many2one("res.partner", index=True)
# Data fields, used for report display
name = fields.Char()
currency_id = fields.Many2one('res.currency')
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))
@ -199,31 +183,34 @@ class TrialBalanceReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_trial_balance'
_inherit = "report_trial_balance"
@api.multi
def print_report(self, report_type):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_trial_balance_xlsx'
if report_type == "xlsx":
report_name = "a_f_r.report_trial_balance_xlsx"
else:
report_name = 'account_financial_report.' \
'report_trial_balance_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
report_name = "account_financial_report." "report_trial_balance_qweb"
return (
self.env["ir.actions.report"]
.search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
.report_action(self, config=False)
)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
report = self.browse(context.get("active_id"))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_trial_balance').render(
rcontext)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_trial_balance"
).render(rcontext)
return result
@api.model
@ -233,17 +220,17 @@ class TrialBalanceReportCompute(models.TransientModel):
def _prepare_report_general_ledger(self, account_ids):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.only_posted_moves,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.only_posted_moves,
# This is postprocessed later with a computed field
'hide_account_at_0': False,
'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)],
'filter_journal_ids': [(6, 0, self.filter_journal_ids.ids)],
'fy_start_date': self.fy_start_date,
"hide_account_at_0": False,
"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)],
"filter_journal_ids": [(6, 0, self.filter_journal_ids.ids)],
"fy_start_date": self.fy_start_date,
}
@api.multi
@ -252,12 +239,13 @@ class TrialBalanceReportCompute(models.TransientModel):
# Compute General Ledger Report Data.
# The data of Trial Balance Report
# are based on General Ledger Report data.
model = self.env['report_general_ledger']
model = self.env["report_general_ledger"]
if self.filter_account_ids:
account_ids = self.filter_account_ids
else:
account_ids = self.env['account.account'].search(
[('company_id', '=', self.company_id.id)])
account_ids = self.env["account.account"].search(
[("company_id", "=", self.company_id.id)]
)
self.general_ledger_id = model.create(
self._prepare_report_general_ledger(account_ids)
)
@ -270,20 +258,20 @@ class TrialBalanceReportCompute(models.TransientModel):
if self.show_partner_details:
self._inject_partner_values()
if not self.filter_account_ids:
if self.hierarchy_on != 'none':
if self.hierarchy_on != "none":
self._inject_account_group_values()
if self.hierarchy_on == 'computed':
if self.hierarchy_on == "computed":
self._update_account_group_computed_values()
else:
self._update_account_group_child_values()
self._update_account_sequence()
self._add_account_group_account_values()
self.refresh()
if not self.filter_account_ids and self.hierarchy_on != 'none':
if not self.filter_account_ids and self.hierarchy_on != "none":
self._compute_group_accounts()
else:
for line in self.account_ids:
line.write({'level': 0})
line.write({"level": 0})
def _inject_account_values(self, account_ids):
"""Inject report values for report_trial_balance_account"""
@ -421,8 +409,7 @@ FROM
self.id,
self.env.uid,
)
self.env.cr.execute(query_inject_account_group,
query_inject_account_params)
self.env.cr.execute(query_inject_account_group, query_inject_account_params)
def _update_account_group_child_values(self):
"""Compute values for report_trial_balance_account group in child."""
@ -469,9 +456,12 @@ FROM computed
WHERE report_trial_balance_account.account_group_id = computed.account_group_id
AND report_trial_balance_account.report_id = %s
"""
query_update_account_params = (self.id, self.id, self.id,)
self.env.cr.execute(query_update_account_group,
query_update_account_params)
query_update_account_params = (
self.id,
self.id,
self.id,
)
self.env.cr.execute(query_update_account_group, query_update_account_params)
def _add_account_group_account_values(self):
"""Compute values for report_trial_balance_account group in child."""
@ -510,9 +500,12 @@ FROM aggr
WHERE report_trial_balance_account.account_group_id = aggr.account_group_id
AND report_trial_balance_account.report_id = %s
"""
query_update_account_params = (self.id, self.id, self.id,)
self.env.cr.execute(query_update_account_group,
query_update_account_params)
query_update_account_params = (
self.id,
self.id,
self.id,
)
self.env.cr.execute(query_update_account_group, query_update_account_params)
def _update_account_group_computed_values(self):
"""Compute values for report_trial_balance_account group in compute."""
@ -553,8 +546,7 @@ FROM accgroup
WHERE report_trial_balance_account.account_group_id = accgroup.id
"""
query_update_account_params = (self.id,)
self.env.cr.execute(query_update_account_group,
query_update_account_params)
self.env.cr.execute(query_update_account_group, query_update_account_params)
def _update_account_sequence(self):
"""Compute sequence, level for report_trial_balance_account account."""
@ -568,22 +560,21 @@ WHERE newline.account_group_id = report_trial_balance_account.parent_id
AND report_trial_balance_account.account_id is not null
AND report_trial_balance_account.report_id = %s"""
query_update_account_params = (self.id,)
self.env.cr.execute(query_update_account_group,
query_update_account_params)
self.env.cr.execute(query_update_account_group, query_update_account_params)
def _compute_group_accounts(self):
groups = self.account_ids.filtered(
lambda a: a.account_group_id is not False)
groups = self.account_ids.filtered(lambda a: a.account_group_id is not False)
for group in groups:
if self.hierarchy_on == 'computed':
group.compute_account_ids = \
group.account_group_id.compute_account_ids
if self.hierarchy_on == "computed":
group.compute_account_ids = group.account_group_id.compute_account_ids
else:
if group.child_account_ids:
chacc = group.child_account_ids.replace(
'}', '').replace('{', '').split(',')
if 'NULL' in chacc:
chacc.remove('NULL')
chacc = (
group.child_account_ids.replace("}", "")
.replace("{", "")
.split(",")
)
if "NULL" in chacc:
chacc.remove("NULL")
if chacc:
group.compute_account_ids = [
(6, 0, [int(g) for g in chacc])]
group.compute_account_ids = [(6, 0, [int(g) for g in chacc])]

257
account_financial_report/report/trial_balance_xlsx.py

@ -7,112 +7,158 @@ from odoo import _, models
class TrialBalanceXslx(models.AbstractModel):
_name = 'report.a_f_r.report_trial_balance_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
_name = "report.a_f_r.report_trial_balance_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('Trial Balance')
report_name = _("Trial Balance")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
if not report.show_partner_details:
res = {
0: {'header': _('Code'), 'field': 'code', 'width': 10},
1: {'header': _('Account'), 'field': 'name', 'width': 60},
2: {'header': _('Initial balance'),
'field': 'initial_balance',
'type': 'amount',
'width': 14},
3: {'header': _('Debit'),
'field': 'debit',
'type': 'amount',
'width': 14},
4: {'header': _('Credit'),
'field': 'credit',
'type': 'amount',
'width': 14},
5: {'header': _('Period balance'),
'field': 'period_balance',
'type': 'amount',
'width': 14},
6: {'header': _('Ending balance'),
'field': 'final_balance',
'type': 'amount',
'width': 14},
0: {"header": _("Code"), "field": "code", "width": 10},
1: {"header": _("Account"), "field": "name", "width": 60},
2: {
"header": _("Initial balance"),
"field": "initial_balance",
"type": "amount",
"width": 14,
},
3: {
"header": _("Debit"),
"field": "debit",
"type": "amount",
"width": 14,
},
4: {
"header": _("Credit"),
"field": "credit",
"type": "amount",
"width": 14,
},
5: {
"header": _("Period balance"),
"field": "period_balance",
"type": "amount",
"width": 14,
},
6: {
"header": _("Ending balance"),
"field": "final_balance",
"type": "amount",
"width": 14,
},
}
if report.foreign_currency:
foreign_currency = {
7: {'header': _('Cur.'),
'field': 'currency_id',
'field_currency_balance': 'currency_id',
'type': 'many2one', 'width': 7},
8: {'header': _('Initial balance'),
'field': 'initial_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
9: {'header': _('Ending balance'),
'field': 'final_balance_foreign_currency',
'type': 'amount_currency',
'width': 14},
7: {
"header": _("Cur."),
"field": "currency_id",
"field_currency_balance": "currency_id",
"type": "many2one",
"width": 7,
},
8: {
"header": _("Initial balance"),
"field": "initial_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
9: {
"header": _("Ending balance"),
"field": "final_balance_foreign_currency",
"type": "amount_currency",
"width": 14,
},
}
res = {**res, **foreign_currency}
return res
else:
res = {
0: {'header': _('Partner'), 'field': 'name', 'width': 70},
1: {'header': _('Initial balance'),
'field': 'initial_balance',
'type': 'amount',
'width': 14},
2: {'header': _('Debit'),
'field': 'debit',
'type': 'amount',
'width': 14},
3: {'header': _('Credit'),
'field': 'credit',
'type': 'amount',
'width': 14},
4: {'header': _('Period balance'),
'field': 'period_balance',
'type': 'amount',
'width': 14},
5: {'header': _('Ending balance'),
'field': 'final_balance',
'type': 'amount',
'width': 14},
0: {"header": _("Partner"), "field": "name", "width": 70},
1: {
"header": _("Initial balance"),
"field": "initial_balance",
"type": "amount",
"width": 14,
},
2: {
"header": _("Debit"),
"field": "debit",
"type": "amount",
"width": 14,
},
3: {
"header": _("Credit"),
"field": "credit",
"type": "amount",
"width": 14,
},
4: {
"header": _("Period balance"),
"field": "period_balance",
"type": "amount",
"width": 14,
},
5: {
"header": _("Ending balance"),
"field": "final_balance",
"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},
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
def _get_report_filters(self, report):
return [
[_('Date range filter'),
_('From: %s To: %s') % (report.date_from, report.date_to)],
[_('Target moves filter'),
_('All posted entries') if report.only_posted_moves else _(
'All entries')],
[_('Account at 0 filter'),
_('Hide') if report.hide_account_at_0 else _('Show')],
[_('Show foreign currency'),
_('Yes') if report.foreign_currency else _('No')],
[_('Limit hierarchy levels'),
_('Level %s' % report.show_hierarchy_level) if
report.limit_hierarchy_level else _('No limit')],
[
_("Date range filter"),
_("From: %s To: %s") % (report.date_from, report.date_to),
],
[
_("Target moves filter"),
_("All posted entries")
if report.only_posted_moves
else _("All entries"),
],
[
_("Account at 0 filter"),
_("Hide") if report.hide_account_at_0 else _("Show"),
],
[
_("Show foreign currency"),
_("Yes") if report.foreign_currency else _("No"),
],
[
_("Limit hierarchy levels"),
_("Level %s" % report.show_hierarchy_level)
if report.limit_hierarchy_level
else _("No limit"),
],
]
def _get_col_count_filter_name(self):
@ -131,11 +177,11 @@ class TrialBalanceXslx(models.AbstractModel):
for account in report.account_ids.filtered(lambda a: not a.hide_line):
if not report.show_partner_details:
# Display account lines
self.write_line(account, 'account')
self.write_line(account, "account")
else:
# Write account title
self.write_array_title(account.code + ' - ' + account.name)
self.write_array_title(account.code + " - " + account.name)
# Display array header for partner lines
self.write_array_header()
@ -143,11 +189,10 @@ class TrialBalanceXslx(models.AbstractModel):
# For each partner
for partner in account.partner_ids:
# Display partner lines
self.write_line(partner, 'partner')
self.write_line(partner, "partner")
# Display account footer line
self.write_account_footer(account,
account.code + ' - ' + account.name)
self.write_account_footer(account, account.code + " - " + account.name)
# Line break
self.row_pos += 2
@ -156,9 +201,9 @@ class TrialBalanceXslx(models.AbstractModel):
"""Write a line on current line using all defined columns field name.
Columns are defined with `_get_report_columns` method.
"""
if type_object == 'partner':
if type_object == "partner":
line_object.currency_id = line_object.report_account_id.currency_id
elif type_object == 'account':
elif type_object == "account":
line_object.currency_id = line_object.currency_id
super(TrialBalanceXslx, self).write_line(line_object)
@ -166,27 +211,27 @@ class TrialBalanceXslx(models.AbstractModel):
"""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':
if column["field"] == "name":
value = name_value
else:
value = getattr(account, column['field'])
cell_type = column.get('type', 'string')
if cell_type == 'string':
self.sheet.write_string(self.row_pos, col_pos, value or '',
self.format_header_left)
elif cell_type == 'amount':
self.sheet.write_number(self.row_pos, col_pos, float(value),
self.format_header_amount)
elif cell_type == 'many2one':
value = getattr(account, column["field"])
cell_type = column.get("type", "string")
if cell_type == "string":
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.row_pos, col_pos, value or "", self.format_header_left
)
elif cell_type == "amount":
self.sheet.write_number(
self.row_pos, col_pos, float(value),
format_amt)
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, col_pos, "", self.format_header_right
)
self.row_pos += 1

132
account_financial_report/report/vat_report.py

@ -6,7 +6,7 @@ from odoo import api, fields, models
class VATReport(models.TransientModel):
_name = "report_vat_report"
_inherit = 'account_financial_report_abstract'
_inherit = "account_financial_report_abstract"
""" Here, we just define class fields.
For methods, go more bottom at this file.
@ -17,43 +17,35 @@ class VATReport(models.TransientModel):
"""
# Filters fields, used for data computation
company_id = fields.Many2one(comodel_name='res.company')
company_id = fields.Many2one(comodel_name="res.company")
date_from = fields.Date()
date_to = fields.Date()
based_on = fields.Selection([('taxtags', 'Tax Tags'),
('taxgroups', 'Tax Groups')],
string='Based On',
required=True,
default='taxtags')
tax_detail = fields.Boolean('Tax Detail')
based_on = fields.Selection(
[("taxtags", "Tax Tags"), ("taxgroups", "Tax Groups")],
string="Based On",
required=True,
default="taxtags",
)
tax_detail = fields.Boolean("Tax Detail")
# Data fields, used to browse report data
taxtags_ids = fields.One2many(
comodel_name='report_vat_report_taxtag',
inverse_name='report_id'
comodel_name="report_vat_report_taxtag", inverse_name="report_id"
)
class VATReportTaxTags(models.TransientModel):
_name = 'report_vat_report_taxtag'
_inherit = 'account_financial_report_abstract'
_order = 'code ASC'
_name = "report_vat_report_taxtag"
_inherit = "account_financial_report_abstract"
_order = "code ASC"
report_id = fields.Many2one(
comodel_name='report_vat_report',
ondelete='cascade',
index=True
comodel_name="report_vat_report", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
taxtag_id = fields.Many2one(
'account.account.tag',
index=True
)
taxgroup_id = fields.Many2one(
'account.tax.group',
index=True
)
taxtag_id = fields.Many2one("account.account.tag", index=True)
taxgroup_id = fields.Many2one("account.tax.group", index=True)
# Data fields, used for report display
code = fields.Char()
@ -63,29 +55,23 @@ class VATReportTaxTags(models.TransientModel):
# Data fields, used to browse report data
tax_ids = fields.One2many(
comodel_name='report_vat_report_tax',
inverse_name='report_tax_id',
string='Taxes'
comodel_name="report_vat_report_tax",
inverse_name="report_tax_id",
string="Taxes",
)
class VATReportTax(models.TransientModel):
_name = 'report_vat_report_tax'
_inherit = 'account_financial_report_abstract'
_order = 'name ASC'
_name = "report_vat_report_tax"
_inherit = "account_financial_report_abstract"
_order = "name ASC"
report_tax_id = fields.Many2one(
comodel_name='report_vat_report_taxtag',
ondelete='cascade',
index=True
comodel_name="report_vat_report_taxtag", ondelete="cascade", index=True
)
# Data fields, used to keep link with real object
tax_id = fields.Many2one(
'account.tax',
index=True,
string='Tax ID',
)
tax_id = fields.Many2one("account.tax", index=True, string="Tax ID",)
# Data fields, used for report display
code = fields.Char()
@ -99,31 +85,32 @@ class VATReportCompute(models.TransientModel):
For class fields, go more top at this file.
"""
_inherit = 'report_vat_report'
_inherit = "report_vat_report"
@api.multi
def print_report(self, report_type='qweb'):
def print_report(self, report_type="qweb"):
self.ensure_one()
if report_type == 'xlsx':
report_name = 'a_f_r.report_vat_report_xlsx'
if report_type == "xlsx":
report_name = "a_f_r.report_vat_report_xlsx"
else:
report_name = 'account_financial_report.report_vat_report_qweb'
report_name = "account_financial_report.report_vat_report_qweb"
context = dict(self.env.context)
action = self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1)
action = self.env["ir.actions.report"].search(
[("report_name", "=", report_name), ("report_type", "=", report_type)],
limit=1,
)
return action.with_context(context).report_action(self, config=False)
def _get_html(self):
result = {}
rcontext = {}
context = dict(self.env.context)
report = self.browse(context.get('active_id'))
report = self.browse(context.get("active_id"))
if report:
rcontext['o'] = report
result['html'] = self.env.ref(
'account_financial_report.report_vat_report').render(
rcontext)
rcontext["o"] = report
result["html"] = self.env.ref(
"account_financial_report.report_vat_report"
).render(rcontext)
return result
@api.model
@ -134,10 +121,10 @@ class VATReportCompute(models.TransientModel):
def compute_data_for_report(self):
self.ensure_one()
# Compute report data
if self.based_on == 'taxtags':
if self.based_on == "taxtags":
self._inject_taxtags_values()
self._inject_tax_taxtags_values()
elif self.based_on == 'taxgroups':
elif self.based_on == "taxgroups":
self._inject_taxgroups_values()
self._inject_tax_taxgroups_values()
# Refresh cache because all data are computed with SQL requests
@ -192,8 +179,13 @@ SELECT
FROM
taxtags tag
"""
query_inject_taxtags_params = (self.company_id.id, self.date_from,
self.date_to, self.id, self.env.uid)
query_inject_taxtags_params = (
self.company_id.id,
self.date_from,
self.date_to,
self.id,
self.env.uid,
)
self.env.cr.execute(query_inject_taxtags, query_inject_taxtags_params)
def _inject_taxgroups_values(self):
@ -242,10 +234,14 @@ SELECT
FROM
taxgroups groups
"""
query_inject_taxgroups_params = (self.company_id.id, self.date_from,
self.date_to, self.id, self.env.uid)
self.env.cr.execute(query_inject_taxgroups,
query_inject_taxgroups_params)
query_inject_taxgroups_params = (
self.company_id.id,
self.date_from,
self.date_to,
self.id,
self.env.uid,
)
self.env.cr.execute(query_inject_taxgroups, query_inject_taxgroups_params)
def _inject_tax_taxtags_values(self):
""" Inject report values for report_vat_report_tax. """
@ -298,8 +294,13 @@ SELECT
FROM
taxtags_tax tt
"""
query_inject_tax_params = (self.id, self.company_id.id, self.date_from,
self.date_to, self.env.uid)
query_inject_tax_params = (
self.id,
self.company_id.id,
self.date_from,
self.date_to,
self.env.uid,
)
self.env.cr.execute(query_inject_tax, query_inject_tax_params)
def _inject_tax_taxgroups_values(self):
@ -351,6 +352,11 @@ SELECT
FROM
taxtags_tax tt
"""
query_inject_tax_params = (self.id, self.company_id.id, self.date_from,
self.date_to, self.env.uid)
query_inject_tax_params = (
self.id,
self.company_id.id,
self.date_from,
self.date_to,
self.env.uid,
)
self.env.cr.execute(query_inject_tax, query_inject_tax_params)

26
account_financial_report/report/vat_report_xlsx.py

@ -5,32 +5,26 @@ from odoo import _, models
class VATReportXslx(models.AbstractModel):
_name = 'report.a_f_r.report_vat_report_xlsx'
_inherit = 'report.account_financial_report.abstract_report_xlsx'
_name = "report.a_f_r.report_vat_report_xlsx"
_inherit = "report.account_financial_report.abstract_report_xlsx"
def _get_report_name(self, report):
report_name = _('VAT Report')
report_name = _("VAT Report")
return self._get_report_complete_name(report, report_name)
def _get_report_columns(self, report):
return {
0: {'header': _('Code'), 'field': 'code', 'width': 5},
1: {'header': _('Name'), 'field': 'name', 'width': 100},
2: {'header': _('Net'),
'field': 'net',
'type': 'amount',
'width': 14},
3: {'header': _('Tax'),
'field': 'tax',
'type': 'amount',
'width': 14},
0: {"header": _("Code"), "field": "code", "width": 5},
1: {"header": _("Name"), "field": "name", "width": 100},
2: {"header": _("Net"), "field": "net", "type": "amount", "width": 14},
3: {"header": _("Tax"), "field": "tax", "type": "amount", "width": 14},
}
def _get_report_filters(self, report):
return [
[_('Date from'), report.date_from],
[_('Date to'), report.date_to],
[_('Based on'), report.based_on],
[_("Date from"), report.date_from],
[_("Date to"), report.date_to],
[_("Based on"), report.based_on],
]
def _get_col_count_filter_name(self):

202
account_financial_report/reports.xml

@ -1,121 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- PDF/HMTL REPORTS -->
<!-- General Ledger -->
<report
id="action_report_general_ledger_qweb"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-pdf"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger_qweb"
/>
id="action_report_general_ledger_qweb"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-pdf"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger_qweb"
/>
<report
id="action_report_general_ledger_html"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-html"
name="account_financial_report.report_general_ledger_qweb"
file="account_financial_report.report_general_ledger_html"
/>
id="action_report_general_ledger_html"
model="report_general_ledger"
string="General Ledger"
report_type="qweb-html"
name="account_financial_report.report_general_ledger_qweb"
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"
/>
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"
/>
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 -->
<report
id="action_report_trial_balance_qweb"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-pdf"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_qweb"
/>
id="action_report_trial_balance_qweb"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-pdf"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_qweb"
/>
<report
id="action_report_trial_balance_html"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-html"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_html"
/>
id="action_report_trial_balance_html"
model="report_trial_balance"
string="Trial Balance"
report_type="qweb-html"
name="account_financial_report.report_trial_balance_qweb"
file="account_financial_report.report_trial_balance_html"
/>
<!-- Open Items -->
<report
id="action_report_open_items_qweb"
model="report_open_items"
string="Open Items"
report_type="qweb-pdf"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_qweb"
id="action_report_open_items_qweb"
model="report_open_items"
string="Open Items"
report_type="qweb-pdf"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_qweb"
/>
<report
id="action_report_open_items_html"
model="report_open_items"
string="Open Items"
report_type="qweb-html"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_html"
id="action_report_open_items_html"
model="report_open_items"
string="Open Items"
report_type="qweb-html"
name="account_financial_report.report_open_items_qweb"
file="account_financial_report.report_open_items_html"
/>
<!-- Aged Partner Balance -->
<report
id="action_report_aged_partner_balance_qweb"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-pdf"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_qweb"
id="action_report_aged_partner_balance_qweb"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-pdf"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_qweb"
/>
<report
id="action_report_aged_partner_balance_html"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-html"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_html"
id="action_report_aged_partner_balance_html"
model="report_aged_partner_balance"
string="Aged Partner Balance"
report_type="qweb-html"
name="account_financial_report.report_aged_partner_balance_qweb"
file="account_financial_report.report_aged_partner_balance_html"
/>
<!-- VAT Report -->
<report
id="action_report_vat_report_qweb"
model="report_vat_report"
string="VAT Report"
report_type="qweb-pdf"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_qweb"
id="action_report_vat_report_qweb"
model="report_vat_report"
string="VAT Report"
report_type="qweb-pdf"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_qweb"
/>
<report
id="action_report_vat_report_html"
model="report_vat_report"
string="VAT Report"
report_type="qweb-html"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_html"
<report
id="action_report_vat_report_html"
model="report_vat_report"
string="VAT Report"
report_type="qweb-html"
name="account_financial_report.report_vat_report_qweb"
file="account_financial_report.report_vat_report_html"
/>
<!-- PDF REPORTS : paperformat -->
<record id="report_qweb_paperformat" model="report.paperformat">
<field name="name">Account financial report qweb paperformat</field>
<field name="default" eval="True"/>
<field name="default" eval="True" />
<field name="format">custom</field>
<field name="page_height">297</field>
<field name="page_width">210</field>
@ -124,35 +115,26 @@
<field name="margin_bottom">8</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False"/>
<field name="header_line" eval="False" />
<field name="header_spacing">10</field>
<field name="dpi">110</field>
</record>
<record id="action_report_general_ledger_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_report_trial_balance_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_report_open_items_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_report_aged_partner_balance_qweb"
model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
<record id="action_report_aged_partner_balance_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<record id="action_report_vat_report_qweb"
model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat"/>
<record id="action_report_vat_report_qweb" model="ir.actions.report">
<field name="paperformat_id" ref="report_qweb_paperformat" />
</record>
<!-- XLSX REPORTS -->
<record id="action_report_general_ledger_xlsx" model="ir.actions.report">
<field name="name">General Ledger XLSX</field>
<field name="model">report_general_ledger</field>
@ -161,7 +143,6 @@
<field name="report_type">xlsx</field>
<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>
@ -170,7 +151,6 @@
<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>
@ -179,7 +159,6 @@
<field name="report_type">xlsx</field>
<field name="report_file">report_trial_balance</field>
</record>
<record id="action_report_open_items_xlsx" model="ir.actions.report">
<field name="name">Open Items XLSX</field>
<field name="model">report_open_items</field>
@ -188,7 +167,6 @@
<field name="report_type">xlsx</field>
<field name="report_file">report_open_items</field>
</record>
<record id="action_report_aged_partner_balance_xlsx" model="ir.actions.report">
<field name="name">Aged Partner Balance XLSX</field>
<field name="model">report_aged_partner_balance</field>
@ -197,7 +175,6 @@
<field name="report_type">xlsx</field>
<field name="report_file">report_aged_partner_balance</field>
</record>
<record id="action_report_vat_report_xlsx" model="ir.actions.report">
<field name="name">VAT Report XLSX</field>
<field name="model">report_vat_report</field>
@ -206,5 +183,4 @@
<field name="report_type">xlsx</field>
<field name="report_file">report_vat_report</field>
</record>
</odoo>

74
account_financial_report/static/src/css/report.css

@ -2,7 +2,7 @@
display: table !important;
background-color: white;
}
.act_as_row {
.act_as_row {
display: table-row !important;
page-break-inside: avoid;
}
@ -16,67 +16,77 @@
.act_as_tbody {
display: table-row-group !important;
}
.list_table, .data_table, .totals_table{
.list_table,
.data_table,
.totals_table {
width: 100% !important;
}
.act_as_row.labels {
background-color:#F0F0F0 !important;
}
.list_table, .data_table, .totals_table, .list_table .act_as_row {
border-left:0px;
border-right:0px;
text-align:center;
font-size:10px;
padding-right:3px;
padding-left:3px;
padding-top:2px;
padding-bottom:2px;
border-collapse:collapse;
background-color: #f0f0f0 !important;
}
.list_table,
.data_table,
.totals_table,
.list_table .act_as_row {
border-left: 0px;
border-right: 0px;
text-align: center;
font-size: 10px;
padding-right: 3px;
padding-left: 3px;
padding-top: 2px;
padding-bottom: 2px;
border-collapse: collapse;
}
.totals_table {
font-weight: bold;
text-align: center;
}
.list_table .act_as_row.labels, .list_table .act_as_row.initial_balance, .list_table .act_as_row.lines {
border-color:grey !important;
border-bottom:1px solid lightGrey !important;
.list_table .act_as_row.labels,
.list_table .act_as_row.initial_balance,
.list_table .act_as_row.lines {
border-color: grey !important;
border-bottom: 1px solid lightGrey !important;
}
.data_table .act_as_cell{
.data_table .act_as_cell {
border: 1px solid lightGrey;
text-align: center;
}
.data_table .act_as_cell, .list_table .act_as_cell, .totals_table .act_as_cell {
.data_table .act_as_cell,
.list_table .act_as_cell,
.totals_table .act_as_cell {
word-wrap: break-word;
}
.data_table .act_as_row.labels, .totals_table .act_as_row.labels {
.data_table .act_as_row.labels,
.totals_table .act_as_row.labels {
font-weight: bold;
}
.initial_balance .act_as_cell {
font-style:italic;
font-style: italic;
}
.account_title {
font-size:11px;
font-weight:bold;
font-size: 11px;
font-weight: bold;
}
.account_title.labels {
background-color:#F0F0F0 !important;
background-color: #f0f0f0 !important;
}
.act_as_cell.amount {
word-wrap:normal;
text-align:right;
word-wrap: normal;
text-align: right;
}
.act_as_cell.left {
text-align:left;
text-align: left;
}
.act_as_cell.right {
text-align:right;
text-align: right;
}
.list_table .act_as_cell{
/* border-right:1px solid lightGrey; uncomment to active column lines */
.list_table .act_as_cell {
/* border-right:1px solid lightGrey; uncomment to active column lines */
}
.list_table .act_as_cell.first_column {
padding-left: 0px;
/* border-left:1px solid lightGrey; uncomment to active column lines */
/* border-left:1px solid lightGrey; uncomment to active column lines */
}
.overflow_ellipsis {
text-overflow: ellipsis;
@ -84,7 +94,7 @@
white-space: nowrap;
}
.custom_footer {
font-size:7px !important;
font-size: 7px !important;
}
.page_break {
page-break-inside: avoid;

77
account_financial_report/static/src/js/account_financial_report_backend.js

@ -1,21 +1,20 @@
odoo.define('account_financial_report.account_financial_report_backend', function (require) {
'use strict';
var core = require('web.core');
var Widget = require('web.Widget');
var ControlPanelMixin = require('web.ControlPanelMixin');
var ReportWidget = require(
'account_financial_report.account_financial_report_widget'
);
odoo.define("account_financial_report.account_financial_report_backend", function(
require
) {
"use strict";
var core = require("web.core");
var Widget = require("web.Widget");
var ControlPanelMixin = require("web.ControlPanelMixin");
var ReportWidget = require("account_financial_report.account_financial_report_widget");
var report_backend = Widget.extend(ControlPanelMixin, {
// Stores all the parameters of the action.
events: {
'click .o_account_financial_reports_print': 'print',
'click .o_account_financial_reports_export': 'export',
"click .o_account_financial_reports_print": "print",
"click .o_account_financial_reports_export": "export",
},
init: function (parent, action) {
init: function(parent, action) {
this.actionManager = parent;
this.given_context = {};
this.odoo_context = action.context;
@ -23,50 +22,49 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
if (action.context.context) {
this.given_context = action.context.context;
}
this.given_context.active_id = action.context.active_id ||
action.params.active_id;
this.given_context.active_id =
action.context.active_id || action.params.active_id;
this.given_context.model = action.context.active_model || false;
this.given_context.ttype = action.context.ttype || false;
return this._super.apply(this, arguments);
},
willStart: function () {
willStart: function() {
return $.when(this.get_html());
},
set_html: function () {
set_html: function() {
var self = this;
var def = $.when();
if (!this.report_widget) {
this.report_widget = new ReportWidget(this, this.given_context);
def = this.report_widget.appendTo(this.$el);
}
def.then(function () {
def.then(function() {
self.report_widget.$el.html(self.html);
});
},
start: function () {
start: function() {
this.set_html();
return this._super();
},
// Fetches the html and is previous report.context if any,
// else create it
get_html: function () {
get_html: function() {
var self = this;
var defs = [];
return this._rpc({
model: this.given_context.model,
method: 'get_html',
method: "get_html",
args: [self.given_context],
context: self.odoo_context,
})
.then(function (result) {
self.html = result.html;
defs.push(self.update_cp());
return $.when.apply($, defs);
});
}).then(function(result) {
self.html = result.html;
defs.push(self.update_cp());
return $.when.apply($, defs);
});
},
// Updates the control panel and render the elements that have yet
// to be rendered
update_cp: function () {
update_cp: function() {
if (this.$buttons) {
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
@ -75,40 +73,37 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
return this.update_control_panel(status);
}
},
do_show: function () {
do_show: function() {
this._super();
this.update_cp();
},
print: function () {
print: function() {
var self = this;
this._rpc({
model: this.given_context.model,
method: 'print_report',
args: [this.given_context.active_id, 'qweb-pdf'],
method: "print_report",
args: [this.given_context.active_id, "qweb-pdf"],
context: self.odoo_context,
}).then(function (result) {
}).then(function(result) {
self.do_action(result);
});
},
export: function () {
export: function() {
var self = this;
this._rpc({
model: this.given_context.model,
method: 'print_report',
args: [this.given_context.active_id, 'xlsx'],
method: "print_report",
args: [this.given_context.active_id, "xlsx"],
context: self.odoo_context,
}).then(function (result) {
}).then(function(result) {
self.do_action(result);
});
},
canBeRemoved: function () {
canBeRemoved: function() {
return $.when();
},
});
core.action_registry.add(
"account_financial_report_backend",
report_backend
);
core.action_registry.add("account_financial_report_backend", report_backend);
return report_backend;
});

96
account_financial_report/static/src/js/account_financial_report_widgets.js

@ -1,86 +1,88 @@
odoo.define('account_financial_report.account_financial_report_widget', function
(require) {
'use strict';
var Widget = require('web.Widget');
odoo.define("account_financial_report.account_financial_report_widget", function(
require
) {
"use strict";
var Widget = require("web.Widget");
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',
"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 () {
init: function() {
this._super.apply(this, arguments);
},
start: function () {
start: function() {
return this._super.apply(this, arguments);
},
boundLink: function (e) {
var res_model = $(e.target).data('res-model');
var res_id = $(e.target).data('active-id');
boundLink: function(e) {
var res_model = $(e.target).data("res-model");
var res_id = $(e.target).data("active-id");
return this.do_action({
type: 'ir.actions.act_window',
type: "ir.actions.act_window",
res_model: res_model,
res_id: res_id,
views: [[false, 'form']],
target: 'current',
views: [[false, "form"]],
target: "current",
});
},
boundLinkmulti: function (e) {
var res_model = $(e.target).data('res-model');
var domain = $(e.target).data('domain');
boundLinkmulti: function(e) {
var res_model = $(e.target).data("res-model");
var domain = $(e.target).data("domain");
if (!res_model) {
res_model = $(e.target.parentElement).data('res-model');
res_model = $(e.target.parentElement).data("res-model");
}
if (!domain) {
domain = $(e.target.parentElement).data('domain');
domain = $(e.target.parentElement).data("domain");
}
return this.do_action({
type: 'ir.actions.act_window',
name: this._toTitleCase(res_model.split('.').join(' ')),
type: "ir.actions.act_window",
name: this._toTitleCase(res_model.split(".").join(" ")),
res_model: res_model,
domain: domain,
views: [[false, "list"], [false, "form"]],
target: 'current',
views: [
[false, "list"],
[false, "form"],
],
target: "current",
});
},
boundLinkMonetary: function (e) {
var res_model = $(e.target.parentElement).data('res-model');
var res_id = $(e.target.parentElement).data('active-id');
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',
type: "ir.actions.act_window",
res_model: res_model,
res_id: res_id,
views: [[false, 'form']],
target: 'current',
views: [[false, "form"]],
target: "current",
});
},
boundLinkMonetarymulti: function (e) {
var res_model = $(e.target.parentElement).data('res-model');
var domain = $(e.target.parentElement).data('domain');
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',
type: "ir.actions.act_window",
res_model: res_model,
domain: domain,
views: [[false, "list"], [false, "form"]],
target: 'current',
views: [
[false, "list"],
[false, "form"],
],
target: "current",
});
},
_toTitleCase: function (str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() +
txt.substr(1).toLowerCase();
_toTitleCase: function(str) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
},
});
return accountFinancialReportWidget;
});

1
account_financial_report/tests/__init__.py

@ -1,4 +1,3 @@
# © 2016 Julien Coux (Camptocamp)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-

475
account_financial_report/tests/abstract_test.py

@ -12,6 +12,7 @@ _logger = logging.getLogger(__name__)
class AbstractTest(common.TransactionCase):
"""Common technical tests for all reports."""
at_install = False
post_install = True
@ -23,173 +24,210 @@ class AbstractTest(common.TransactionCase):
return self
def _chart_template_create(self):
transfer_account_id = self.env['account.account.template'].create({
'code': '000',
'name': 'Liquidity Transfers',
'reconcile': True,
'user_type_id': self.ref(
"account.data_account_type_current_assets"),
})
self.chart = self.env['account.chart.template'].create({
'name': 'Test COA',
'code_digits': 4,
'bank_account_code_prefix': 1014,
'cash_account_code_prefix': 1014,
'currency_id': self.ref('base.USD'),
'transfer_account_code_prefix': '000',
})
transfer_account_id.update({
'chart_template_id': self.chart.id,
})
self.env['ir.model.data'].create({
'res_id': transfer_account_id.id,
'model': transfer_account_id._name,
'name': 'Liquidity Transfers',
})
act = self.env['account.account.template'].create({
'code': '001',
'name': 'Expenses',
'user_type_id': self.ref("account.data_account_type_expenses"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'expenses',
})
act = self.env['account.account.template'].create({
'code': '002',
'name': 'Product Sales',
'user_type_id': self.ref("account.data_account_type_revenue"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'sales',
})
act = self.env['account.account.template'].create({
'code': '003',
'name': 'Account Receivable',
'user_type_id': self.ref("account.data_account_type_receivable"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'receivable',
})
act = self.env['account.account.template'].create({
'code': '004',
'name': 'Account Payable',
'user_type_id': self.ref("account.data_account_type_payable"),
'chart_template_id': self.chart.id,
'reconcile': True,
})
self.env['ir.model.data'].create({
'res_id': act.id,
'model': act._name,
'name': 'payable',
})
transfer_account_id = self.env["account.account.template"].create(
{
"code": "000",
"name": "Liquidity Transfers",
"reconcile": True,
"user_type_id": self.ref("account.data_account_type_current_assets"),
}
)
self.chart = self.env["account.chart.template"].create(
{
"name": "Test COA",
"code_digits": 4,
"bank_account_code_prefix": 1014,
"cash_account_code_prefix": 1014,
"currency_id": self.ref("base.USD"),
"transfer_account_code_prefix": "000",
}
)
transfer_account_id.update(
{"chart_template_id": self.chart.id,}
)
self.env["ir.model.data"].create(
{
"res_id": transfer_account_id.id,
"model": transfer_account_id._name,
"name": "Liquidity Transfers",
}
)
act = self.env["account.account.template"].create(
{
"code": "001",
"name": "Expenses",
"user_type_id": self.ref("account.data_account_type_expenses"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "expenses",}
)
act = self.env["account.account.template"].create(
{
"code": "002",
"name": "Product Sales",
"user_type_id": self.ref("account.data_account_type_revenue"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "sales",}
)
act = self.env["account.account.template"].create(
{
"code": "003",
"name": "Account Receivable",
"user_type_id": self.ref("account.data_account_type_receivable"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "receivable",}
)
act = self.env["account.account.template"].create(
{
"code": "004",
"name": "Account Payable",
"user_type_id": self.ref("account.data_account_type_payable"),
"chart_template_id": self.chart.id,
"reconcile": True,
}
)
self.env["ir.model.data"].create(
{"res_id": act.id, "model": act._name, "name": "payable",}
)
def _add_chart_of_accounts(self):
self.company = self.env['res.company'].create({
'name': 'Spanish test company',
})
self.env.ref('base.group_multi_company').write({
'users': [(4, self.env.uid)],
})
self.env.user.write({
'company_ids': [(4, self.company.id)],
'company_id': self.company.id,
})
self.with_context(
company_id=self.company.id, force_company=self.company.id)
self.company = self.env["res.company"].create({"name": "Spanish test company",})
self.env.ref("base.group_multi_company").write(
{"users": [(4, self.env.uid)],}
)
self.env.user.write(
{"company_ids": [(4, self.company.id)], "company_id": self.company.id,}
)
self.with_context(company_id=self.company.id, force_company=self.company.id)
self.chart.try_loading_for_current_company()
self.revenue = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_revenue"))], limit=1)
self.expense = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_expenses"))], limit=1)
self.receivable = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_receivable"))], limit=1)
self.payable = self.env['account.account'].search(
[('user_type_id', '=', self.ref(
"account.data_account_type_payable"))], limit=1)
self.revenue = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_revenue"))],
limit=1,
)
self.expense = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_expenses"))],
limit=1,
)
self.receivable = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_receivable"))],
limit=1,
)
self.payable = self.env["account.account"].search(
[("user_type_id", "=", self.ref("account.data_account_type_payable"))],
limit=1,
)
return True
def _journals_create(self):
self.journal_sale = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for sale',
'type': 'sale',
'code': 'TSALE',
'default_debit_account_id': self.revenue.id,
'default_credit_account_id': self.revenue.id,
})
self.journal_purchase = self.env['account.journal'].create({
'company_id': self.company.id,
'name': 'Test journal for purchase',
'type': 'purchase',
'code': 'TPUR',
'default_debit_account_id': self.expense.id,
'default_credit_account_id': self.expense.id,
})
self.journal_sale = self.env["account.journal"].create(
{
"company_id": self.company.id,
"name": "Test journal for sale",
"type": "sale",
"code": "TSALE",
"default_debit_account_id": self.revenue.id,
"default_credit_account_id": self.revenue.id,
}
)
self.journal_purchase = self.env["account.journal"].create(
{
"company_id": self.company.id,
"name": "Test journal for purchase",
"type": "purchase",
"code": "TPUR",
"default_debit_account_id": self.expense.id,
"default_credit_account_id": self.expense.id,
}
)
return True
def _invoice_create(self):
self.partner = self.env['res.partner'].create({
'name': 'Test partner',
'company_id': self.company.id,
'property_account_receivable_id': self.receivable.id,
'property_account_payable_id': self.payable.id,
})
self.partner = self.env["res.partner"].create(
{
"name": "Test partner",
"company_id": self.company.id,
"property_account_receivable_id": self.receivable.id,
"property_account_payable_id": self.payable.id,
}
)
# customer invoice
customer_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
})]
self.invoice_out = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'out_invoice',
'invoice_line_ids': customer_invoice_lines,
'account_id': self.partner.property_account_receivable_id.id,
'journal_id': self.journal_sale.id,
})
customer_invoice_lines = [
(
0,
False,
{
"name": "Test description #1",
"account_id": self.revenue.id,
"quantity": 1.0,
"price_unit": 100.0,
},
),
(
0,
False,
{
"name": "Test description #2",
"account_id": self.revenue.id,
"quantity": 2.0,
"price_unit": 25.0,
},
),
]
self.invoice_out = self.env["account.invoice"].create(
{
"partner_id": self.partner.id,
"type": "out_invoice",
"invoice_line_ids": customer_invoice_lines,
"account_id": self.partner.property_account_receivable_id.id,
"journal_id": self.journal_sale.id,
}
)
self.invoice_out.action_invoice_open()
# vendor bill
vendor_invoice_lines = [(0, False, {
'name': 'Test description #1',
'account_id': self.revenue.id,
'quantity': 1.0,
'price_unit': 100.0,
}), (0, False, {
'name': 'Test description #2',
'account_id': self.revenue.id,
'quantity': 2.0,
'price_unit': 25.0,
})]
self.invoice_in = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'type': 'in_invoice',
'invoice_line_ids': vendor_invoice_lines,
'account_id': self.partner.property_account_payable_id.id,
'journal_id': self.journal_purchase.id,
})
vendor_invoice_lines = [
(
0,
False,
{
"name": "Test description #1",
"account_id": self.revenue.id,
"quantity": 1.0,
"price_unit": 100.0,
},
),
(
0,
False,
{
"name": "Test description #2",
"account_id": self.revenue.id,
"quantity": 2.0,
"price_unit": 25.0,
},
),
]
self.invoice_in = self.env["account.invoice"].create(
{
"partner_id": self.partner.id,
"type": "in_invoice",
"invoice_line_ids": vendor_invoice_lines,
"account_id": self.partner.property_account_payable_id.id,
"journal_id": self.journal_purchase.id,
}
)
self.invoice_in.action_invoice_open()
def setUp(self):
@ -216,54 +254,65 @@ class AbstractTest(common.TransactionCase):
self.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-html')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-html",
)
def test_qweb(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-pdf')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-pdf",
)
def test_xlsx(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type='xlsx')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type="xlsx",
)
def test_print(self):
self.report.print_report('qweb')
self.report.print_report('xlsx')
self.report.print_report("qweb")
self.report.print_report("xlsx")
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_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',
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action
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')
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.account_ids[0].name.encode('utf8') in rep[0]
)
self.assertTrue(self.report_title.encode("utf8") in rep[0])
self.assertTrue(self.report.account_ids[0].name.encode("utf8") in rep[0])
def test_04_compute_data(self):
"""Check that the SQL queries work with all filters options"""
@ -280,73 +329,69 @@ class AbstractTest(common.TransactionCase):
# Same filters with only one account
current_filter = self.base_filters.copy()
current_filter.update(filters)
report_accounts = report.account_ids.filtered('account_id')
current_filter.update({
'filter_account_ids':
[(6, 0, report_accounts[0].account_id.ids)],
})
report_accounts = report.account_ids.filtered("account_id")
current_filter.update(
{"filter_account_ids": [(6, 0, report_accounts[0].account_id.ids)],}
)
report2 = self.model.create(current_filter)
report2.compute_data_for_report()
self.assertEqual(len(report2.account_ids), 1)
self.assertEqual(report2.account_ids.name,
report_accounts[0].name)
self.assertEqual(report2.account_ids.name, report_accounts[0].name)
if self._partner_test_is_possible(filters):
# Same filters with only one partner
report_partner_ids = report.account_ids.mapped('partner_ids')
partner_ids = report_partner_ids.mapped('partner_id')
report_partner_ids = report.account_ids.mapped("partner_ids")
partner_ids = report_partner_ids.mapped("partner_id")
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update({
'filter_partner_ids': [(6, 0, partner_ids[0].ids)],
})
current_filter.update(
{"filter_partner_ids": [(6, 0, partner_ids[0].ids)],}
)
report3 = self.model.create(current_filter)
report3.compute_data_for_report()
self.assertGreaterEqual(len(report3.account_ids), 1)
report_partner_ids3 = report3.account_ids.mapped('partner_ids')
partner_ids3 = report_partner_ids3.mapped('partner_id')
report_partner_ids3 = report3.account_ids.mapped("partner_ids")
partner_ids3 = report_partner_ids3.mapped("partner_id")
self.assertEqual(len(partner_ids3), 1)
self.assertEqual(
partner_ids3.name,
partner_ids[0].name
)
self.assertEqual(partner_ids3.name, partner_ids[0].name)
# Same filters with only one partner and one account
report_partner_ids = report3.account_ids.mapped('partner_ids')
report_account_id = report_partner_ids.filtered(
lambda p: p.partner_id
)[0].report_account_id
report_partner_ids = report3.account_ids.mapped("partner_ids")
report_account_id = report_partner_ids.filtered(lambda p: p.partner_id)[
0
].report_account_id
current_filter = self.base_filters.copy()
current_filter.update(filters)
current_filter.update({
'filter_account_ids':
[(6, 0, report_account_id.account_id.ids)],
'filter_partner_ids': [(6, 0, partner_ids[0].ids)],
})
current_filter.update(
{
"filter_account_ids": [
(6, 0, report_account_id.account_id.ids)
],
"filter_partner_ids": [(6, 0, partner_ids[0].ids)],
}
)
report4 = self.model.create(current_filter)
report4.compute_data_for_report()
self.assertEqual(len(report4.account_ids), 1)
self.assertEqual(report4.account_ids.name,
report_account_id.account_id.name)
self.assertEqual(
report4.account_ids.name, report_account_id.account_id.name
)
report_partner_ids4 = report4.account_ids.mapped('partner_ids')
partner_ids4 = report_partner_ids4.mapped('partner_id')
report_partner_ids4 = report4.account_ids.mapped("partner_ids")
partner_ids4 = report_partner_ids4.mapped("partner_id")
self.assertEqual(len(partner_ids4), 1)
self.assertEqual(
partner_ids4.name,
partner_ids[0].name
)
self.assertEqual(partner_ids4.name, partner_ids[0].name)
def _partner_test_is_possible(self, filters):
"""

110
account_financial_report/tests/abstract_test_foreign_currency.py

@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from . import abstract_test
_logger = logging.getLogger(__name__)
@ -13,66 +14,81 @@ class AbstractTestForeignCurrency(abstract_test.AbstractTest):
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',
})
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_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,
})
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,
})
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

62
account_financial_report/tests/abstract_test_tax_report.py

@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging
from odoo.tests.common import TransactionCase
from odoo.tools import test_reports
@ -28,48 +29,61 @@ class AbstractTest(TransactionCase):
cls.report.compute_data_for_report()
def test_html(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-html')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-html",
)
def test_qweb(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type='qweb-pdf')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.qweb_report_name,
[self.report.id],
report_type="qweb-pdf",
)
def test_xlsx(self):
test_reports.try_report(self.env.cr, self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type='xlsx')
test_reports.try_report(
self.env.cr,
self.env.uid,
self.xlsx_report_name,
[self.report.id],
report_type="xlsx",
)
def test_print(self):
self.report.print_report('qweb')
self.report.print_report('xlsx')
self.report.print_report("qweb")
self.report.print_report("xlsx")
def test_generation_report_html(self):
"""Check if report HTML is correctly generated"""
# Check if returned report action is correct
report_type = 'qweb-html'
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',
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action
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')
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_title.encode("utf8") in rep[0])

22
account_financial_report/tests/test_aged_partner_balance.py

@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from . import abstract_test
@ -12,30 +13,29 @@ class TestAgedPartnerBalance(abstract_test.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_aged_partner_balance']
return self.env["report_aged_partner_balance"]
def _getQwebReportName(self):
return 'account_financial_report.report_aged_partner_balance_qweb'
return "account_financial_report.report_aged_partner_balance_qweb"
def _getXlsxReportName(self):
return 'a_f_r.report_aged_partner_balance_xlsx'
return "a_f_r.report_aged_partner_balance_xlsx"
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_aged_partner_balance_xlsx'
return "account_financial_report." "action_report_aged_partner_balance_xlsx"
def _getReportTitle(self):
return 'Odoo'
return "Odoo"
def _getBaseFilters(self):
return {
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
"date_at": date(date.today().year, 12, 31),
"company_id": self.company.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'only_posted_moves': True},
{'show_move_line_details': True},
{'only_posted_moves': True, 'show_move_line_details': True},
{"only_posted_moves": True},
{"show_move_line_details": True},
{"only_posted_moves": True, "show_move_line_details": True},
]

574
account_financial_report/tests/test_general_ledger.py

@ -3,10 +3,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from odoo.tests import common
from odoo import fields
from datetime import date
from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c
@ -16,179 +17,195 @@ class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
def _getReportModel(self):
return self.env['report_general_ledger']
return self.env["report_general_ledger"]
def _getQwebReportName(self):
return 'account_financial_report.report_general_ledger_qweb'
return "account_financial_report.report_general_ledger_qweb"
def _getXlsxReportName(self):
return 'a_f_r.report_general_ledger_xlsx'
return "a_f_r.report_general_ledger_xlsx"
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_general_ledger_xlsx'
return "account_financial_report." "action_report_general_ledger_xlsx"
def _getReportTitle(self):
return 'Odoo'
return "Odoo"
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'fy_start_date': date(date.today().year, 1, 1),
'foreign_currency': True,
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 12, 31),
"company_id": self.company.id,
"fy_start_date": date(date.today().year, 1, 1),
"foreign_currency": True,
}
def _getAdditionalFiltersToBeTested(self):
additional_filters = [
{'only_posted_moves': True},
{'hide_account_at_0': True},
{'centralize': True},
{'only_posted_moves': True, 'hide_account_at_0': True},
{'only_posted_moves': True, 'centralize': True},
{'hide_account_at_0': True, 'centralize': True},
{
'only_posted_moves': True,
'hide_account_at_0': True,
'centralize': True
},
{"only_posted_moves": True},
{"hide_account_at_0": True},
{"centralize": True},
{"only_posted_moves": True, "hide_account_at_0": True},
{"only_posted_moves": True, "centralize": True},
{"hide_account_at_0": True, "centralize": True},
{"only_posted_moves": True, "hide_account_at_0": True, "centralize": True},
]
# Add `show_analytic_tags` filter on each cases
additional_filters_with_show_tags = []
for additional_filter in additional_filters:
additional_filter['show_analytic_tags'] = True
additional_filters_with_show_tags.append(
additional_filter
)
additional_filter["show_analytic_tags"] = True
additional_filters_with_show_tags.append(additional_filter)
additional_filters += additional_filters_with_show_tags
# Add `filter_analytic_tag_ids` filter on each cases
analytic_tag = self.env['account.analytic.tag'].create({
'name': 'TEST tag'
})
analytic_tag = self.env["account.analytic.tag"].create({"name": "TEST tag"})
# Define all move lines on this tag
# (this test just check with the all filters, all works technically)
move_lines = self.env['account.move.line'].search([])
move_lines.write({
'analytic_tag_ids': [(6, False, analytic_tag.ids)],
})
move_lines = self.env["account.move.line"].search([])
move_lines.write(
{"analytic_tag_ids": [(6, False, analytic_tag.ids)],}
)
additional_filters_with_filter_tags = []
for additional_filter in additional_filters:
additional_filter['filter_analytic_tag_ids'] = [
additional_filter["filter_analytic_tag_ids"] = [
(6, False, analytic_tag.ids)
]
additional_filters_with_filter_tags.append(
additional_filter
)
additional_filters_with_filter_tags.append(additional_filter)
additional_filters += additional_filters_with_filter_tags
return additional_filters
class TestGeneralLedgerReport(common.TransactionCase):
def setUp(self):
super(TestGeneralLedgerReport, self).setUp()
self.before_previous_fy_year = fields.Date.from_string('2014-05-05')
self.previous_fy_date_start = fields.Date.from_string('2015-01-01')
self.previous_fy_date_end = fields.Date.from_string('2015-12-31')
self.fy_date_start = fields.Date.from_string('2016-01-01')
self.fy_date_end = fields.Date.from_string('2016-12-31')
self.receivable_account = self.env['account.account'].search([
('user_type_id.name', '=', 'Receivable')
], limit=1)
self.income_account = self.env['account.account'].search([
('user_type_id.name', '=', 'Income')
], limit=1)
self.unaffected_account = self.env['account.account'].search([
(
'user_type_id',
'=',
self.env.ref('account.data_unaffected_earnings').id
)], limit=1)
self.before_previous_fy_year = fields.Date.from_string("2014-05-05")
self.previous_fy_date_start = fields.Date.from_string("2015-01-01")
self.previous_fy_date_end = fields.Date.from_string("2015-12-31")
self.fy_date_start = fields.Date.from_string("2016-01-01")
self.fy_date_end = fields.Date.from_string("2016-12-31")
self.receivable_account = self.env["account.account"].search(
[("user_type_id.name", "=", "Receivable")], limit=1
)
self.income_account = self.env["account.account"].search(
[("user_type_id.name", "=", "Income")], limit=1
)
self.unaffected_account = self.env["account.account"].search(
[
(
"user_type_id",
"=",
self.env.ref("account.data_unaffected_earnings").id,
)
],
limit=1,
)
def _add_move(
self,
date,
receivable_debit,
receivable_credit,
income_debit,
income_credit,
unaffected_debit=0,
unaffected_credit=0
self,
date,
receivable_debit,
receivable_credit,
income_debit,
income_credit,
unaffected_debit=0,
unaffected_credit=0,
):
move_name = 'expense accrual'
journal = self.env['account.journal'].search([], limit=1)
partner = self.env.ref('base.res_partner_12')
move_name = "expense accrual"
journal = self.env["account.journal"].search([], limit=1)
partner = self.env.ref("base.res_partner_12")
move_vals = {
'journal_id': journal.id,
'name': move_name,
'date': date,
'line_ids': [
(0, 0, {
'name': move_name,
'debit': receivable_debit,
'credit': receivable_credit,
'account_id': self.receivable_account.id,
'partner_id': partner.id}),
(0, 0, {
'name': move_name,
'debit': income_debit,
'credit': income_credit,
'account_id': self.income_account.id,
'partner_id': partner.id}),
(0, 0, {
'name': move_name,
'debit': unaffected_debit,
'credit': unaffected_credit,
'account_id': self.unaffected_account.id,
'partner_id': partner.id}),
]}
move = self.env['account.move'].create(move_vals)
"journal_id": journal.id,
"name": move_name,
"date": date,
"line_ids": [
(
0,
0,
{
"name": move_name,
"debit": receivable_debit,
"credit": receivable_credit,
"account_id": self.receivable_account.id,
"partner_id": partner.id,
},
),
(
0,
0,
{
"name": move_name,
"debit": income_debit,
"credit": income_credit,
"account_id": self.income_account.id,
"partner_id": partner.id,
},
),
(
0,
0,
{
"name": move_name,
"debit": unaffected_debit,
"credit": unaffected_credit,
"account_id": self.unaffected_account.id,
"partner_id": partner.id,
},
),
],
}
move = self.env["account.move"].create(move_vals)
move.post()
def _get_report_lines(self, with_partners=False):
company = self.env.ref('base.main_company')
general_ledger = self.env['report_general_ledger'].create({
'date_from': self.fy_date_start,
'date_to': self.fy_date_end,
'only_posted_moves': True,
'hide_account_at_0': False,
'company_id': company.id,
'fy_start_date': self.fy_date_start,
})
company = self.env.ref("base.main_company")
general_ledger = self.env["report_general_ledger"].create(
{
"date_from": self.fy_date_start,
"date_to": self.fy_date_end,
"only_posted_moves": True,
"hide_account_at_0": False,
"company_id": company.id,
"fy_start_date": self.fy_date_start,
}
)
general_ledger.compute_data_for_report(
with_line_details=True, with_partners=with_partners
)
lines = {}
report_account_model = self.env['report_general_ledger_account']
lines['receivable'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.receivable_account.id),
])
lines['income'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.income_account.id),
])
lines['unaffected'] = report_account_model.search([
('report_id', '=', general_ledger.id),
('account_id', '=', self.unaffected_account.id),
])
if with_partners:
report_partner_model = self.env[
'report_general_ledger_partner'
report_account_model = self.env["report_general_ledger_account"]
lines["receivable"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.receivable_account.id),
]
lines['partner_receivable'] = report_partner_model.search([
('report_account_id', '=', lines['receivable'].id),
('partner_id', '=', self.env.ref('base.res_partner_12').id),
])
)
lines["income"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.income_account.id),
]
)
lines["unaffected"] = report_account_model.search(
[
("report_id", "=", general_ledger.id),
("account_id", "=", self.unaffected_account.id),
]
)
if with_partners:
report_partner_model = self.env["report_general_ledger_partner"]
lines["partner_receivable"] = report_partner_model.search(
[
("report_account_id", "=", lines["receivable"].id),
("partner_id", "=", self.env.ref("base.res_partner_12").id),
]
)
return lines
def test_01_account_balance(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 0)
self.assertEqual(len(lines['income']), 0)
self.assertEqual(len(lines["receivable"]), 0)
self.assertEqual(len(lines["income"]), 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -197,21 +214,21 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=1000,
receivable_credit=0,
income_debit=0,
income_credit=1000
income_credit=1000,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 0)
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 0)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 0)
self.assertEqual(lines['receivable'].final_balance, 1000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 0)
self.assertEqual(lines["receivable"].final_balance, 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -221,28 +238,28 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=0,
receivable_credit=1000,
income_debit=1000,
income_credit=0
income_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 1)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 1000)
self.assertEqual(lines['receivable'].final_balance, 0)
self.assertEqual(lines['income'].initial_debit, 0)
self.assertEqual(lines['income'].initial_credit, 0)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].final_debit, 1000)
self.assertEqual(lines['income'].final_credit, 0)
self.assertEqual(lines['income'].final_balance, 1000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 1000)
self.assertEqual(lines["receivable"].final_balance, 0)
self.assertEqual(lines["income"].initial_debit, 0)
self.assertEqual(lines["income"].initial_credit, 0)
self.assertEqual(lines["income"].initial_balance, 0)
self.assertEqual(lines["income"].final_debit, 1000)
self.assertEqual(lines["income"].final_credit, 0)
self.assertEqual(lines["income"].final_balance, 1000)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -251,33 +268,33 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=0,
receivable_credit=1000,
income_debit=1000,
income_credit=0
income_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['receivable']), 1)
self.assertEqual(len(lines['income']), 1)
self.assertEqual(len(lines["receivable"]), 1)
self.assertEqual(len(lines["income"]), 1)
# Check the initial and final balance
self.assertEqual(lines['receivable'].initial_debit, 1000)
self.assertEqual(lines['receivable'].initial_credit, 0)
self.assertEqual(lines['receivable'].initial_balance, 1000)
self.assertEqual(lines['receivable'].final_debit, 1000)
self.assertEqual(lines['receivable'].final_credit, 2000)
self.assertEqual(lines['receivable'].final_balance, -1000)
self.assertEqual(lines['income'].initial_debit, 0)
self.assertEqual(lines['income'].initial_credit, 0)
self.assertEqual(lines['income'].initial_balance, 0)
self.assertEqual(lines['income'].final_debit, 2000)
self.assertEqual(lines['income'].final_credit, 0)
self.assertEqual(lines['income'].final_balance, 2000)
self.assertEqual(lines["receivable"].initial_debit, 1000)
self.assertEqual(lines["receivable"].initial_credit, 0)
self.assertEqual(lines["receivable"].initial_balance, 1000)
self.assertEqual(lines["receivable"].final_debit, 1000)
self.assertEqual(lines["receivable"].final_credit, 2000)
self.assertEqual(lines["receivable"].final_balance, -1000)
self.assertEqual(lines["income"].initial_debit, 0)
self.assertEqual(lines["income"].initial_credit, 0)
self.assertEqual(lines["income"].initial_balance, 0)
self.assertEqual(lines["income"].final_debit, 2000)
self.assertEqual(lines["income"].final_credit, 0)
self.assertEqual(lines["income"].final_balance, 2000)
def test_02_partner_balance(self):
# Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 0)
self.assertEqual(len(lines["partner_receivable"]), 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -286,20 +303,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=1000,
receivable_credit=0,
income_debit=0,
income_credit=1000
income_credit=1000,
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 0)
self.assertEqual(lines['partner_receivable'].final_balance, 1000)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 0)
self.assertEqual(lines["partner_receivable"].final_balance, 1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -309,20 +326,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=0,
receivable_credit=1000,
income_debit=1000,
income_credit=0
income_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 1000)
self.assertEqual(lines['partner_receivable'].final_balance, 0)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 1000)
self.assertEqual(lines["partner_receivable"].final_balance, 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -331,33 +348,33 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=0,
receivable_credit=1000,
income_debit=1000,
income_credit=0
income_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines(with_partners=True)
self.assertEqual(len(lines['partner_receivable']), 1)
self.assertEqual(len(lines["partner_receivable"]), 1)
# Check the initial and final balance
self.assertEqual(lines['partner_receivable'].initial_debit, 1000)
self.assertEqual(lines['partner_receivable'].initial_credit, 0)
self.assertEqual(lines['partner_receivable'].initial_balance, 1000)
self.assertEqual(lines['partner_receivable'].final_debit, 1000)
self.assertEqual(lines['partner_receivable'].final_credit, 2000)
self.assertEqual(lines['partner_receivable'].final_balance, -1000)
self.assertEqual(lines["partner_receivable"].initial_debit, 1000)
self.assertEqual(lines["partner_receivable"].initial_credit, 0)
self.assertEqual(lines["partner_receivable"].initial_balance, 1000)
self.assertEqual(lines["partner_receivable"].final_debit, 1000)
self.assertEqual(lines["partner_receivable"].final_credit, 2000)
self.assertEqual(lines["partner_receivable"].final_balance, -1000)
def test_03_unaffected_account_balance(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 0)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 0)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add a move at the previous day of the first day of fiscal year
# to check the initial balance
@ -366,20 +383,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=1000,
receivable_credit=0,
income_debit=0,
income_credit=1000
income_credit=1000,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, -1000)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 1000)
self.assertEqual(lines["unaffected"].final_balance, -1000)
# Add reversale move of the initial move the first day of fiscal year
# to check the first day of fiscal year is not used
@ -391,20 +408,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
income_debit=0,
income_credit=1000,
unaffected_debit=1000,
unaffected_credit=0
unaffected_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 1000)
self.assertEqual(lines['unaffected'].final_balance, 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 1000)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add another move at the end day of fiscal year
# to check that it correctly used on report
@ -415,33 +432,33 @@ class TestGeneralLedgerReport(common.TransactionCase):
income_debit=0,
income_credit=0,
unaffected_debit=0,
unaffected_credit=3000
unaffected_credit=3000,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 1000)
self.assertEqual(lines['unaffected'].initial_balance, -1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 4000)
self.assertEqual(lines['unaffected'].final_balance, -3000)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 1000)
self.assertEqual(lines["unaffected"].initial_balance, -1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 4000)
self.assertEqual(lines["unaffected"].final_balance, -3000)
def test_04_unaffected_account_balance_2_years(self):
# Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 0)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 0)
self.assertEqual(lines['unaffected'].final_debit, 0)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 0)
self.assertEqual(lines["unaffected"].initial_debit, 0)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 0)
self.assertEqual(lines["unaffected"].final_debit, 0)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 0)
# Add a move at any date 2 years before the balance
# (to create an historic)
@ -450,20 +467,20 @@ class TestGeneralLedgerReport(common.TransactionCase):
receivable_debit=0,
receivable_credit=1000,
income_debit=1000,
income_credit=0
income_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 1000)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 1000)
self.assertEqual(lines['unaffected'].final_debit, 1000)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 1000)
self.assertEqual(lines["unaffected"].initial_debit, 1000)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 1000)
self.assertEqual(lines["unaffected"].final_debit, 1000)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 1000)
# Affect the company's result last year
self._add_move(
@ -473,7 +490,7 @@ class TestGeneralLedgerReport(common.TransactionCase):
income_debit=0,
income_credit=0,
unaffected_debit=0,
unaffected_credit=1000
unaffected_credit=1000,
)
# Add another move last year to test the initial balance this year
@ -484,70 +501,63 @@ class TestGeneralLedgerReport(common.TransactionCase):
income_debit=500,
income_credit=0,
unaffected_debit=0,
unaffected_credit=0
unaffected_credit=0,
)
# Re Generate the general ledger line
lines = self._get_report_lines()
self.assertEqual(len(lines['unaffected']), 1)
self.assertEqual(len(lines["unaffected"]), 1)
# Check the initial and final balance
self.assertEqual(lines['unaffected'].initial_debit, 500)
self.assertEqual(lines['unaffected'].initial_credit, 0)
self.assertEqual(lines['unaffected'].initial_balance, 500)
self.assertEqual(lines['unaffected'].final_debit, 500)
self.assertEqual(lines['unaffected'].final_credit, 0)
self.assertEqual(lines['unaffected'].final_balance, 500)
self.assertEqual(lines["unaffected"].initial_debit, 500)
self.assertEqual(lines["unaffected"].initial_credit, 0)
self.assertEqual(lines["unaffected"].initial_balance, 500)
self.assertEqual(lines["unaffected"].final_debit, 500)
self.assertEqual(lines["unaffected"].final_credit, 0)
self.assertEqual(lines["unaffected"].final_balance, 500)
def test_partner_filter(self):
partner_1 = self.env.ref('base.res_partner_1')
partner_2 = self.env.ref('base.res_partner_2')
partner_3 = self.env.ref('base.res_partner_3')
partner_4 = self.env.ref('base.res_partner_4')
partner_1.write({'is_company': False,
'parent_id': partner_2.id})
partner_3.write({'is_company': False})
partner_1 = self.env.ref("base.res_partner_1")
partner_2 = self.env.ref("base.res_partner_2")
partner_3 = self.env.ref("base.res_partner_3")
partner_4 = self.env.ref("base.res_partner_4")
partner_1.write({"is_company": False, "parent_id": partner_2.id})
partner_3.write({"is_company": False})
expected_list = [partner_2.id, partner_3.id, partner_4.id]
context = {
'active_ids': [
partner_1.id, partner_2.id, partner_3.id, partner_4.id
],
'active_model': 'res.partner'
}
"active_ids": [partner_1.id, partner_2.id, partner_3.id, partner_4.id],
"active_model": "res.partner",
}
wizard = self.env["general.ledger.report.wizard"].with_context(context)
self.assertEqual(wizard._default_partners(), expected_list)
def test_validate_date(self):
company_id = self.env.ref('base.main_company')
company_id.write({
'fiscalyear_last_day': 31,
'fiscalyear_last_month': 12,
})
user = self.env.ref('base.user_root').with_context(
company_id=company_id.id)
wizard = self.env["general.ledger.report.wizard"].with_context(
user=user.id
company_id = self.env.ref("base.main_company")
company_id.write(
{"fiscalyear_last_day": 31, "fiscalyear_last_month": 12,}
)
self.assertEqual(wizard._init_date_from(),
time.strftime('%Y') + '-01-01')
user = self.env.ref("base.user_root").with_context(company_id=company_id.id)
wizard = self.env["general.ledger.report.wizard"].with_context(user=user.id)
self.assertEqual(wizard._init_date_from(), time.strftime("%Y") + "-01-01")
def test_validate_date_range(self):
data_type = self.env['date.range.type'].create({
'name': 'Fiscal year',
'company_id': False,
'allow_overlap': False
})
dr = self.env['date.range'].create({
'name': 'FS2015',
'date_start': '2018-01-01',
'date_end': '2018-12-31',
'type_id': data_type.id,
})
wizard = self.env["general.ledger.report.wizard"].create({
'date_range_id': dr.id})
data_type = self.env["date.range.type"].create(
{"name": "Fiscal year", "company_id": False, "allow_overlap": False}
)
dr = self.env["date.range"].create(
{
"name": "FS2015",
"date_start": "2018-01-01",
"date_end": "2018-12-31",
"type_id": data_type.id,
}
)
wizard = self.env["general.ledger.report.wizard"].create(
{"date_range_id": dr.id}
)
wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, date(2018, 1, 1))
self.assertEqual(wizard.date_to, date(2018, 12, 31))

500
account_financial_report/tests/test_journal_ledger.py

@ -1,7 +1,8 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import datetime, date
from datetime import date, datetime
from dateutil.relativedelta import relativedelta
from odoo.fields import Date
@ -14,260 +15,291 @@ class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency):
"""
Technical tests for General Ledger Report.
"""
def _getReportModel(self):
return self.env['report_journal_ledger']
return self.env["report_journal_ledger"]
def _getQwebReportName(self):
return 'account_financial_report.report_journal_ledger_qweb'
return "account_financial_report.report_journal_ledger_qweb"
def _getXlsxReportName(self):
return 'a_f_r.report_journal_ledger_xlsx'
return "a_f_r.report_journal_ledger_xlsx"
def _getXlsxReportActionName(self):
return 'account_financial_report.' \
'action_report_journal_ledger_xlsx'
return "account_financial_report." "action_report_journal_ledger_xlsx"
def _getReportTitle(self):
return 'Odoo'
return "Odoo"
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 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},
{
"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_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',
"type": "ir.actions.report",
"report_name": self.qweb_report_name,
"report_type": "qweb-html",
},
report_action
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')
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]
)
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.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')
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')
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'
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
}),
]
"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, report, expected_debit, expected_credit
):
self.assertEqual(
expected_debit,
sum([journal.debit for journal in
report.report_journal_ledger_ids])
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])
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,
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
])
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
])
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
])
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
])
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)]
})
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)
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.move_target = "posted"
report.compute_data_for_report()
self.check_report_journal_debit_credit(report, 0, 0)
@ -289,37 +321,47 @@ class TestJournalReport(TransactionCase):
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
])],
})
]
"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 = 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)
@ -327,37 +369,47 @@ class TestJournalReport(TransactionCase):
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
])],
})
]
"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 = 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)

44
account_financial_report/tests/test_open_items.py

@ -3,6 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c
@ -12,50 +13,47 @@ class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
"""
def _getReportModel(self):
return self.env['report_open_items']
return self.env["report_open_items"]
def _getQwebReportName(self):
return 'account_financial_report.report_open_items_qweb'
return "account_financial_report.report_open_items_qweb"
def _getXlsxReportName(self):
return 'a_f_r.report_open_items_xlsx'
return "a_f_r.report_open_items_xlsx"
def _getXlsxReportActionName(self):
return 'account_financial_report.action_report_open_items_xlsx'
return "account_financial_report.action_report_open_items_xlsx"
def _getReportTitle(self):
return 'Odoo'
return "Odoo"
def _getBaseFilters(self):
return {
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
'foreign_currency': True,
"date_at": date(date.today().year, 12, 31),
"company_id": self.company.id,
"foreign_currency": True,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'only_posted_moves': True},
{'hide_account_at_0': True},
{'only_posted_moves': True, 'hide_account_at_0': True},
{"only_posted_moves": True},
{"hide_account_at_0": True},
{"only_posted_moves": True, "hide_account_at_0": True},
]
def test_partner_filter(self):
partner_1 = self.env.ref('base.res_partner_1')
partner_2 = self.env.ref('base.res_partner_2')
partner_3 = self.env.ref('base.res_partner_3')
partner_4 = self.env.ref('base.res_partner_4')
partner_1.write({'is_company': False,
'parent_id': partner_2.id})
partner_3.write({'is_company': False})
partner_1 = self.env.ref("base.res_partner_1")
partner_2 = self.env.ref("base.res_partner_2")
partner_3 = self.env.ref("base.res_partner_3")
partner_4 = self.env.ref("base.res_partner_4")
partner_1.write({"is_company": False, "parent_id": partner_2.id})
partner_3.write({"is_company": False})
expected_list = [partner_2.id, partner_3.id, partner_4.id]
context = {
'active_ids': [
partner_1.id, partner_2.id, partner_3.id, partner_4.id
],
'active_model': 'res.partner'
}
"active_ids": [partner_1.id, partner_2.id, partner_3.id, partner_4.id],
"active_model": "res.partner",
}
wizard = self.env["open.items.report.wizard"].with_context(context)
self.assertEqual(wizard._default_partners(), expected_list)

911
account_financial_report/tests/test_trial_balance.py
File diff suppressed because it is too large
View File

494
account_financial_report/tests/test_vat_report.py

@ -3,7 +3,9 @@
import time
from datetime import date
from odoo.tests import common
from . import abstract_test_tax_report
@ -13,202 +15,231 @@ class TestVAT(abstract_test_tax_report.AbstractTest):
"""
def _getReportModel(self):
return self.env['report_vat_report']
return self.env["report_vat_report"]
def _getQwebReportName(self):
return 'account_financial_report.report_vat_report_qweb'
return "account_financial_report.report_vat_report_qweb"
def _getXlsxReportName(self):
return 'a_f_r.report_vat_report_xlsx'
return "a_f_r.report_vat_report_xlsx"
def _getXlsxReportActionName(self):
return 'account_financial_report.action_report_vat_report_xlsx'
return "account_financial_report.action_report_vat_report_xlsx"
def _getReportTitle(self):
return 'Odoo'
return "Odoo"
def _getBaseFilters(self):
return {
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.env.user.company_id.id,
"date_from": date(date.today().year, 1, 1),
"date_to": date(date.today().year, 12, 31),
"company_id": self.env.user.company_id.id,
}
def _getAdditionalFiltersToBeTested(self):
return [
{'based_on': 'taxtags'},
{'based_on': 'taxgroups'},
{'tax_details': True},
{'based_on': 'taxtags', 'tax_details': True},
{'based_on': 'taxgroups', 'tax_details': True},
{"based_on": "taxtags"},
{"based_on": "taxgroups"},
{"tax_details": True},
{"based_on": "taxtags", "tax_details": True},
{"based_on": "taxgroups", "tax_details": True},
]
class TestVATReport(common.TransactionCase):
def setUp(self):
super(TestVATReport, self).setUp()
self.date_from = time.strftime('%Y-%m-01')
self.date_to = time.strftime('%Y-%m-28')
self.company = self.env.ref('base.main_company')
self.receivable_account = self.env['account.account'].search([
('company_id', '=', self.company.id),
('user_type_id.name', '=', 'Receivable')
], limit=1)
self.income_account = self.env['account.account'].search([
('company_id', '=', self.company.id),
('user_type_id.name', '=', 'Income')
], limit=1)
self.tax_account = self.env['account.account'].search([
('company_id', '=', self.company.id),
('user_type_id',
'=',
self.env.ref(
'account.data_account_type_non_current_liabilities').id)
], limit=1)
self.bank_journal = self.env['account.journal'].search([
('type', '=', 'bank'), ('company_id', '=', self.company.id)
], limit=1)
self.tax_tag_01 = self.env['account.account.tag'].create({
'name': 'Tag 01',
'applicability': 'taxes'
})
self.tax_tag_02 = self.env['account.account.tag'].create({
'name': 'Tag 02',
'applicability': 'taxes'
})
self.tax_tag_03 = self.env['account.account.tag'].create({
'name': 'Tag 03',
'applicability': 'taxes'
})
self.tax_group_10 = self.env['account.tax.group'].create({
'name': 'Tax 10%',
'sequence': 1
})
self.tax_group_20 = self.env['account.tax.group'].create({
'name': 'Tax 20%',
'sequence': 2
})
self.tax_10 = self.env['account.tax'].create({
'name': 'Tax 10.0%',
'amount': 10.0,
'amount_type': 'percent',
'type_tax_use': 'sale',
'account_id': self.tax_account.id,
'company_id': self.company.id,
'refund_account_id': self.tax_account.id,
'tax_group_id': self.tax_group_10.id,
'tag_ids': [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])]
})
self.tax_20 = self.env['account.tax'].create({
'sequence': 30,
'name': 'Tax 20.0%',
'amount': 20.0,
'amount_type': 'percent',
'type_tax_use': 'sale',
'tax_exigibility': 'on_payment',
'account_id': self.tax_account.id,
'company_id': self.company.id,
'refund_account_id': self.tax_account.id,
'cash_basis_account_id': self.tax_account.id,
'tax_group_id': self.tax_group_20.id,
'tag_ids': [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])]
})
self.date_from = time.strftime("%Y-%m-01")
self.date_to = time.strftime("%Y-%m-28")
self.company = self.env.ref("base.main_company")
self.receivable_account = self.env["account.account"].search(
[
("company_id", "=", self.company.id),
("user_type_id.name", "=", "Receivable"),
],
limit=1,
)
self.income_account = self.env["account.account"].search(
[
("company_id", "=", self.company.id),
("user_type_id.name", "=", "Income"),
],
limit=1,
)
self.tax_account = self.env["account.account"].search(
[
("company_id", "=", self.company.id),
(
"user_type_id",
"=",
self.env.ref(
"account.data_account_type_non_current_liabilities"
).id,
),
],
limit=1,
)
self.bank_journal = self.env["account.journal"].search(
[("type", "=", "bank"), ("company_id", "=", self.company.id)], limit=1
)
self.tax_tag_01 = self.env["account.account.tag"].create(
{"name": "Tag 01", "applicability": "taxes"}
)
self.tax_tag_02 = self.env["account.account.tag"].create(
{"name": "Tag 02", "applicability": "taxes"}
)
self.tax_tag_03 = self.env["account.account.tag"].create(
{"name": "Tag 03", "applicability": "taxes"}
)
self.tax_group_10 = self.env["account.tax.group"].create(
{"name": "Tax 10%", "sequence": 1}
)
self.tax_group_20 = self.env["account.tax.group"].create(
{"name": "Tax 20%", "sequence": 2}
)
self.tax_10 = self.env["account.tax"].create(
{
"name": "Tax 10.0%",
"amount": 10.0,
"amount_type": "percent",
"type_tax_use": "sale",
"account_id": self.tax_account.id,
"company_id": self.company.id,
"refund_account_id": self.tax_account.id,
"tax_group_id": self.tax_group_10.id,
"tag_ids": [(6, 0, [self.tax_tag_01.id, self.tax_tag_02.id])],
}
)
self.tax_20 = self.env["account.tax"].create(
{
"sequence": 30,
"name": "Tax 20.0%",
"amount": 20.0,
"amount_type": "percent",
"type_tax_use": "sale",
"tax_exigibility": "on_payment",
"account_id": self.tax_account.id,
"company_id": self.company.id,
"refund_account_id": self.tax_account.id,
"cash_basis_account_id": self.tax_account.id,
"tax_group_id": self.tax_group_20.id,
"tag_ids": [(6, 0, [self.tax_tag_02.id, self.tax_tag_03.id])],
}
)
invoice = self.env['account.invoice'].create({
'partner_id': self.env.ref('base.res_partner_2').id,
'account_id': self.receivable_account.id,
'company_id': self.company.id,
'date_invoice': time.strftime('%Y-%m-03'),
'type': 'out_invoice',
})
invoice = self.env["account.invoice"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
"account_id": self.receivable_account.id,
"company_id": self.company.id,
"date_invoice": time.strftime("%Y-%m-03"),
"type": "out_invoice",
}
)
self.env['account.invoice.line'].create({
'product_id': self.env.ref('product.product_product_4').id,
'quantity': 1.0,
'price_unit': 100.0,
'invoice_id': invoice.id,
'name': 'product',
'account_id': self.income_account.id,
'invoice_line_tax_ids': [(6, 0, [self.tax_10.id])],
})
self.env["account.invoice.line"].create(
{
"product_id": self.env.ref("product.product_product_4").id,
"quantity": 1.0,
"price_unit": 100.0,
"invoice_id": invoice.id,
"name": "product",
"account_id": self.income_account.id,
"invoice_line_tax_ids": [(6, 0, [self.tax_10.id])],
}
)
invoice.compute_taxes()
invoice.action_invoice_open()
self.cbinvoice = self.env['account.invoice'].create({
'partner_id': self.env.ref('base.res_partner_2').id,
'account_id': self.receivable_account.id,
'company_id': self.company.id,
'date_invoice': time.strftime('%Y-%m-05'),
'type': 'out_invoice',
})
self.cbinvoice = self.env["account.invoice"].create(
{
"partner_id": self.env.ref("base.res_partner_2").id,
"account_id": self.receivable_account.id,
"company_id": self.company.id,
"date_invoice": time.strftime("%Y-%m-05"),
"type": "out_invoice",
}
)
self.env['account.invoice.line'].create({
'product_id': self.env.ref('product.product_product_4').id,
'quantity': 1.0,
'price_unit': 500.0,
'invoice_id': self.cbinvoice.id,
'name': 'product',
'account_id': self.income_account.id,
'invoice_line_tax_ids': [(6, 0, [self.tax_20.id])],
})
self.env["account.invoice.line"].create(
{
"product_id": self.env.ref("product.product_product_4").id,
"quantity": 1.0,
"price_unit": 500.0,
"invoice_id": self.cbinvoice.id,
"name": "product",
"account_id": self.income_account.id,
"invoice_line_tax_ids": [(6, 0, [self.tax_20.id])],
}
)
self.cbinvoice.compute_taxes()
self.cbinvoice.action_invoice_open()
def _get_report_lines(self):
self.cbinvoice.pay_and_reconcile(
self.bank_journal.id, 300, date(
date.today().year, date.today().month, 10))
vat_report = self.env['report_vat_report'].create({
'date_from': self.date_from,
'date_to': self.date_to,
'company_id': self.company.id,
'based_on': 'taxtags',
'tax_detail': True,
})
self.bank_journal.id, 300, date(date.today().year, date.today().month, 10)
)
vat_report = self.env["report_vat_report"].create(
{
"date_from": self.date_from,
"date_to": self.date_to,
"company_id": self.company.id,
"based_on": "taxtags",
"tax_detail": True,
}
)
vat_report.compute_data_for_report()
lines = {}
vat_taxtag_model = self.env['report_vat_report_taxtag']
lines['tag_01'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_01.id),
])
lines['tag_02'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_02.id),
])
lines['tag_03'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxtag_id', '=', self.tax_tag_03.id),
])
vat_tax_model = self.env['report_vat_report_tax']
lines['tax_10'] = vat_tax_model.search([
('report_tax_id', '=', lines['tag_02'].id),
('tax_id', '=', self.tax_10.id),
])
lines['tax_20'] = vat_tax_model.search([
('report_tax_id', '=', lines['tag_02'].id),
('tax_id', '=', self.tax_20.id),
])
vat_report['based_on'] = 'taxgroups'
vat_taxtag_model = self.env["report_vat_report_taxtag"]
lines["tag_01"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_01.id),]
)
lines["tag_02"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_02.id),]
)
lines["tag_03"] = vat_taxtag_model.search(
[("report_id", "=", vat_report.id), ("taxtag_id", "=", self.tax_tag_03.id),]
)
vat_tax_model = self.env["report_vat_report_tax"]
lines["tax_10"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["tag_02"].id),
("tax_id", "=", self.tax_10.id),
]
)
lines["tax_20"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["tag_02"].id),
("tax_id", "=", self.tax_20.id),
]
)
vat_report["based_on"] = "taxgroups"
vat_report.compute_data_for_report()
lines['group_10'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxgroup_id', '=', self.tax_group_10.id),
])
lines['group_20'] = vat_taxtag_model.search([
('report_id', '=', vat_report.id),
('taxgroup_id', '=', self.tax_group_20.id),
])
vat_tax_model = self.env['report_vat_report_tax']
lines['tax_group_10'] = vat_tax_model.search([
('report_tax_id', '=', lines['group_10'].id),
('tax_id', '=', self.tax_10.id),
])
lines['tax_group_20'] = vat_tax_model.search([
('report_tax_id', '=', lines['group_20'].id),
('tax_id', '=', self.tax_20.id),
])
lines["group_10"] = vat_taxtag_model.search(
[
("report_id", "=", vat_report.id),
("taxgroup_id", "=", self.tax_group_10.id),
]
)
lines["group_20"] = vat_taxtag_model.search(
[
("report_id", "=", vat_report.id),
("taxgroup_id", "=", self.tax_group_20.id),
]
)
vat_tax_model = self.env["report_vat_report_tax"]
lines["tax_group_10"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["group_10"].id),
("tax_id", "=", self.tax_10.id),
]
)
lines["tax_group_20"] = vat_tax_model.search(
[
("report_tax_id", "=", lines["group_20"].id),
("tax_id", "=", self.tax_20.id),
]
)
return lines
def test_01_compute(self):
@ -216,85 +247,98 @@ class TestVATReport(common.TransactionCase):
lines = self._get_report_lines()
# Check report based on taxtags
self.assertEqual(len(lines['tag_01']), 1)
self.assertEqual(len(lines['tag_02']), 1)
self.assertEqual(len(lines['tag_03']), 1)
self.assertEqual(len(lines['tax_10']), 1)
self.assertEqual(len(lines['tax_20']), 1)
self.assertEqual(lines['tag_01'].net, 100)
self.assertEqual(lines['tag_01'].tax, 10)
self.assertEqual(lines['tag_02'].net, 350)
self.assertEqual(lines['tag_02'].tax, 60)
self.assertEqual(lines['tag_03'].net, 250)
self.assertEqual(lines['tag_03'].tax, 50)
self.assertEqual(lines['tax_10'].net, 100)
self.assertEqual(lines['tax_10'].tax, 10)
self.assertEqual(lines['tax_20'].net, 250)
self.assertEqual(lines['tax_20'].tax, 50)
self.assertEqual(len(lines["tag_01"]), 1)
self.assertEqual(len(lines["tag_02"]), 1)
self.assertEqual(len(lines["tag_03"]), 1)
self.assertEqual(len(lines["tax_10"]), 1)
self.assertEqual(len(lines["tax_20"]), 1)
self.assertEqual(lines["tag_01"].net, 100)
self.assertEqual(lines["tag_01"].tax, 10)
self.assertEqual(lines["tag_02"].net, 350)
self.assertEqual(lines["tag_02"].tax, 60)
self.assertEqual(lines["tag_03"].net, 250)
self.assertEqual(lines["tag_03"].tax, 50)
self.assertEqual(lines["tax_10"].net, 100)
self.assertEqual(lines["tax_10"].tax, 10)
self.assertEqual(lines["tax_20"].net, 250)
self.assertEqual(lines["tax_20"].tax, 50)
# Check report based on taxgroups
self.assertEqual(len(lines['group_10']), 1)
self.assertEqual(len(lines['group_20']), 1)
self.assertEqual(len(lines['tax_group_10']), 1)
self.assertEqual(len(lines['tax_group_20']), 1)
self.assertEqual(lines['group_10'].net, 100)
self.assertEqual(lines['group_10'].tax, 10)
self.assertEqual(lines['group_20'].net, 250)
self.assertEqual(lines['group_20'].tax, 50)
self.assertEqual(lines['tax_group_10'].net, 100)
self.assertEqual(lines['tax_group_10'].tax, 10)
self.assertEqual(lines['tax_group_20'].net, 250)
self.assertEqual(lines['tax_group_20'].tax, 50)
self.assertEqual(len(lines["group_10"]), 1)
self.assertEqual(len(lines["group_20"]), 1)
self.assertEqual(len(lines["tax_group_10"]), 1)
self.assertEqual(len(lines["tax_group_20"]), 1)
self.assertEqual(lines["group_10"].net, 100)
self.assertEqual(lines["group_10"].tax, 10)
self.assertEqual(lines["group_20"].net, 250)
self.assertEqual(lines["group_20"].tax, 50)
self.assertEqual(lines["tax_group_10"].net, 100)
self.assertEqual(lines["tax_group_10"].tax, 10)
self.assertEqual(lines["tax_group_20"].net, 250)
self.assertEqual(lines["tax_group_20"].tax, 50)
def test_get_report_html(self):
vat_report = self.env['report_vat_report'].create({
'date_from': self.date_from,
'date_to': self.date_to,
'company_id': self.company.id,
'tax_detail': True,
})
vat_report = self.env["report_vat_report"].create(
{
"date_from": self.date_from,
"date_to": self.date_to,
"company_id": self.company.id,
"tax_detail": True,
}
)
vat_report.compute_data_for_report()
vat_report.get_html(given_context={})
def test_wizard_date_range(self):
vat_wizard = self.env['vat.report.wizard']
date_range = self.env['date.range']
self.type = self.env['date.range.type'].create(
{'name': 'Month',
'company_id': False,
'allow_overlap': False})
dt = date_range.create({
'name': 'FS2016',
'date_start': time.strftime('%Y-%m-01'),
'date_end': time.strftime('%Y-%m-28'),
'type_id': self.type.id,
})
vat_wizard = self.env["vat.report.wizard"]
date_range = self.env["date.range"]
self.type = self.env["date.range.type"].create(
{"name": "Month", "company_id": False, "allow_overlap": False}
)
dt = date_range.create(
{
"name": "FS2016",
"date_start": time.strftime("%Y-%m-01"),
"date_end": time.strftime("%Y-%m-28"),
"type_id": self.type.id,
}
)
wizard = vat_wizard.create(
{'date_range_id': dt.id,
'date_from': time.strftime('%Y-%m-28'),
'date_to': time.strftime('%Y-%m-01'),
'tax_detail': True})
{
"date_range_id": dt.id,
"date_from": time.strftime("%Y-%m-28"),
"date_to": time.strftime("%Y-%m-01"),
"tax_detail": True,
}
)
wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, date(
date.today().year, date.today().month, 1))
self.assertEqual(wizard.date_to, date(
date.today().year, date.today().month, 28))
wizard._export('qweb-pdf')
self.assertEqual(
wizard.date_from, date(date.today().year, date.today().month, 1)
)
self.assertEqual(
wizard.date_to, date(date.today().year, date.today().month, 28)
)
wizard._export("qweb-pdf")
wizard.button_export_html()
wizard.button_export_pdf()
wizard.button_export_xlsx()
wizard = vat_wizard.create(
{'date_range_id': dt.id,
'date_from': time.strftime('%Y-%m-28'),
'date_to': time.strftime('%Y-%m-01'),
'based_on': 'taxgroups',
'tax_detail': True})
{
"date_range_id": dt.id,
"date_from": time.strftime("%Y-%m-28"),
"date_to": time.strftime("%Y-%m-01"),
"based_on": "taxgroups",
"tax_detail": True,
}
)
wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, date(
date.today().year, date.today().month, 1))
self.assertEqual(wizard.date_to, date(
date.today().year, date.today().month, 28))
wizard._export('qweb-pdf')
self.assertEqual(
wizard.date_from, date(date.today().year, date.today().month, 1)
)
self.assertEqual(
wizard.date_to, date(date.today().year, date.today().month, 28)
)
wizard._export("qweb-pdf")
wizard.button_export_html()
wizard.button_export_pdf()
wizard.button_export_xlsx()

6
account_financial_report/view/account_view.xml

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="ir.ui.view" id="view_account_specific_form">
<field name="name">account.account.form.inherit</field>
<field name="inherit_id" ref="account.view_account_form"/>
<field name="inherit_id" ref="account.view_account_form" />
<field name="model">account.account</field>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="deprecated" position="after">
<field name="centralized"/>
<field name="centralized" />
</field>
</field>
</record>

6
account_financial_report/view/report_aged_partner_balance.xml

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

6
account_financial_report/view/report_general_ledger.xml

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

6
account_financial_report/view/report_journal_ledger.xml

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<?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"/>
<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_open_items.xml

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

49
account_financial_report/view/report_template.xml

@ -1,58 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="account_financial_report_assets_backend"
name="account_financial_report assets" inherit_id="web.assets_backend">
<template
id="account_financial_report_assets_backend"
name="account_financial_report assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<link href="/account_financial_report/static/src/css/report.css" rel="stylesheet"/>
<script type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_backend.js"/>
<script type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_widgets.js"/>
<link
href="/account_financial_report/static/src/css/report.css"
rel="stylesheet"
/>
<script
type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_backend.js"
/>
<script
type="text/javascript"
src="/account_financial_report/static/src/js/account_financial_report_widgets.js"
/>
</xpath>
</template>
<template id="report_buttons">
<div class="button_row">
<button class="o_account_financial_reports_print btn btn-sm oe_button"><span class="fa fa-print"/> Print</button>
<button class="o_account_financial_reports_export btn btn-sm oe_button"><span class="fa fa-download"/> Export</button>
<button class="o_account_financial_reports_print btn btn-sm oe_button"><span
class="fa fa-print"
/> Print</button>
<button
class="o_account_financial_reports_export btn btn-sm oe_button"
><span class="fa fa-download" /> Export</button>
</div>
</template>
<record id="action_report_general_ledger" model="ir.actions.client">
<field name="name">General Ledger</field>
<field name="tag">account_financial_report_backend</field>
<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">
<record id="action_report_open_items" model="ir.actions.client">
<field name="name">Open Items</field>
<field name="tag">account_financial_report_backend</field>
<field name="context" eval="{'active_model': 'report_open_items'}" />
</record>
<record id="action_report_trial_balance" model="ir.actions.client">
<record id="action_report_trial_balance" model="ir.actions.client">
<field name="name">Trial Balance</field>
<field name="tag">account_financial_report_backend</field>
<field name="context" eval="{'active_model': 'report_trial_balance'}" />
</record>
<record id="action_report_aged_partner_balance" model="ir.actions.client">
<record id="action_report_aged_partner_balance" model="ir.actions.client">
<field name="name">Aged Partner Balance</field>
<field name="tag">account_financial_report_backend</field>
<field name="context" eval="{'active_model': 'report_aged_partner_balance'}" />
</record>
<record id="action_report_vat_report" model="ir.actions.client">
<field name="name">VAT Report</field>
<field name="tag">account_financial_report_backend</field>
<field name="context" eval="{'active_model': 'report_vat_report'}" />
</record>
</odoo>

8
account_financial_report/view/report_trial_balance.xml

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

6
account_financial_report/view/report_vat_report.xml

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

29
account_financial_report/wizard/abstract_wizard.py

@ -5,28 +5,25 @@ from odoo import models
class AbstractWizard(models.AbstractModel):
_name = 'account_financial_report_abstract_wizard'
_description = 'Abstract Wizard'
_name = "account_financial_report_abstract_wizard"
_description = "Abstract Wizard"
def _get_partner_ids_domain(self):
return [
'&',
'|',
('company_id', '=', self.company_id.id),
('company_id', '=', False),
'|',
('parent_id', '=', False),
('is_company', '=', True),
"&",
"|",
("company_id", "=", self.company_id.id),
("company_id", "=", False),
"|",
("parent_id", "=", False),
("is_company", "=", True),
]
def _default_partners(self):
context = self.env.context
if (
context.get('active_ids') and
context.get('active_model') == 'res.partner'
):
partners = self.env['res.partner'].browse(context['active_ids'])
corp_partners = partners.filtered('parent_id')
if context.get("active_ids") and context.get("active_model") == "res.partner":
partners = self.env["res.partner"].browse(context["active_ids"])
corp_partners = partners.filtered("parent_id")
partners -= corp_partners
partners |= corp_partners.mapped('commercial_partner_id')
partners |= corp_partners.mapped("commercial_partner_id")
return partners.ids

92
account_financial_report/wizard/aged_partner_balance_wizard.py

@ -4,77 +4,74 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class AgedPartnerBalanceWizard(models.TransientModel):
"""Aged partner balance report wizard."""
_name = 'aged.partner.balance.wizard'
_description = 'Aged Partner Balance Wizard'
_inherit = 'account_financial_report_abstract_wizard'
_name = "aged.partner.balance.wizard"
_description = "Aged Partner Balance Wizard"
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
required=False,
string='Company'
string="Company",
)
date_at = fields.Date(required=True, default=fields.Date.context_today)
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
required=True,
default="all",
)
date_at = fields.Date(required=True,
default=fields.Date.context_today)
target_move = fields.Selection([('posted', 'All Posted Entries'),
('all', 'All Entries')],
string='Target Moves',
required=True,
default='all')
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
comodel_name="account.account", string="Filter accounts",
)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
partner_ids = fields.Many2many(
comodel_name='res.partner',
string='Filter partners',
comodel_name="res.partner", string="Filter partners",
)
show_move_line_details = fields.Boolean()
@api.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.account_ids:
if self.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': []}}
lambda a: a.company_id == self.company_id
)
res = {"domain": {"account_ids": [], "partner_ids": []}}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [('company_id', '=', self.company_id.id)]
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))]
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
domain += [('internal_type', '=', 'receivable')]
domain += [("internal_type", "=", "receivable")]
elif self.payable_accounts_only:
domain += [('internal_type', '=', 'payable')]
self.account_ids = self.env['account.account'].search(domain)
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None
@ -82,46 +79,47 @@ class AgedPartnerBalanceWizard(models.TransientModel):
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_aged_partner_balance')
"account_financial_report.action_report_aged_partner_balance"
)
vals = action.read()[0]
context1 = vals.get('context', {})
context1 = vals.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_aged_partner_balance']
model = self.env["report_aged_partner_balance"]
report = model.create(self._prepare_report_aged_partner_balance())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
vals['context'] = context1
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'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
def _prepare_report_aged_partner_balance(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted',
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'show_move_line_details': self.show_move_line_details,
"date_at": self.date_at,
"only_posted_moves": self.target_move == "posted",
"company_id": self.company_id.id,
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
"show_move_line_details": self.show_move_line_details,
}
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_aged_partner_balance']
model = self.env["report_aged_partner_balance"]
report = model.create(self._prepare_report_aged_partner_balance())
report.compute_data_for_report()
return report.print_report(report_type)

82
account_financial_report/wizard/aged_partner_balance_wizard_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- AGED PARTNER BALANCE -->
<record id="aged_partner_balance_wizard" model="ir.ui.view">
<field name="name">Aged Partner Balance</field>
@ -8,52 +7,75 @@
<field name="arch" type="xml">
<form>
<group name="main_info">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field
name="company_id"
options="{'no_create': True}"
groups="base.group_multi_company"
/>
</group>
<group name="filters">
<group name="date_range">
<field name="date_at"/>
<field name="date_at" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio"/>
<field name="show_move_line_details"/>
<field name="target_move" widget="radio" />
<field name="show_move_line_details" />
</group>
</group>
<group name="partner_filter" col="1">
<label for="partner_ids"/>
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
<label for="partner_ids" />
<field
name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
/>
</group>
<group name="account_filter" col="4">
<label for="account_ids" colspan="4"/>
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
<field name="account_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"
/>
</group>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<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_aged_partner_balance_wizard"
name="Aged Partner Balance"
res_model="aged.partner.balance.wizard"
view_type="form"
view_mode="form"
view_id="aged_partner_balance_wizard"
target="new" />
<act_window
id="action_aged_partner_balance_wizard"
name="Aged Partner Balance"
res_model="aged.partner.balance.wizard"
view_type="form"
view_mode="form"
view_id="aged_partner_balance_wizard"
target="new"
/>
</odoo>

265
account_financial_report/wizard/general_ledger_wizard.py

@ -8,92 +8,78 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo.exceptions import ValidationError
import time
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class GeneralLedgerReportWizard(models.TransientModel):
"""General ledger report wizard."""
_name = "general.ledger.report.wizard"
_description = "General Ledger Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
required=False,
string='Company'
string="Company",
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range'
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_from = fields.Date(required=True, default=lambda self: self._init_date_from())
date_to = fields.Date(required=True, default=fields.Date.context_today)
fy_start_date = fields.Date(compute="_compute_fy_start_date")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
required=True,
default="all",
)
date_from = fields.Date(required=True,
default=lambda self: self._init_date_from())
date_to = fields.Date(required=True,
default=fields.Date.context_today)
fy_start_date = fields.Date(compute='_compute_fy_start_date')
target_move = fields.Selection([('posted', 'All Posted Entries'),
('all', 'All Entries')],
string='Target Moves',
required=True,
default='all')
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
comodel_name="account.account", string="Filter accounts",
)
centralize = fields.Boolean(string='Activate centralization',
default=True)
centralize = fields.Boolean(string="Activate centralization", default=True)
hide_account_at_0 = fields.Boolean(
string='Hide account ending balance at 0',
help='Use this filter to hide an account or a partner '
'with an ending balance at 0. '
'If partners are filtered, '
'debits and credits totals will not match the trial balance.'
)
show_analytic_tags = fields.Boolean(
string='Show analytic tags',
)
account_type_ids = fields.Many2many(
'account.account.type',
string='Account Types',
string="Hide account ending balance at 0",
help="Use this filter to hide an account or a partner "
"with an ending balance at 0. "
"If partners are filtered, "
"debits and credits totals will not match the trial balance.",
)
show_analytic_tags = fields.Boolean(string="Show analytic tags",)
account_type_ids = fields.Many2many("account.account.type", string="Account Types",)
partner_ids = fields.Many2many(
comodel_name='res.partner',
string='Filter partners',
comodel_name="res.partner",
string="Filter partners",
default=lambda self: self._default_partners(),
)
analytic_tag_ids = fields.Many2many(
comodel_name='account.analytic.tag',
string='Filter analytic tags',
comodel_name="account.analytic.tag", string="Filter analytic tags",
)
account_journal_ids = fields.Many2many(
comodel_name='account.journal',
string='Filter journals',
comodel_name="account.journal", string="Filter journals",
)
cost_center_ids = fields.Many2many(
comodel_name='account.analytic.account',
string='Filter cost centers',
comodel_name="account.analytic.account", string="Filter cost centers",
)
not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True,
string='Not only one unaffected earnings account'
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.',
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.",
default=lambda self: self._default_foreign_currency(),
)
partner_ungrouped = fields.Boolean(
string='Partner ungrouped',
help='If set moves are not grouped by partner in any case'
string="Partner ungrouped",
help="If set moves are not grouped by partner in any case",
)
def _init_date_from(self):
@ -104,73 +90,87 @@ class GeneralLedgerReportWizard(models.TransientModel):
last_fsc_month = self.env.user.company_id.fiscalyear_last_month
last_fsc_day = self.env.user.company_id.fiscalyear_last_day
if cur_month < last_fsc_month \
or cur_month == last_fsc_month and cur_day <= last_fsc_day:
return time.strftime('%Y-01-01')
if (
cur_month < last_fsc_month
or cur_month == last_fsc_month
and cur_day <= last_fsc_day
):
return time.strftime("%Y-01-01")
def _default_foreign_currency(self):
return self.env.user.has_group('base.group_multi_currency')
return self.env.user.has_group("base.group_multi_currency")
@api.depends('date_from')
@api.depends("date_from")
def _compute_fy_start_date(self):
for wiz in self.filtered('date_from'):
for wiz in self.filtered("date_from"):
date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
wiz.fy_start_date = fields.Date.to_string(res["date_from"])
@api.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
account_type = self.env.ref('account.data_unaffected_earnings')
count = self.env['account.account'].search_count(
account_type = self.env.ref("account.data_unaffected_earnings")
count = self.env["account.account"].search_count(
[
('user_type_id', '=', account_type.id),
('company_id', '=', self.company_id.id)
])
("user_type_id", "=", account_type.id),
("company_id", "=", self.company_id.id),
]
)
self.not_only_one_unaffected_earnings_account = count != 1
if self.company_id and self.date_range_id.company_id and \
self.date_range_id.company_id != self.company_id:
if (
self.company_id
and self.date_range_id.company_id
and self.date_range_id.company_id != self.company_id
):
self.date_range_id = False
if self.company_id and self.account_journal_ids:
self.account_journal_ids = self.account_journal_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.account_ids:
if self.account_type_ids:
self._onchange_account_type_ids()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
lambda a: a.company_id == self.company_id
)
if self.company_id and self.cost_center_ids:
self.cost_center_ids = self.cost_center_ids.filtered(
lambda c: c.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': [],
'account_journal_ids': [],
'cost_center_ids': [],
'date_range_id': []
}
}
lambda c: c.company_id == self.company_id
)
res = {
"domain": {
"account_ids": [],
"partner_ids": [],
"account_journal_ids": [],
"cost_center_ids": [],
"date_range_id": [],
}
}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['account_journal_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res['domain']['cost_center_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
res["domain"]["account_journal_ids"] += [
("company_id", "=", self.company_id.id)
]
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
res["domain"]["cost_center_ids"] += [
("company_id", "=", self.company_id.id)
]
res["domain"]["date_range_id"] += [
"|",
("company_id", "=", self.company_id.id),
("company_id", "=", False),
]
return res
@api.onchange('date_range_id')
@api.onchange("date_range_id")
def onchange_date_range_id(self):
"""Handle date range change."""
if self.date_range_id:
@ -178,30 +178,40 @@ class GeneralLedgerReportWizard(models.TransientModel):
self.date_to = self.date_range_id.date_end
@api.multi
@api.constrains('company_id', 'date_range_id')
@api.constrains("company_id", "date_range_id")
def _check_company_id_date_range_id(self):
for rec in self.sudo():
if rec.company_id and rec.date_range_id.company_id and\
rec.company_id != rec.date_range_id.company_id:
if (
rec.company_id
and rec.date_range_id.company_id
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_('The Company in the General Ledger Report Wizard and in '
'Date Range must be the same.'))
_(
"The Company in the General Ledger Report Wizard and in "
"Date Range must be the same."
)
)
@api.onchange('account_type_ids')
@api.onchange("account_type_ids")
def _onchange_account_type_ids(self):
if self.account_type_ids:
self.account_ids = self.env['account.account'].search([
('company_id', '=', self.company_id.id),
('user_type_id', 'in', self.account_type_ids.ids)])
self.account_ids = self.env["account.account"].search(
[
("company_id", "=", self.company_id.id),
("user_type_id", "in", self.account_type_ids.ids),
]
)
else:
self.account_ids = None
@api.onchange('partner_ids')
@api.onchange("partner_ids")
def onchange_partner_ids(self):
"""Handle partners change."""
if self.partner_ids:
self.account_type_ids = self.env['account.account.type'].search([
('type', 'in', ['receivable', 'payable'])])
self.account_type_ids = self.env["account.account.type"].search(
[("type", "in", ["receivable", "payable"])]
)
else:
self.account_type_ids = None
# Somehow this is required to force onchange on _default_partners()
@ -210,55 +220,54 @@ class GeneralLedgerReportWizard(models.TransientModel):
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_general_ledger')
action = self.env.ref("account_financial_report.action_report_general_ledger")
action_data = action.read()[0]
context1 = action_data.get('context', {})
context1 = action_data.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_general_ledger']
model = self.env["report_general_ledger"]
report = model.create(self._prepare_report_general_ledger())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
action_data['context'] = context1
context1["active_id"] = report.id
context1["active_ids"] = report.ids
action_data["context"] = context1
return action_data
@api.multi
def button_export_pdf(self):
self.ensure_one()
report_type = 'qweb-pdf'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
def _prepare_report_general_ledger(self):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
'hide_account_at_0': self.hide_account_at_0,
'foreign_currency': self.foreign_currency,
'show_analytic_tags': self.show_analytic_tags,
'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.account_ids.ids)],
'filter_partner_ids': [(6, 0, self.partner_ids.ids)],
'filter_cost_center_ids': [(6, 0, self.cost_center_ids.ids)],
'filter_analytic_tag_ids': [(6, 0, self.analytic_tag_ids.ids)],
'filter_journal_ids': [(6, 0, self.account_journal_ids.ids)],
'centralize': self.centralize,
'fy_start_date': self.fy_start_date,
'partner_ungrouped': self.partner_ungrouped,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_at_0,
"foreign_currency": self.foreign_currency,
"show_analytic_tags": self.show_analytic_tags,
"company_id": self.company_id.id,
"filter_account_ids": [(6, 0, self.account_ids.ids)],
"filter_partner_ids": [(6, 0, self.partner_ids.ids)],
"filter_cost_center_ids": [(6, 0, self.cost_center_ids.ids)],
"filter_analytic_tag_ids": [(6, 0, self.analytic_tag_ids.ids)],
"filter_journal_ids": [(6, 0, self.account_journal_ids.ids)],
"centralize": self.centralize,
"fy_start_date": self.fy_start_date,
"partner_ungrouped": self.partner_ungrouped,
}
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_general_ledger']
model = self.env["report_general_ledger"]
report = model.create(self._prepare_report_general_ledger())
report.compute_data_for_report()
return report.print_report(report_type)

198
account_financial_report/wizard/general_ledger_wizard_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- GENERAL LEDGER -->
<record id="general_ledger_wizard" model="ir.ui.view">
<field name="name">General Ledger</field>
@ -8,42 +7,68 @@
<field name="arch" type="xml">
<form>
<group name="main_info">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field
name="company_id"
options="{'no_create': True}"
groups="base.group_multi_company"
/>
</group>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
>
<group name="filters">
<group name="date_range">
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="fy_start_date" invisible="1"/>
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
<field name="fy_start_date" invisible="1" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio"/>
<label string="Other options" for="centralize"/>
<field name="target_move" widget="radio" />
<label string="Other options" for="centralize" />
<div>
<field name="centralize" nolabel="1" class="oe_inline"/>
<label for="centralize" class="oe_inline"/>
<field
name="centralize"
nolabel="1"
class="oe_inline"
/>
<label for="centralize" class="oe_inline" />
</div>
<label string=" " for="hide_account_at_0"/>
<label string=" " for="hide_account_at_0" />
<div>
<field name="hide_account_at_0" nolabel="1" class="oe_inline"/>
<label for="hide_account_at_0" class="oe_inline"/>
<field
name="hide_account_at_0"
nolabel="1"
class="oe_inline"
/>
<label for="hide_account_at_0" class="oe_inline" />
</div>
<label string=" " for="foreign_currency"/>
<label string=" " for="foreign_currency" />
<div>
<field name="foreign_currency" nolabel="1" class="oe_inline"/>
<label for="foreign_currency" class="oe_inline"/>
<field
name="foreign_currency"
nolabel="1"
class="oe_inline"
/>
<label for="foreign_currency" class="oe_inline" />
</div>
<label string=" " for="show_analytic_tags"/>
<label string=" " for="show_analytic_tags" />
<div>
<field name="show_analytic_tags" nolabel="1" class="oe_inline"/>
<label for="show_analytic_tags" class="oe_inline"/>
<field
name="show_analytic_tags"
nolabel="1"
class="oe_inline"
/>
<label for="show_analytic_tags" class="oe_inline" />
</div>
<label string=" " for="partner_ungrouped"/>
<label string=" " for="partner_ungrouped" />
<div>
<field name="partner_ungrouped" nolabel="1" class="oe_inline"/>
<label for="partner_ungrouped" class="oe_inline"/>
<field
name="partner_ungrouped"
nolabel="1"
class="oe_inline"
/>
<label for="partner_ungrouped" class="oe_inline" />
</div>
</group>
</group>
@ -51,69 +76,116 @@
<page string="Filter accounts">
<group>
<group>
<field name="account_type_ids" widget="many2many_checkboxes" nolabel="1"/>
<field
name="account_type_ids"
widget="many2many_checkboxes"
nolabel="1"
/>
</group>
<group>
<field name="account_ids" widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
<field
name="account_ids"
widget="many2many_tags"
options="{'no_create': True}"
nolabel="1"
/>
</group>
</group>
</page>
<page string="Filter partners">
<field name="partner_ids" nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
<field
name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
/>
</page>
<page string="Filter cost centers" groups="analytic.group_analytic_accounting">
<field name="cost_center_ids" nolabel="1"
options="{'no_create': True}"
groups="analytic.group_analytic_accounting"/>
<page
string="Filter cost centers"
groups="analytic.group_analytic_accounting"
>
<field
name="cost_center_ids"
nolabel="1"
options="{'no_create': True}"
groups="analytic.group_analytic_accounting"
/>
</page>
<page string="Filter analytic tags">
<field name="analytic_tag_ids" widget="many2many_tags" nolabel="1" options="{'no_create': True}"/>
<field
name="analytic_tag_ids"
widget="many2many_tags"
nolabel="1"
options="{'no_create': True}"
/>
</page>
</notebook>
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
<group/>
<h4>General Ledger can be computed only if selected company have only one unaffected earnings account.</h4>
<group/>
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
>
<field
name="not_only_one_unaffected_earnings_account"
invisible="1"
/>
<group />
<h4
>General Ledger can be computed only if selected company have only one unaffected earnings account.</h4>
<group />
</div>
<footer>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<button
name="button_export_xlsx"
string="Export XLSX"
type="object"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
>
<button string="Cancel" class="oe_link" special="cancel" />
</div>
</footer>
</form>
</field>
</record>
<act_window id="action_general_ledger_wizard"
name="General Ledger"
res_model="general.ledger.report.wizard"
view_type="form"
view_mode="form"
view_id="general_ledger_wizard"
target="new" />
<act_window
id="action_general_ledger_wizard"
name="General Ledger"
res_model="general.ledger.report.wizard"
view_type="form"
view_mode="form"
view_id="general_ledger_wizard"
target="new"
/>
<!--Add to res.partner action-->
<act_window id="act_action_general_ledger_wizard_partner_relation"
name="General Ledger"
res_model="general.ledger.report.wizard"
src_model="res.partner"
view_mode="form"
groups="account.group_account_manager"
key2="client_action_multi"
target="new" />
<act_window
id="act_action_general_ledger_wizard_partner_relation"
name="General Ledger"
res_model="general.ledger.report.wizard"
src_model="res.partner"
view_mode="form"
groups="account.group_account_manager"
key2="client_action_multi"
target="new"
/>
</odoo>

122
account_financial_report/wizard/journal_ledger_wizard.py

@ -1,134 +1,117 @@
# 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 import _, api, fields, models
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class JournalLedgerReportWizard(models.TransientModel):
"""Journal Ledger report wizard."""
_name = 'journal.ledger.report.wizard'
_name = "journal.ledger.report.wizard"
_description = "Journal Ledger Report Wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
string='Company',
string="Company",
required=False,
ondelete='cascade',
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range',
)
date_from = fields.Date(
string="Start date",
required=True
)
date_to = fields.Date(
string="End date",
required=True
ondelete="cascade",
)
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range",)
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",
required=False,
comodel_name="account.journal", string="Journals", required=False,
)
move_target = fields.Selection(
selection='_get_move_targets',
default='all',
required=True,
selection="_get_move_targets", default="all", required=True,
)
foreign_currency = fields.Boolean()
sort_option = fields.Selection(
selection='_get_sort_options',
selection="_get_sort_options",
string="Sort entries by",
default='move_name',
default="move_name",
required=True,
)
group_option = fields.Selection(
selection='_get_group_options',
selection="_get_group_options",
string="Group entries by",
default='journal',
default="journal",
required=True,
)
with_account_name = fields.Boolean(
default=False,
)
with_account_name = fields.Boolean(default=False,)
@api.model
def _get_move_targets(self):
return [
('all', _("All")),
('posted', _("Posted")),
('draft', _("Not Posted"))
]
return [("all", _("All")), ("posted", _("Posted")), ("draft", _("Not Posted"))]
@api.model
def _get_sort_options(self):
return [
('move_name', _("Entry number")),
('date', _("Date")),
("move_name", _("Entry number")),
("date", _("Date")),
]
@api.model
def _get_group_options(self):
return [
('journal', _("Journal")),
('none', _("No group")),
("journal", _("Journal")),
("none", _("No group")),
]
@api.onchange('date_range_id')
@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.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
if self.company_id and self.date_range_id.company_id and \
self.date_range_id.company_id != self.company_id:
if (
self.company_id
and self.date_range_id.company_id
and self.date_range_id.company_id != self.company_id
):
self.date_range_id = False
if self.company_id and self.journal_ids:
self.journal_ids = self.journal_ids.filtered(
lambda p: p.company_id == self.company_id or not p.company_id)
res = {'domain': {'journal_ids': []}}
lambda p: p.company_id == self.company_id or not p.company_id
)
res = {"domain": {"journal_ids": []}}
if not self.company_id:
return res
else:
res['domain']['journal_ids'] += [
('company_id', '=', self.company_id.id)]
res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)]
return res
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_journal_ledger')
action = self.env.ref("account_financial_report.action_report_journal_ledger")
vals = action.read()[0]
context1 = vals.get('context', {})
context1 = vals.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_journal_ledger']
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
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'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
@api.multi
@ -137,24 +120,25 @@ class JournalLedgerReportWizard(models.TransientModel):
journals = self.journal_ids
if not journals:
# Not selecting a journal means that we'll display all journals
journals = self.env['account.journal'].search(
[('company_id', '=', self.company_id.id)])
journals = self.env["account.journal"].search(
[("company_id", "=", self.company_id.id)]
)
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, journals.ids)],
'sort_option': self.sort_option,
'group_option': self.group_option,
'with_account_name': self.with_account_name,
"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, journals.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']
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)

82
account_financial_report/wizard/journal_ledger_wizard_view.xml

@ -1,66 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<?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"/>
<field name="company_id" groups="base.group_multi_company" />
</group>
<separator string="Periods"/>
<separator string="Periods" />
<group>
<group>
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
</group>
<group/>
<group />
</group>
<separator string="Options"/>
<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"/>
<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 />
</group>
<separator string="Journals"/>
<separator string="Journals" />
<group>
<field name="journal_ids" widget="many2many_tags"/>
<field name="journal_ids" widget="many2many_tags" />
</group>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<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" />
<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>

117
account_financial_report/wizard/open_items_wizard.py

@ -3,9 +3,9 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
from odoo.tools.safe_eval import safe_eval
from odoo import api, fields, models
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class OpenItemsReportWizard(models.TransientModel):
@ -13,134 +13,133 @@ class OpenItemsReportWizard(models.TransientModel):
_name = "open.items.report.wizard"
_description = "Open Items Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
required=False,
string='Company'
string="Company",
)
date_at = fields.Date(required=True, default=fields.Date.context_today)
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
required=True,
default="all",
)
date_at = fields.Date(required=True,
default=fields.Date.context_today)
target_move = fields.Selection([('posted', 'All Posted Entries'),
('all', 'All Entries')],
string='Target Moves',
required=True,
default='all')
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
domain=[('reconcile', '=', True)],
comodel_name="account.account",
string="Filter accounts",
domain=[("reconcile", "=", True)],
)
hide_account_at_0 = fields.Boolean(
string='Hide account ending balance at 0', default=True,
help='Use this filter to hide an account or a partner '
'with an ending balance at 0. '
'If partners are filtered, '
'debits and credits totals will not match the trial balance.'
string="Hide account ending balance at 0",
default=True,
help="Use this filter to hide an account or a partner "
"with an ending balance at 0. "
"If partners are filtered, "
"debits and credits totals will not match the trial balance.",
)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
partner_ids = fields.Many2many(
comodel_name='res.partner',
string='Filter partners',
comodel_name="res.partner",
string="Filter partners",
default=lambda self: self._default_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.',
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.",
default=lambda self: self._default_foreign_currency(),
)
def _default_foreign_currency(self):
return self.env.user.has_group('base.group_multi_currency')
return self.env.user.has_group("base.group_multi_currency")
@api.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.account_ids:
if self.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': []}}
lambda a: a.company_id == self.company_id
)
res = {"domain": {"account_ids": [], "partner_ids": []}}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
return res
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [('company_id', '=', self.company_id.id)]
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))]
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
domain += [('internal_type', '=', 'receivable')]
domain += [("internal_type", "=", "receivable")]
elif self.payable_accounts_only:
domain += [('internal_type', '=', 'payable')]
self.account_ids = self.env['account.account'].search(domain)
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_open_items')
action = self.env.ref("account_financial_report.action_report_open_items")
vals = action.read()[0]
context1 = vals.get('context', {})
context1 = vals.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_open_items']
model = self.env["report_open_items"]
report = model.create(self._prepare_report_open_items())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
vals['context'] = context1
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'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
def _prepare_report_open_items(self):
self.ensure_one()
return {
'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted',
'hide_account_at_0': self.hide_account_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)],
"date_at": self.date_at,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_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)],
}
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_open_items']
model = self.env["report_open_items"]
report = model.create(self._prepare_report_open_items())
report.compute_data_for_report()
return report.print_report(report_type)

105
account_financial_report/wizard/open_items_wizard_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- OPEN ITEMS -->
<record id="open_items_wizard" model="ir.ui.view">
<field name="name">Open Items</field>
@ -8,68 +7,90 @@
<field name="arch" type="xml">
<form>
<group name="main_info">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field
name="company_id"
options="{'no_create': True}"
groups="base.group_multi_company"
/>
</group>
<group name="filters">
<group name="date_range">
<field name="date_at"/>
<field name="date_at" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio"/>
<field name="hide_account_at_0"/>
<field name="foreign_currency"/>
<field name="target_move" widget="radio" />
<field name="hide_account_at_0" />
<field name="foreign_currency" />
</group>
</group>
<group name="partner_filter" col="1">
<label for="partner_ids"/>
<field name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
<label for="partner_ids" />
<field
name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
/>
</group>
<group name="account_filter" col="4">
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"
/>
</group>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<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_open_items_wizard"
name="Open Items"
res_model="open.items.report.wizard"
view_type="form"
view_mode="form"
view_id="open_items_wizard"
target="new" />
<act_window
id="action_open_items_wizard"
name="Open Items"
res_model="open.items.report.wizard"
view_type="form"
view_mode="form"
view_id="open_items_wizard"
target="new"
/>
<!--Add to res.partner action-->
<act_window id="act_action_open_items_wizard_partner_relation"
name="Open Items Partner"
res_model="open.items.report.wizard"
src_model="res.partner"
view_mode="form"
context="{
<act_window
id="act_action_open_items_wizard_partner_relation"
name="Open Items Partner"
res_model="open.items.report.wizard"
src_model="res.partner"
view_mode="form"
context="{
'default_receivable_accounts_only':1,
'default_payable_accounts_only':1,
}"
groups="account.group_account_manager"
key2="client_action_multi"
target="new" />
groups="account.group_account_manager"
key2="client_action_multi"
target="new"
/>
</odoo>

236
account_financial_report/wizard/trial_balance_wizard.py

@ -4,10 +4,10 @@
# Copyright 2018 Eficent Business and IT Consuting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class TrialBalanceReportWizard(models.TransientModel):
@ -15,169 +15,180 @@ class TrialBalanceReportWizard(models.TransientModel):
_name = "trial.balance.report.wizard"
_description = "Trial Balance Report Wizard"
_inherit = 'account_financial_report_abstract_wizard'
_inherit = "account_financial_report_abstract_wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
required=False,
string='Company'
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range'
string="Company",
)
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_from = fields.Date(required=True)
date_to = fields.Date(required=True)
fy_start_date = fields.Date(compute='_compute_fy_start_date')
target_move = fields.Selection([('posted', 'All Posted Entries'),
('all', 'All Entries')],
string='Target Moves',
required=True,
default='all')
fy_start_date = fields.Date(compute="_compute_fy_start_date")
target_move = fields.Selection(
[("posted", "All Posted Entries"), ("all", "All Entries")],
string="Target Moves",
required=True,
default="all",
)
hierarchy_on = fields.Selection(
[('computed', 'Computed Accounts'),
('relation', 'Child Accounts'),
('none', 'No hierarchy')],
string='Hierarchy On',
[
("computed", "Computed Accounts"),
("relation", "Child Accounts"),
("none", "No hierarchy"),
],
string="Hierarchy On",
required=True,
default='computed',
default="computed",
help="""Computed Accounts: Use when the account group have codes
that represent prefixes of the actual accounts.\n
Child Accounts: Use when your account groups are hierarchical.\n
No hierarchy: Use to display just the accounts, without any grouping.
""",
)
limit_hierarchy_level = fields.Boolean('Limit hierarchy levels')
show_hierarchy_level = fields.Integer('Hierarchy Levels to display',
default=1)
limit_hierarchy_level = fields.Boolean("Limit hierarchy levels")
show_hierarchy_level = fields.Integer("Hierarchy Levels to display", default=1)
hide_parent_hierarchy_level = fields.Boolean(
'Do not display parent levels', default=False)
"Do not display parent levels", default=False
)
account_ids = fields.Many2many(
comodel_name='account.account',
string='Filter accounts',
comodel_name="account.account", string="Filter accounts",
)
hide_account_at_0 = fields.Boolean(
string='Hide accounts at 0', default=True,
help='When this option is enabled, the trial balance will '
'not display accounts that have initial balance = '
'debit = credit = end balance = 0',
string="Hide accounts at 0",
default=True,
help="When this option is enabled, the trial balance will "
"not display accounts that have initial balance = "
"debit = credit = end balance = 0",
)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
show_partner_details = fields.Boolean()
partner_ids = fields.Many2many(
comodel_name='res.partner',
string='Filter partners',
)
journal_ids = fields.Many2many(
comodel_name="account.journal",
comodel_name="res.partner", string="Filter partners",
)
journal_ids = fields.Many2many(comodel_name="account.journal",)
not_only_one_unaffected_earnings_account = fields.Boolean(
readonly=True,
string='Not only one unaffected earnings account'
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.'
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.multi
@api.constrains('hierarchy_on', 'show_hierarchy_level')
@api.constrains("hierarchy_on", "show_hierarchy_level")
def _check_show_hierarchy_level(self):
for rec in self:
if rec.hierarchy_on != 'none' and rec.show_hierarchy_level <= 0:
raise UserError(_('The hierarchy level to filter on must be '
'greater than 0.'))
if rec.hierarchy_on != "none" and rec.show_hierarchy_level <= 0:
raise UserError(
_("The hierarchy level to filter on must be " "greater than 0.")
)
@api.depends('date_from')
@api.depends("date_from")
def _compute_fy_start_date(self):
for wiz in self.filtered('date_from'):
for wiz in self.filtered("date_from"):
date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = fields.Date.to_string(res['date_from'])
wiz.fy_start_date = fields.Date.to_string(res["date_from"])
@api.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
"""Handle company change."""
account_type = self.env.ref('account.data_unaffected_earnings')
count = self.env['account.account'].search_count(
account_type = self.env.ref("account.data_unaffected_earnings")
count = self.env["account.account"].search_count(
[
('user_type_id', '=', account_type.id),
('company_id', '=', self.company_id.id)
])
("user_type_id", "=", account_type.id),
("company_id", "=", self.company_id.id),
]
)
self.not_only_one_unaffected_earnings_account = count != 1
if self.company_id and self.date_range_id.company_id and \
self.date_range_id.company_id != self.company_id:
if (
self.company_id
and self.date_range_id.company_id
and self.date_range_id.company_id != self.company_id
):
self.date_range_id = False
if self.company_id and self.partner_ids:
self.partner_ids = self.partner_ids.filtered(
lambda p: p.company_id == self.company_id or
not p.company_id)
lambda p: p.company_id == self.company_id or not p.company_id
)
if self.company_id and self.journal_ids:
self.journal_ids = self.journal_ids.filtered(
lambda a: a.company_id == self.company_id)
lambda a: a.company_id == self.company_id
)
if self.company_id and self.account_ids:
if self.receivable_accounts_only or self.payable_accounts_only:
self.onchange_type_accounts_only()
else:
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id)
res = {'domain': {'account_ids': [],
'partner_ids': [],
'date_range_id': [],
'journal_ids': [],
}
}
lambda a: a.company_id == self.company_id
)
res = {
"domain": {
"account_ids": [],
"partner_ids": [],
"date_range_id": [],
"journal_ids": [],
}
}
if not self.company_id:
return res
else:
res['domain']['account_ids'] += [
('company_id', '=', self.company_id.id)]
res['domain']['partner_ids'] += self._get_partner_ids_domain()
res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res['domain']['journal_ids'] += [
('company_id', '=', self.company_id.id)]
res["domain"]["account_ids"] += [("company_id", "=", self.company_id.id)]
res["domain"]["partner_ids"] += self._get_partner_ids_domain()
res["domain"]["date_range_id"] += [
"|",
("company_id", "=", self.company_id.id),
("company_id", "=", False),
]
res["domain"]["journal_ids"] += [("company_id", "=", self.company_id.id)]
return res
@api.onchange('date_range_id')
@api.onchange("date_range_id")
def onchange_date_range_id(self):
"""Handle date range change."""
self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end
@api.multi
@api.constrains('company_id', 'date_range_id')
@api.constrains("company_id", "date_range_id")
def _check_company_id_date_range_id(self):
for rec in self.sudo():
if rec.company_id and rec.date_range_id.company_id and\
rec.company_id != rec.date_range_id.company_id:
if (
rec.company_id
and rec.date_range_id.company_id
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_('The Company in the Trial Balance Report Wizard and in '
'Date Range must be the same.'))
_(
"The Company in the Trial Balance Report Wizard and in "
"Date Range must be the same."
)
)
@api.onchange('receivable_accounts_only', 'payable_accounts_only')
@api.onchange("receivable_accounts_only", "payable_accounts_only")
def onchange_type_accounts_only(self):
"""Handle receivable/payable accounts only change."""
if self.receivable_accounts_only or self.payable_accounts_only:
domain = [('company_id', '=', self.company_id.id)]
domain = [("company_id", "=", self.company_id.id)]
if self.receivable_accounts_only and self.payable_accounts_only:
domain += [('internal_type', 'in', ('receivable', 'payable'))]
domain += [("internal_type", "in", ("receivable", "payable"))]
elif self.receivable_accounts_only:
domain += [('internal_type', '=', 'receivable')]
domain += [("internal_type", "=", "receivable")]
elif self.payable_accounts_only:
domain += [('internal_type', '=', 'payable')]
self.account_ids = self.env['account.account'].search(domain)
domain += [("internal_type", "=", "payable")]
self.account_ids = self.env["account.account"].search(domain)
else:
self.account_ids = None
@api.onchange('show_partner_details')
@api.onchange("show_partner_details")
def onchange_show_partner_details(self):
"""Handle partners change."""
if self.show_partner_details:
@ -188,56 +199,55 @@ class TrialBalanceReportWizard(models.TransientModel):
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_trial_balance')
action = self.env.ref("account_financial_report.action_report_trial_balance")
vals = action.read()[0]
context1 = vals.get('context', {})
context1 = vals.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_trial_balance']
model = self.env["report_trial_balance"]
report = model.create(self._prepare_report_trial_balance())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
vals['context'] = context1
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'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
def _prepare_report_trial_balance(self):
self.ensure_one()
return {
'date_from': self.date_from,
'date_to': self.date_to,
'only_posted_moves': self.target_move == 'posted',
'hide_account_at_0': self.hide_account_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)],
'filter_journal_ids': [(6, 0, self.journal_ids.ids)],
'fy_start_date': self.fy_start_date,
'hierarchy_on': self.hierarchy_on,
'limit_hierarchy_level': self.limit_hierarchy_level,
'show_hierarchy_level': self.show_hierarchy_level,
'hide_parent_hierarchy_level': self.hide_parent_hierarchy_level,
'show_partner_details': self.show_partner_details,
"date_from": self.date_from,
"date_to": self.date_to,
"only_posted_moves": self.target_move == "posted",
"hide_account_at_0": self.hide_account_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)],
"filter_journal_ids": [(6, 0, self.journal_ids.ids)],
"fy_start_date": self.fy_start_date,
"hierarchy_on": self.hierarchy_on,
"limit_hierarchy_level": self.limit_hierarchy_level,
"show_hierarchy_level": self.show_hierarchy_level,
"hide_parent_hierarchy_level": self.hide_parent_hierarchy_level,
"show_partner_details": self.show_partner_details,
}
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_trial_balance']
model = self.env["report_trial_balance"]
report = model.create(self._prepare_report_trial_balance())
report.compute_data_for_report()
return report.print_report(report_type)

164
account_financial_report/wizard/trial_balance_wizard_view.xml

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<!-- TRIAL BALANCE -->
<record id="trial_balance_wizard" model="ir.ui.view">
<field name="name">Trial Balance</field>
@ -8,84 +7,135 @@
<field name="arch" type="xml">
<form>
<group name="main_info">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
<field
name="company_id"
options="{'no_create': True}"
groups="base.group_multi_company"
/>
</group>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
>
<group name="filters">
<group name="date_range">
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="fy_start_date" invisible="1"/>
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
<field name="fy_start_date" invisible="1" />
</group>
<group name="other_filters">
<field name="target_move" widget="radio"/>
<field name="hide_account_at_0"/>
<field name="show_partner_details"/>
<field name="hierarchy_on" widget="radio" attrs="{'invisible':[('show_partner_details','=',True)]}"/>
<field name="limit_hierarchy_level" attrs="{'invisible':['|', ('hierarchy_on','=','none'),('show_partner_details','=',True)]}"/>
<field name="show_hierarchy_level" attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"/>
<field name="hide_parent_hierarchy_level" attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"/>
<field name="foreign_currency"/>
<field name="target_move" widget="radio" />
<field name="hide_account_at_0" />
<field name="show_partner_details" />
<field
name="hierarchy_on"
widget="radio"
attrs="{'invisible':[('show_partner_details','=',True)]}"
/>
<field
name="limit_hierarchy_level"
attrs="{'invisible':['|', ('hierarchy_on','=','none'),('show_partner_details','=',True)]}"
/>
<field
name="show_hierarchy_level"
attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"
/>
<field
name="hide_parent_hierarchy_level"
attrs="{'invisible':[('limit_hierarchy_level','=', False)]}"
/>
<field name="foreign_currency" />
</group>
</group>
<group name="partner_filter" attrs="{'invisible':[('show_partner_details','!=',True)]}" col="1">
<label for="partner_ids"/>
<field name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"/>
<group
name="partner_filter"
attrs="{'invisible':[('show_partner_details','!=',True)]}"
col="1"
>
<label for="partner_ids" />
<field
name="partner_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
/>
</group>
<label for="journal_ids"/>
<field name="journal_ids"
widget="many2many_tags"
nolabel="1"
options="{'no_create': True}"
<label for="journal_ids" />
<field
name="journal_ids"
widget="many2many_tags"
nolabel="1"
options="{'no_create': True}"
/>
<group attrs="{'invisible':[('show_partner_details','!=',True)]}"/>
<div/>
<group attrs="{'invisible':[('show_partner_details','!=',True)]}" />
<div />
<group name="account_filter" col="4">
<label for="account_ids" colspan="4"/>
<field name="receivable_accounts_only"/>
<field name="payable_accounts_only"/>
<field name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"/>
<label for="account_ids" colspan="4" />
<field name="receivable_accounts_only" />
<field name="payable_accounts_only" />
<field
name="account_ids"
nolabel="1"
widget="many2many_tags"
options="{'no_create': True}"
colspan="4"
/>
</group>
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<field name="not_only_one_unaffected_earnings_account" invisible="1"/>
<group/>
<h4>Trial Balance can be computed only if selected company have only one unaffected earnings account.</h4>
<group/>
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
>
<field
name="not_only_one_unaffected_earnings_account"
invisible="1"
/>
<group />
<h4
>Trial Balance can be computed only if selected company have only one unaffected earnings account.</h4>
<group />
</div>
<footer>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}">
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', True)]}"
>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<button
name="button_export_xlsx"
string="Export XLSX"
type="object"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</div>
<div attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}">
<div
attrs="{'invisible': [('not_only_one_unaffected_earnings_account', '=', False)]}"
>
<button string="Cancel" class="oe_link" special="cancel" />
</div>
</footer>
</form>
</field>
</record>
<act_window id="action_trial_balance_wizard"
name="Trial Balance"
res_model="trial.balance.report.wizard"
view_type="form"
view_mode="form"
view_id="trial_balance_wizard"
target="new" />
<act_window
id="action_trial_balance_wizard"
name="Trial Balance"
res_model="trial.balance.report.wizard"
view_type="form"
view_mode="form"
view_id="trial_balance_wizard"
target="new"
/>
</odoo>

98
account_financial_report/wizard/vat_report_wizard.py

@ -1,10 +1,10 @@
# Copyright 2018 Forest and Biomass Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import pycompat
from odoo.tools.safe_eval import safe_eval
class VATReportWizard(models.TransientModel):
@ -12,98 +12,104 @@ class VATReportWizard(models.TransientModel):
_description = "VAT Report Wizard"
company_id = fields.Many2one(
comodel_name='res.company',
comodel_name="res.company",
default=lambda self: self.env.user.company_id,
required=False,
string='Company'
string="Company",
)
date_range_id = fields.Many2one(
comodel_name='date.range',
string='Date range'
date_range_id = fields.Many2one(comodel_name="date.range", string="Date range")
date_from = fields.Date("Start Date", required=True)
date_to = fields.Date("End Date", required=True)
based_on = fields.Selection(
[("taxtags", "Tax Tags"), ("taxgroups", "Tax Groups")],
string="Based On",
required=True,
default="taxtags",
)
date_from = fields.Date('Start Date', required=True)
date_to = fields.Date('End Date', required=True)
based_on = fields.Selection([('taxtags', 'Tax Tags'),
('taxgroups', 'Tax Groups')],
string='Based On',
required=True,
default='taxtags')
tax_detail = fields.Boolean('Detail Taxes')
tax_detail = fields.Boolean("Detail Taxes")
@api.onchange('company_id')
@api.onchange("company_id")
def onchange_company_id(self):
if self.company_id and self.date_range_id.company_id and \
self.date_range_id.company_id != self.company_id:
if (
self.company_id
and self.date_range_id.company_id
and self.date_range_id.company_id != self.company_id
):
self.date_range_id = False
res = {'domain': {'date_range_id': [],
}
}
res = {"domain": {"date_range_id": [],}}
if not self.company_id:
return res
else:
res['domain']['date_range_id'] += [
'|', ('company_id', '=', self.company_id.id),
('company_id', '=', False)]
res["domain"]["date_range_id"] += [
"|",
("company_id", "=", self.company_id.id),
("company_id", "=", False),
]
return res
@api.onchange('date_range_id')
@api.onchange("date_range_id")
def onchange_date_range_id(self):
"""Handle date range change."""
self.date_from = self.date_range_id.date_start
self.date_to = self.date_range_id.date_end
@api.multi
@api.constrains('company_id', 'date_range_id')
@api.constrains("company_id", "date_range_id")
def _check_company_id_date_range_id(self):
for rec in self.sudo():
if rec.company_id and rec.date_range_id.company_id and\
rec.company_id != rec.date_range_id.company_id:
if (
rec.company_id
and rec.date_range_id.company_id
and rec.company_id != rec.date_range_id.company_id
):
raise ValidationError(
_('The Company in the Vat Report Wizard and in '
'Date Range must be the same.'))
_(
"The Company in the Vat Report Wizard and in "
"Date Range must be the same."
)
)
@api.multi
def button_export_html(self):
self.ensure_one()
action = self.env.ref(
'account_financial_report.action_report_vat_report')
action = self.env.ref("account_financial_report.action_report_vat_report")
vals = action.read()[0]
context1 = vals.get('context', {})
context1 = vals.get("context", {})
if isinstance(context1, pycompat.string_types):
context1 = safe_eval(context1)
model = self.env['report_vat_report']
model = self.env["report_vat_report"]
report = model.create(self._prepare_vat_report())
report.compute_data_for_report()
context1['active_id'] = report.id
context1['active_ids'] = report.ids
vals['context'] = context1
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'
report_type = "qweb-pdf"
return self._export(report_type)
@api.multi
def button_export_xlsx(self):
self.ensure_one()
report_type = 'xlsx'
report_type = "xlsx"
return self._export(report_type)
def _prepare_vat_report(self):
self.ensure_one()
return {
'company_id': self.company_id.id,
'date_from': self.date_from,
'date_to': self.date_to,
'based_on': self.based_on,
'tax_detail': self.tax_detail,
"company_id": self.company_id.id,
"date_from": self.date_from,
"date_to": self.date_to,
"based_on": self.based_on,
"tax_detail": self.tax_detail,
}
def _export(self, report_type):
"""Default export is PDF."""
model = self.env['report_vat_report']
model = self.env["report_vat_report"]
report = model.create(self._prepare_vat_report())
report.compute_data_for_report()
return report.print_report(report_type)

75
account_financial_report/wizard/vat_report_wizard_view.xml

@ -1,44 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="vat_report_wizard" model="ir.ui.view">
<field name="name">vat_report_wizard_view</field>
<field name="model">vat.report.wizard</field>
<field name="arch" type="xml">
<form string="VAT Report Options">
<group name="main_info">
<field name="company_id" options="{'no_create': True}" groups="base.group_multi_company"/>
</group>
<group name="filters">
<group name="date_range">
<field name="date_range_id"/>
<field name="date_from"/>
<field name="date_to"/>
<form string="VAT Report Options">
<group name="main_info">
<field
name="company_id"
options="{'no_create': True}"
groups="base.group_multi_company"
/>
</group>
<group name="other_filters">
<field name="based_on" widget="radio"/>
<field name="tax_detail"/>
<group name="filters">
<group name="date_range">
<field name="date_range_id" />
<field name="date_from" />
<field name="date_to" />
</group>
<group name="other_filters">
<field name="based_on" widget="radio" />
<field name="tax_detail" />
</group>
</group>
</group>
<footer>
<button name="button_export_html" string="View"
type="object" default_focus="1" class="oe_highlight"/>
<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"/>
<button
name="button_export_pdf"
string="Export PDF"
type="object"
/>
or
<button name="button_export_xlsx" string="Export XLSX" type="object"/>
<button
name="button_export_xlsx"
string="Export XLSX"
type="object"
/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</form>
</field>
</record>
<act_window id="action_vat_report_wizard"
name="VAT Report"
res_model="vat.report.wizard"
view_type="form"
view_mode="form"
view_id="vat_report_wizard"
target="new" />
<act_window
id="action_vat_report_wizard"
name="VAT Report"
res_model="vat.report.wizard"
view_type="form"
view_mode="form"
view_id="vat_report_wizard"
target="new"
/>
</odoo>

1
setup/account_financial_report/odoo/addons/account_financial_report

@ -0,0 +1 @@
../../../../account_financial_report

6
setup/account_financial_report/setup.py

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading…
Cancel
Save