Joan Sisquella
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 6621 additions and 9297 deletions
-
5account_financial_report/__manifest__.py
-
1546account_financial_report/i18n/es.po
-
22account_financial_report/models/account_group.py
-
8account_financial_report/models/account_move_line.py
-
5account_financial_report/readme/CONTRIBUTORS.rst
-
1account_financial_report/report/__init__.py
-
23account_financial_report/report/abstract_report.py
-
207account_financial_report/report/abstract_report_xlsx.py
-
987account_financial_report/report/aged_partner_balance.py
-
181account_financial_report/report/aged_partner_balance_xlsx.py
-
2474account_financial_report/report/general_ledger.py
-
286account_financial_report/report/general_ledger_xlsx.py
-
1168account_financial_report/report/journal_ledger.py
-
112account_financial_report/report/journal_ledger_xlsx.py
-
1232account_financial_report/report/open_items.py
-
148account_financial_report/report/open_items_xlsx.py
-
438account_financial_report/report/templates/aged_partner_balance.xml
-
345account_financial_report/report/templates/general_ledger.xml
-
110account_financial_report/report/templates/journal_ledger.xml
-
313account_financial_report/report/templates/open_items.xml
-
1033account_financial_report/report/templates/trial_balance.xml
-
172account_financial_report/report/templates/vat_report.xml
-
1205account_financial_report/report/trial_balance.py
-
118account_financial_report/report/trial_balance_xlsx.py
-
586account_financial_report/report/vat_report.py
-
38account_financial_report/report/vat_report_xlsx.py
-
152account_financial_report/reports.xml
-
4account_financial_report/tests/__init__.py
-
399account_financial_report/tests/abstract_test.py
-
78account_financial_report/tests/abstract_test_foreign_currency.py
-
75account_financial_report/tests/abstract_test_tax_report.py
-
41account_financial_report/tests/test_aged_partner_balance.py
-
561account_financial_report/tests/test_general_ledger.py
-
209account_financial_report/tests/test_journal_ledger.py
-
37account_financial_report/tests/test_open_items.py
-
649account_financial_report/tests/test_trial_balance.py
-
252account_financial_report/tests/test_vat_report.py
-
20account_financial_report/view/report_template.xml
-
83account_financial_report/wizard/aged_partner_balance_wizard.py
-
20account_financial_report/wizard/aged_partner_balance_wizard_view.xml
-
157account_financial_report/wizard/general_ledger_wizard.py
-
73account_financial_report/wizard/general_ledger_wizard_view.xml
-
81account_financial_report/wizard/journal_ledger_wizard.py
-
88account_financial_report/wizard/open_items_wizard.py
-
18account_financial_report/wizard/open_items_wizard_view.xml
-
90account_financial_report/wizard/trial_balance_wizard.py
-
18account_financial_report/wizard/trial_balance_wizard_view.xml
-
48account_financial_report/wizard/vat_report_wizard.py
-
2account_financial_report/wizard/vat_report_wizard_view.xml
1546
account_financial_report/i18n/es.po
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,23 +0,0 @@ |
|||
# 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 |
|||
|
|||
|
|||
class AbstractReport(models.AbstractModel): |
|||
_name = 'account_financial_report_abstract' |
|||
_description = 'Abstract Report' |
|||
|
|||
def _transient_clean_rows_older_than(self, seconds): |
|||
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 = ( |
|||
"DELETE FROM %s" |
|||
" WHERE COALESCE(" |
|||
"write_date, create_date, (now() at time zone 'UTC'))" |
|||
"::timestamp < ((now() at time zone 'UTC') - interval %s)" |
|||
) |
|||
self.env.cr.execute(query, (AsIs(self._table), "%s seconds" % seconds)) |
987
account_financial_report/report/aged_partner_balance.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2474
account_financial_report/report/general_ledger.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1168
account_financial_report/report/journal_ledger.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1232
account_financial_report/report/open_items.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1033
account_financial_report/report/templates/trial_balance.xml
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1205
account_financial_report/report/trial_balance.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,356 +1,264 @@ |
|||
# Copyright 2018 Forest and Biomass Romania |
|||
# Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import api, fields, models |
|||
from odoo import models, api |
|||
import operator |
|||
|
|||
|
|||
class VATReport(models.TransientModel): |
|||
_name = "report_vat_report" |
|||
_inherit = 'account_financial_report_abstract' |
|||
""" Here, we just define class fields. |
|||
For methods, go more bottom at this file. |
|||
class VATReport(models.AbstractModel): |
|||
_name = 'report.account_financial_report.vat_report' |
|||
_description = "VAT Report" |
|||
|
|||
The class hierarchy is : |
|||
* VATReport |
|||
** VATReportTaxTags |
|||
*** VATReportTax |
|||
""" |
|||
def _get_tax_data(self, tax_ids, hide_tax_at_zero): |
|||
domain = [] |
|||
if hide_tax_at_zero: |
|||
domain += [('id', 'in', tax_ids)] |
|||
taxes = self.env['account.tax'].search(domain) |
|||
tax_data = {} |
|||
for tax in taxes: |
|||
tax_data.update({ |
|||
tax.id: { |
|||
'id': tax.id, |
|||
'name': tax.name, |
|||
'tax_group_id': tax.tax_group_id.id, |
|||
'tags_ids': tax.tag_ids.ids, |
|||
'type_tax_use': tax.type_tax_use, |
|||
'amount_type': tax.amount_type, |
|||
} |
|||
}) |
|||
return tax_data |
|||
|
|||
# Filters fields, used for data computation |
|||
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') |
|||
|
|||
# Data fields, used to browse report data |
|||
taxtags_ids = fields.One2many( |
|||
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' |
|||
|
|||
report_id = fields.Many2one( |
|||
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 |
|||
) |
|||
|
|||
# Data fields, used for report display |
|||
code = fields.Char() |
|||
name = fields.Char() |
|||
net = fields.Float(digits=(16, 2)) |
|||
tax = fields.Float(digits=(16, 2)) |
|||
|
|||
# Data fields, used to browse report data |
|||
tax_ids = fields.One2many( |
|||
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' |
|||
|
|||
report_tax_id = fields.Many2one( |
|||
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', |
|||
) |
|||
|
|||
# Data fields, used for report display |
|||
code = fields.Char() |
|||
name = fields.Char() |
|||
net = fields.Float(digits=(16, 2)) |
|||
tax = fields.Float(digits=(16, 2)) |
|||
|
|||
|
|||
class VATReportCompute(models.TransientModel): |
|||
""" Here, we just define methods. |
|||
For class fields, go more top at this file. |
|||
""" |
|||
@api.model |
|||
def _get_tax_report_domain(self, company_id, date_from, |
|||
date_to, only_posted_moves): |
|||
domain = [('company_id', '=', company_id), |
|||
('date', '>=', date_from), |
|||
('date', '<=', date_to), |
|||
('tax_line_id', '!=', False), |
|||
('tax_exigible', '=', True)] |
|||
if only_posted_moves: |
|||
domain += [('move_id.state', '=', 'posted')] |
|||
return domain |
|||
|
|||
_inherit = 'report_vat_report' |
|||
@api.model |
|||
def _get_net_report_domain(self, company_id, date_from, |
|||
date_to, only_posted_moves): |
|||
domain = [('company_id', '=', company_id), |
|||
('date', '>=', date_from), |
|||
('date', '<=', date_to), |
|||
('tax_exigible', '=', True)] |
|||
if only_posted_moves: |
|||
domain += [('move_id.state', '=', 'posted')] |
|||
return domain |
|||
|
|||
@api.multi |
|||
def print_report(self, report_type='qweb'): |
|||
self.ensure_one() |
|||
if report_type == 'xlsx': |
|||
report_name = 'a_f_r.report_vat_report_xlsx' |
|||
else: |
|||
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) |
|||
return action.with_context(context).report_action(self, config=False) |
|||
def _get_vat_report_data(self, company_id, date_from, |
|||
date_to, only_posted_moves, hide_tax_at_zero): |
|||
tax_domain = self._get_tax_report_domain( |
|||
company_id, date_from, date_to, only_posted_moves |
|||
) |
|||
ml_fields = ['id', 'tax_base_amount', 'balance', 'tax_line_id', |
|||
'tax_ids', 'analytic_tag_ids'] |
|||
tax_move_lines = self.env['account.move.line'].search_read( |
|||
domain=tax_domain, |
|||
fields=ml_fields, |
|||
) |
|||
net_domain = self._get_net_report_domain( |
|||
company_id, date_from, date_to, only_posted_moves |
|||
) |
|||
taxed_move_lines = self.env['account.move.line'].search_read( |
|||
domain=net_domain, |
|||
fields=ml_fields, |
|||
) |
|||
taxed_move_lines = list( |
|||
filter(lambda d: d['tax_ids'], taxed_move_lines)) |
|||
vat_data = [] |
|||
for tax_move_line in tax_move_lines: |
|||
vat_data.append({ |
|||
'net': 0.0, |
|||
'tax': tax_move_line['balance'], |
|||
'tax_line_id': tax_move_line['tax_line_id'][0], |
|||
}) |
|||
for taxed_move_line in taxed_move_lines: |
|||
for tax_id in taxed_move_line['tax_ids']: |
|||
vat_data.append({ |
|||
'net': taxed_move_line['balance'], |
|||
'tax': 0.0, |
|||
'tax_line_id': tax_id, |
|||
}) |
|||
tax_ids = list(map(operator.itemgetter('tax_line_id'), vat_data)) |
|||
tax_ids = list(set(tax_ids)) |
|||
tax_data = self._get_tax_data(tax_ids, hide_tax_at_zero) |
|||
return vat_data, tax_data |
|||
|
|||
def _get_html(self): |
|||
result = {} |
|||
rcontext = {} |
|||
context = dict(self.env.context) |
|||
report = self.browse(context.get('active_id')) |
|||
if report: |
|||
rcontext['o'] = report |
|||
result['html'] = self.env.ref( |
|||
'account_financial_report.report_vat_report').render( |
|||
rcontext) |
|||
return result |
|||
def _get_tax_group_data(self, tax_group_ids): |
|||
tax_groups = self.env['account.tax.group'].browse(tax_group_ids) |
|||
tax_group_data = {} |
|||
for tax_group in tax_groups: |
|||
tax_group_data.update({ |
|||
tax_group.id: { |
|||
'id': tax_group.id, |
|||
'name': tax_group.name, |
|||
'code': str(tax_group.sequence), |
|||
} |
|||
}) |
|||
return tax_group_data |
|||
|
|||
@api.model |
|||
def get_html(self, given_context=None): |
|||
return self.with_context(given_context)._get_html() |
|||
|
|||
@api.multi |
|||
def compute_data_for_report(self): |
|||
self.ensure_one() |
|||
# Compute report data |
|||
if self.based_on == 'taxtags': |
|||
self._inject_taxtags_values() |
|||
self._inject_tax_taxtags_values() |
|||
elif self.based_on == 'taxgroups': |
|||
self._inject_taxgroups_values() |
|||
self._inject_tax_taxgroups_values() |
|||
# Refresh cache because all data are computed with SQL requests |
|||
self.refresh() |
|||
def _initialize_vat_report( |
|||
self, tax_id, tag_or_group_id, vat_report, tax_data |
|||
): |
|||
if tag_or_group_id not in vat_report.keys(): |
|||
vat_report[tag_or_group_id] = {} |
|||
vat_report[tag_or_group_id]['net'] = 0.0 |
|||
vat_report[tag_or_group_id]['tax'] = 0.0 |
|||
vat_report[tag_or_group_id][tax_id] = dict(tax_data[tax_id]) |
|||
vat_report[tag_or_group_id][tax_id].update( |
|||
{'net': 0.0, 'tax': 0.0} |
|||
) |
|||
else: |
|||
if tax_id not in vat_report[tag_or_group_id].keys(): |
|||
vat_report[tag_or_group_id][tax_id] = dict(tax_data[tax_id]) |
|||
vat_report[tag_or_group_id][tax_id].update( |
|||
{'net': 0.0, 'tax': 0.0} |
|||
) |
|||
return vat_report |
|||
|
|||
def _inject_taxtags_values(self): |
|||
"""Inject report values for report_vat_report_taxtags.""" |
|||
query_inject_taxtags = """ |
|||
WITH |
|||
taxtags AS |
|||
(SELECT coalesce(regexp_replace(tag.name, |
|||
'[^0-9\\.]+', '', 'g'), ' ') AS code, |
|||
tag.name, tag.id, |
|||
coalesce(sum(movetax.tax_base_amount), 0.00) AS net, |
|||
coalesce(sum(movetax.balance), 0.00) AS tax |
|||
FROM |
|||
account_account_tag AS tag |
|||
INNER JOIN account_tax_account_tag AS taxtag |
|||
ON tag.id = taxtag.account_account_tag_id |
|||
INNER JOIN account_tax AS tax |
|||
ON tax.id = taxtag.account_tax_id |
|||
INNER JOIN account_move_line AS movetax |
|||
ON movetax.tax_line_id = tax.id |
|||
INNER JOIN account_move AS move |
|||
ON move.id = movetax.move_id |
|||
WHERE tag.id is not null AND movetax.tax_exigible |
|||
AND move.company_id = %s AND move.date >= %s |
|||
AND move.date <= %s AND move.state = 'posted' |
|||
GROUP BY tag.id |
|||
ORDER BY code, tag.name |
|||
) |
|||
INSERT INTO |
|||
report_vat_report_taxtag |
|||
( |
|||
report_id, |
|||
create_uid, |
|||
create_date, |
|||
taxtag_id, |
|||
code, |
|||
name, |
|||
net, tax |
|||
) |
|||
SELECT |
|||
%s AS report_id, |
|||
%s AS create_uid, |
|||
NOW() AS create_date, |
|||
tag.id, |
|||
tag.code, |
|||
tag.name, |
|||
abs(tag.net), |
|||
abs(tag.tax) |
|||
FROM |
|||
taxtags tag |
|||
""" |
|||
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 _get_vat_report_group_data(self, vat_report_data, tax_data, |
|||
tax_detail, hide_tax_at_zero): |
|||
vat_report = {} |
|||
if not hide_tax_at_zero: |
|||
for tax_id in tax_data.keys(): |
|||
if tax_data[tax_id]['amount_type'] == 'group': |
|||
continue |
|||
tax_group_id = tax_data[tax_id]['tax_group_id'] |
|||
vat_report = self._initialize_vat_report( |
|||
tax_id, tax_group_id, vat_report, tax_data |
|||
) |
|||
for tax_move_line in vat_report_data: |
|||
tax_id = tax_move_line['tax_line_id'] |
|||
if tax_data[tax_id]['amount_type'] == 'group': |
|||
continue |
|||
tax_group_id = tax_data[tax_id]['tax_group_id'] |
|||
vat_report = self._initialize_vat_report( |
|||
tax_id, tax_group_id, vat_report, tax_data |
|||
) |
|||
vat_report[tax_group_id]['net'] += tax_move_line['net'] |
|||
vat_report[tax_group_id]['tax'] += tax_move_line['tax'] |
|||
vat_report[tax_group_id][tax_id]['net'] += tax_move_line['net'] |
|||
vat_report[tax_group_id][tax_id]['tax'] += tax_move_line['tax'] |
|||
tax_group_data = self._get_tax_group_data(vat_report.keys()) |
|||
vat_report_list = [] |
|||
for tax_group_id in vat_report.keys(): |
|||
vat_report_group = {} |
|||
vat_report_group.update({tax_group_id: { |
|||
'name': tax_group_data[tax_group_id]['name'], |
|||
'code': tax_group_data[tax_group_id]['code'], |
|||
'net': vat_report[tax_group_id]['net'], |
|||
'tax': vat_report[tax_group_id]['tax'], |
|||
} |
|||
}) |
|||
if tax_detail: |
|||
vat_report_group[tax_group_id]['taxes'] = [] |
|||
for tax_id in vat_report[tax_group_id]: |
|||
if isinstance(tax_id, int): |
|||
vat_report_group[tax_group_id]['taxes'].append( |
|||
vat_report[tax_group_id][tax_id] |
|||
) |
|||
vat_report_list.append(vat_report_group[tax_group_id]) |
|||
return vat_report_list |
|||
|
|||
def _inject_taxgroups_values(self): |
|||
"""Inject report values for report_vat_report_taxtags.""" |
|||
query_inject_taxgroups = """ |
|||
WITH |
|||
taxgroups AS |
|||
(SELECT coalesce(taxgroup.sequence, 0) AS code, |
|||
taxgroup.name, taxgroup.id, |
|||
coalesce(sum(movetax.tax_base_amount), 0.00) AS net, |
|||
coalesce(sum(movetax.balance), 0.00) AS tax |
|||
FROM |
|||
account_tax_group AS taxgroup |
|||
INNER JOIN account_tax AS tax |
|||
ON tax.tax_group_id = taxgroup.id |
|||
INNER JOIN account_move_line AS movetax |
|||
ON movetax.tax_line_id = tax.id |
|||
INNER JOIN account_move AS move |
|||
ON move.id = movetax.move_id |
|||
WHERE taxgroup.id is not null AND movetax.tax_exigible |
|||
AND move.company_id = %s AND move.date >= %s |
|||
AND move.date <= %s AND move.state = 'posted' |
|||
GROUP BY taxgroup.id |
|||
ORDER BY code, taxgroup.name |
|||
) |
|||
INSERT INTO |
|||
report_vat_report_taxtag |
|||
( |
|||
report_id, |
|||
create_uid, |
|||
create_date, |
|||
taxgroup_id, |
|||
code, |
|||
name, |
|||
net, tax |
|||
) |
|||
SELECT |
|||
%s AS report_id, |
|||
%s AS create_uid, |
|||
NOW() AS create_date, |
|||
groups.id, |
|||
groups.code, |
|||
groups.name, |
|||
abs(groups.net), |
|||
abs(groups.tax) |
|||
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) |
|||
def _get_tags_data(self, tags_ids): |
|||
tags = self.env['account.account.tag'].browse(tags_ids) |
|||
tags_data = {} |
|||
for tag in tags: |
|||
tags_data.update({tag.id: { |
|||
'code': "", |
|||
'name': tag.name} |
|||
}) |
|||
return tags_data |
|||
|
|||
def _inject_tax_taxtags_values(self): |
|||
""" Inject report values for report_vat_report_tax. """ |
|||
# pylint: disable=sql-injection |
|||
query_inject_tax = """ |
|||
WITH |
|||
taxtags_tax AS |
|||
( |
|||
SELECT |
|||
tag.id AS report_tax_id, ' ' AS code, |
|||
tax.name, tax.id, |
|||
coalesce(sum(movetax.tax_base_amount), 0.00) AS net, |
|||
coalesce(sum(movetax.balance), 0.00) AS tax |
|||
FROM |
|||
report_vat_report_taxtag AS tag |
|||
INNER JOIN account_tax_account_tag AS taxtag |
|||
ON tag.taxtag_id = taxtag.account_account_tag_id |
|||
INNER JOIN account_tax AS tax |
|||
ON tax.id = taxtag.account_tax_id |
|||
INNER JOIN account_move_line AS movetax |
|||
ON movetax.tax_line_id = tax.id |
|||
INNER JOIN account_move AS move |
|||
ON move.id = movetax.move_id |
|||
WHERE tag.id is not null AND movetax.tax_exigible |
|||
AND tag.report_id = %s AND move.company_id = %s |
|||
AND move.date >= %s AND move.date <= %s |
|||
AND move.state = 'posted' |
|||
GROUP BY tag.id, tax.id |
|||
ORDER BY tax.name |
|||
) |
|||
INSERT INTO |
|||
report_vat_report_tax |
|||
( |
|||
report_tax_id, |
|||
create_uid, |
|||
create_date, |
|||
tax_id, |
|||
name, |
|||
net, |
|||
tax |
|||
) |
|||
SELECT |
|||
tt.report_tax_id, |
|||
%s AS create_uid, |
|||
NOW() AS create_date, |
|||
tt.id, |
|||
tt.name, |
|||
abs(tt.net), |
|||
abs(tt.tax) |
|||
FROM |
|||
taxtags_tax tt |
|||
""" |
|||
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 _get_vat_report_tag_data( |
|||
self, vat_report_data, tax_data, tax_detail, hide_tax_at_zero |
|||
): |
|||
vat_report = {} |
|||
if not hide_tax_at_zero: |
|||
for tax_id in tax_data.keys(): |
|||
if tax_data[tax_id]['amount_type'] == 'group': |
|||
continue |
|||
tags_ids = tax_data[tax_id]['tags_ids'] |
|||
if tags_ids: |
|||
for tag_id in tags_ids: |
|||
vat_report = self._initialize_vat_report( |
|||
tax_id, tag_id, vat_report, tax_data |
|||
) |
|||
for tax_move_line in vat_report_data: |
|||
tax_id = tax_move_line['tax_line_id'] |
|||
if tax_data[tax_id]['amount_type'] == 'group': |
|||
pass |
|||
else: |
|||
tags_ids = tax_data[tax_id]['tags_ids'] |
|||
if tags_ids: |
|||
for tag_id in tags_ids: |
|||
vat_report = self._initialize_vat_report( |
|||
tax_id, tag_id, vat_report, tax_data |
|||
) |
|||
vat_report[tag_id][tax_id]['net'] += tax_move_line['net'] |
|||
vat_report[tag_id][tax_id]['tax'] += tax_move_line['tax'] |
|||
vat_report[tag_id]['net'] += tax_move_line['net'] |
|||
vat_report[tag_id]['tax'] += tax_move_line['tax'] |
|||
tags_data = self._get_tags_data(vat_report.keys()) |
|||
vat_report_list = [] |
|||
for tag_id in vat_report.keys(): |
|||
vat_report_tag = {} |
|||
vat_report_tag.update({tag_id: { |
|||
'name': tags_data[tag_id]['name'], |
|||
'code': tags_data[tag_id]['code'], |
|||
'net': vat_report[tag_id]['net'], |
|||
'tax': vat_report[tag_id]['tax'], |
|||
} |
|||
}) |
|||
if tax_detail: |
|||
vat_report_tag[tag_id]['taxes'] = [] |
|||
for tax_id in vat_report[tag_id]: |
|||
if isinstance(tax_id, int): |
|||
vat_report_tag[tag_id]['taxes'].append( |
|||
vat_report[tag_id][tax_id] |
|||
) |
|||
vat_report_list.append(vat_report_tag[tag_id]) |
|||
return vat_report_list |
|||
|
|||
def _inject_tax_taxgroups_values(self): |
|||
""" Inject report values for report_vat_report_tax. """ |
|||
# pylint: disable=sql-injection |
|||
query_inject_tax = """ |
|||
WITH |
|||
taxtags_tax AS |
|||
( |
|||
SELECT |
|||
taxtag.id AS report_tax_id, ' ' AS code, |
|||
tax.name, tax.id, |
|||
coalesce(sum(movetax.tax_base_amount), 0.00) AS net, |
|||
coalesce(sum(movetax.balance), 0.00) AS tax |
|||
FROM |
|||
report_vat_report_taxtag AS taxtag |
|||
INNER JOIN account_tax AS tax |
|||
ON tax.tax_group_id = taxtag.taxgroup_id |
|||
INNER JOIN account_move_line AS movetax |
|||
ON movetax.tax_line_id = tax.id |
|||
INNER JOIN account_move AS move |
|||
ON move.id = movetax.move_id |
|||
WHERE taxtag.id is not null AND movetax.tax_exigible |
|||
AND taxtag.report_id = %s AND move.company_id = %s |
|||
AND move.date >= %s AND move.date <= %s |
|||
AND move.state = 'posted' |
|||
GROUP BY taxtag.id, tax.id |
|||
ORDER BY tax.name |
|||
@api.multi |
|||
def _get_report_values(self, docids, data): |
|||
wizard_id = data['wizard_id'] |
|||
company = self.env['res.company'].browse(data['company_id']) |
|||
company_id = data['company_id'] |
|||
date_from = data['date_from'] |
|||
date_to = data['date_to'] |
|||
based_on = data['based_on'] |
|||
tax_detail = data['tax_detail'] |
|||
only_posted_moves = data['only_posted_moves'] |
|||
hide_tax_at_zero = data['hide_tax_at_zero'] |
|||
vat_report_data, tax_data = self._get_vat_report_data( |
|||
company_id, date_from, date_to, only_posted_moves, hide_tax_at_zero |
|||
) |
|||
INSERT INTO |
|||
report_vat_report_tax |
|||
( |
|||
report_tax_id, |
|||
create_uid, |
|||
create_date, |
|||
tax_id, |
|||
name, |
|||
net, |
|||
tax |
|||
) |
|||
SELECT |
|||
tt.report_tax_id, |
|||
%s AS create_uid, |
|||
NOW() AS create_date, |
|||
tt.id, |
|||
tt.name, |
|||
abs(tt.net), |
|||
abs(tt.tax) |
|||
FROM |
|||
taxtags_tax tt |
|||
""" |
|||
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) |
|||
if based_on == 'taxgroups': |
|||
vat_report = self._get_vat_report_group_data( |
|||
vat_report_data, tax_data, tax_detail, hide_tax_at_zero |
|||
) |
|||
else: |
|||
vat_report = self._get_vat_report_tag_data( |
|||
vat_report_data, tax_data, tax_detail, hide_tax_at_zero |
|||
) |
|||
return { |
|||
'doc_ids': [wizard_id], |
|||
'doc_model': 'open.items.report.wizard', |
|||
'docs': self.env['open.items.report.wizard'].browse(wizard_id), |
|||
'company_name': company.display_name, |
|||
'currency_name': company.currency_id.name, |
|||
'date_to': data['date_to'], |
|||
'date_from': data['date_from'], |
|||
'based_on': data['based_on'], |
|||
'tax_detail': data['tax_detail'], |
|||
'vat_report': vat_report, |
|||
} |
@ -1,399 +0,0 @@ |
|||
# Author: Julien Coux |
|||
# Copyright 2016 Camptocamp SA |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import logging |
|||
|
|||
from odoo.tests import common |
|||
from odoo.tools import test_reports |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AbstractTest(common.TransactionCase): |
|||
"""Common technical tests for all reports.""" |
|||
at_install = False |
|||
post_install = True |
|||
|
|||
accounts = {} |
|||
|
|||
def with_context(self, *args, **kwargs): |
|||
context = dict(args[0] if args else self.env.context, **kwargs) |
|||
self.env = self.env(context=context) |
|||
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', |
|||
}) |
|||
|
|||
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.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) |
|||
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, |
|||
}) |
|||
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, |
|||
}) |
|||
|
|||
# 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, |
|||
}) |
|||
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, |
|||
}) |
|||
self.invoice_in.action_invoice_open() |
|||
|
|||
def setUp(self): |
|||
super(AbstractTest, self).setUp() |
|||
|
|||
self.with_context() |
|||
self._chart_template_create() |
|||
self._add_chart_of_accounts() |
|||
self._journals_create() |
|||
self._invoice_create() |
|||
|
|||
self.model = self._getReportModel() |
|||
|
|||
self.qweb_report_name = self._getQwebReportName() |
|||
self.xlsx_report_name = self._getXlsxReportName() |
|||
self.xlsx_action_name = self._getXlsxReportActionName() |
|||
|
|||
self.report_title = self._getReportTitle() |
|||
|
|||
self.base_filters = self._getBaseFilters() |
|||
self.additional_filters = self._getAdditionalFiltersToBeTested() |
|||
|
|||
self.report = self.model.create(self.base_filters) |
|||
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') |
|||
|
|||
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') |
|||
|
|||
def test_xlsx(self): |
|||
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') |
|||
|
|||
def test_02_generation_report_html(self): |
|||
"""Check if report HTML is correctly generated""" |
|||
|
|||
# Check if returned report action is correct |
|||
report_type = 'qweb-html' |
|||
report_action = self.report.print_report(report_type) |
|||
self.assertDictContainsSubset( |
|||
{ |
|||
'type': 'ir.actions.report', |
|||
'report_name': self.qweb_report_name, |
|||
'report_type': 'qweb-html', |
|||
}, |
|||
report_action |
|||
) |
|||
|
|||
# Check if report template is correct |
|||
report = self.env['ir.actions.report'].search( |
|||
[('report_name', '=', self.qweb_report_name), |
|||
('report_type', '=', report_type)], limit=1) |
|||
self.assertEqual(report.report_type, 'qweb-html') |
|||
|
|||
rep = report.render(self.report.ids, {}) |
|||
|
|||
self.assertTrue(self.report_title.encode('utf8') in rep[0]) |
|||
self.assertTrue( |
|||
self.report.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""" |
|||
|
|||
for filters in [{}] + self.additional_filters: |
|||
current_filter = self.base_filters.copy() |
|||
current_filter.update(filters) |
|||
|
|||
report = self.model.create(current_filter) |
|||
report.compute_data_for_report() |
|||
|
|||
self.assertGreaterEqual(len(report.account_ids), 1) |
|||
|
|||
# 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)], |
|||
}) |
|||
|
|||
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) |
|||
|
|||
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') |
|||
|
|||
current_filter = self.base_filters.copy() |
|||
current_filter.update(filters) |
|||
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') |
|||
|
|||
self.assertEqual(len(partner_ids3), 1) |
|||
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 |
|||
|
|||
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)], |
|||
}) |
|||
|
|||
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) |
|||
|
|||
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 |
|||
) |
|||
|
|||
def _partner_test_is_possible(self, filters): |
|||
""" |
|||
:return: |
|||
a boolean to indicate if partner test is possible |
|||
with current filters |
|||
""" |
|||
return True |
|||
|
|||
def _getReportModel(self): |
|||
""" |
|||
:return: the report model name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getQwebReportName(self): |
|||
""" |
|||
:return: the qweb report name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getXlsxReportName(self): |
|||
""" |
|||
:return: the xlsx report name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getXlsxReportActionName(self): |
|||
""" |
|||
:return: the xlsx report action name |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getReportTitle(self): |
|||
""" |
|||
:return: the report title displayed into the report |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getBaseFilters(self): |
|||
""" |
|||
:return: the minimum required filters to generate report |
|||
""" |
|||
raise NotImplementedError() |
|||
|
|||
def _getAdditionalFiltersToBeTested(self): |
|||
""" |
|||
:return: the additional filters to generate report variants |
|||
""" |
|||
raise NotImplementedError() |
@ -1,78 +0,0 @@ |
|||
# Copyright 2018 Forest and Biomass Romania |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import logging |
|||
from . import abstract_test |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AbstractTestForeignCurrency(abstract_test.AbstractTest): |
|||
"""Common technical tests for all reports.""" |
|||
|
|||
def _chart_template_create(self): |
|||
super(AbstractTestForeignCurrency, self)._chart_template_create() |
|||
# Account for foreign payments |
|||
self.account_type_other = self.env['account.account.type'].create( |
|||
{'name': 'foreign expenses', |
|||
'type': 'other', |
|||
}) |
|||
act = self.env['account.account.template'].create({ |
|||
'code': '0012', |
|||
'name': 'Foreign Expenses', |
|||
'user_type_id': self.account_type_other.id, |
|||
'chart_template_id': self.chart.id, |
|||
'currency_id': self.env.ref('base.EUR').id, |
|||
}) |
|||
self.env['ir.model.data'].create({ |
|||
'res_id': act.id, |
|||
'model': act._name, |
|||
'name': 'foreign expenses', |
|||
}) |
|||
return True |
|||
|
|||
def _add_chart_of_accounts(self): |
|||
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts() |
|||
self.foreign_expense = self.env['account.account'].search( |
|||
[('currency_id', '=', self.env.ref('base.EUR').id)], limit=1) |
|||
self.foreign_currency_id = self.foreign_expense.currency_id |
|||
return True |
|||
|
|||
def _journals_create(self): |
|||
super(AbstractTestForeignCurrency, self)._journals_create() |
|||
self.journal_foreign_purchases = self.env['account.journal'].create({ |
|||
'company_id': self.company.id, |
|||
'name': 'Test journal for purchase', |
|||
'type': 'purchase', |
|||
'code': 'TFORPUR', |
|||
'default_debit_account_id': self.foreign_expense.id, |
|||
'default_credit_account_id': self.foreign_expense.id, |
|||
'currency_id': self.foreign_currency_id.id, |
|||
}) |
|||
return True |
|||
|
|||
def _invoice_create(self): |
|||
super(AbstractTestForeignCurrency, self)._invoice_create() |
|||
# vendor bill foreign currency |
|||
foreign_vendor_invoice_lines = [(0, False, { |
|||
'name': 'Test description #1', |
|||
'account_id': self.revenue.id, |
|||
'quantity': 1.0, |
|||
'price_unit': 100.0, |
|||
'currency_id': self.foreign_currency_id.id, |
|||
}), (0, False, { |
|||
'name': 'Test description #2', |
|||
'account_id': self.revenue.id, |
|||
'quantity': 2.0, |
|||
'price_unit': 25.0, |
|||
'currency_id': self.foreign_currency_id.id, |
|||
})] |
|||
self.foreign_invoice_in = self.env['account.invoice'].create({ |
|||
'partner_id': self.partner.id, |
|||
'type': 'in_invoice', |
|||
'invoice_line_ids': foreign_vendor_invoice_lines, |
|||
'account_id': self.partner.property_account_payable_id.id, |
|||
'journal_id': self.journal_foreign_purchases.id, |
|||
}) |
|||
self.foreign_invoice_in.action_invoice_open() |
|||
return True |
@ -1,75 +0,0 @@ |
|||
# Copyright 2018 Forest and Biomass Romania |
|||
# 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 |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class AbstractTest(TransactionCase): |
|||
"""Common technical tests for all reports.""" |
|||
|
|||
def setUp(cls): |
|||
super(AbstractTest, cls).setUp() |
|||
|
|||
cls.model = cls._getReportModel() |
|||
|
|||
cls.qweb_report_name = cls._getQwebReportName() |
|||
cls.xlsx_report_name = cls._getXlsxReportName() |
|||
cls.xlsx_action_name = cls._getXlsxReportActionName() |
|||
|
|||
cls.report_title = cls._getReportTitle() |
|||
|
|||
cls.base_filters = cls._getBaseFilters() |
|||
|
|||
cls.report = cls.model.create(cls.base_filters) |
|||
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') |
|||
|
|||
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') |
|||
|
|||
def test_xlsx(self): |
|||
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') |
|||
|
|||
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_action = self.report.print_report(report_type) |
|||
self.assertDictContainsSubset( |
|||
{ |
|||
'type': 'ir.actions.report', |
|||
'report_name': self.qweb_report_name, |
|||
'report_type': 'qweb-html', |
|||
}, |
|||
report_action |
|||
) |
|||
|
|||
# Check if report template is correct |
|||
report = self.env['ir.actions.report'].search( |
|||
[('report_name', '=', self.qweb_report_name), |
|||
('report_type', '=', report_type)], limit=1) |
|||
self.assertEqual(report.report_type, 'qweb-html') |
|||
|
|||
rep = report.render(self.report.ids, {}) |
|||
|
|||
self.assertTrue(self.report_title.encode('utf8') in rep[0]) |
@ -1,41 +0,0 @@ |
|||
# Author: Julien Coux |
|||
# Copyright 2016 Camptocamp SA |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from datetime import date |
|||
from . import abstract_test |
|||
|
|||
|
|||
class TestAgedPartnerBalance(abstract_test.AbstractTest): |
|||
""" |
|||
Technical tests for Aged Partner Balance Report. |
|||
""" |
|||
|
|||
def _getReportModel(self): |
|||
return self.env['report_aged_partner_balance'] |
|||
|
|||
def _getQwebReportName(self): |
|||
return 'account_financial_report.report_aged_partner_balance_qweb' |
|||
|
|||
def _getXlsxReportName(self): |
|||
return 'a_f_r.report_aged_partner_balance_xlsx' |
|||
|
|||
def _getXlsxReportActionName(self): |
|||
return 'account_financial_report.' \ |
|||
'action_report_aged_partner_balance_xlsx' |
|||
|
|||
def _getReportTitle(self): |
|||
return 'Odoo' |
|||
|
|||
def _getBaseFilters(self): |
|||
return { |
|||
'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}, |
|||
] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue