hveficent
7 years ago
committed by
Pedro M. Baeza
43 changed files with 3233 additions and 290 deletions
-
8account_financial_report/README.rst
-
3account_financial_report/__manifest__.py
-
7account_financial_report/menuitems.xml
-
2account_financial_report/report/__init__.py
-
93account_financial_report/report/abstract_report_xlsx.py
-
2account_financial_report/report/aged_partner_balance.py
-
148account_financial_report/report/general_ledger.py
-
79account_financial_report/report/general_ledger_xlsx.py
-
810account_financial_report/report/journal_ledger.py
-
249account_financial_report/report/journal_ledger_xlsx.py
-
230account_financial_report/report/open_items.py
-
35account_financial_report/report/open_items_xlsx.py
-
199account_financial_report/report/templates/general_ledger.xml
-
463account_financial_report/report/templates/journal_ledger.xml
-
89account_financial_report/report/templates/open_items.xml
-
173account_financial_report/report/templates/trial_balance.xml
-
4account_financial_report/report/templates/vat_report.xml
-
61account_financial_report/report/trial_balance.py
-
67account_financial_report/report/trial_balance_xlsx.py
-
31account_financial_report/reports.xml
-
3account_financial_report/static/src/css/report.css
-
13account_financial_report/static/src/js/account_financial_report_backend.js
-
27account_financial_report/static/src/js/account_financial_report_widgets.js
-
2account_financial_report/tests/__init__.py
-
2account_financial_report/tests/abstract_test.py
-
78account_financial_report/tests/abstract_test_foreign_currency.py
-
5account_financial_report/tests/test_general_ledger.py
-
366account_financial_report/tests/test_journal_ledger.py
-
5account_financial_report/tests/test_open_items.py
-
6account_financial_report/tests/test_trial_balance.py
-
2account_financial_report/tests/test_vat_report.py
-
9account_financial_report/view/report_journal_ledger.xml
-
6account_financial_report/view/report_template.xml
-
1account_financial_report/wizard/__init__.py
-
2account_financial_report/wizard/aged_partner_balance_wizard.py
-
7account_financial_report/wizard/general_ledger_wizard.py
-
1account_financial_report/wizard/general_ledger_wizard_view.xml
-
142account_financial_report/wizard/journal_ledger_wizard.py
-
66account_financial_report/wizard/journal_ledger_wizard_view.xml
-
7account_financial_report/wizard/open_items_wizard.py
-
1account_financial_report/wizard/open_items_wizard_view.xml
-
8account_financial_report/wizard/trial_balance_wizard.py
-
1account_financial_report/wizard/trial_balance_wizard_view.xml
@ -0,0 +1,810 @@ |
|||||
|
# Copyright 2017 ACSONE SA/NV |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from odoo import models, fields, api |
||||
|
|
||||
|
DIGITS = (16, 2) |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedger(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger' |
||||
|
|
||||
|
date_from = fields.Date( |
||||
|
required=True |
||||
|
) |
||||
|
date_to = fields.Date( |
||||
|
required=True |
||||
|
) |
||||
|
company_id = fields.Many2one( |
||||
|
comodel_name='res.company', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
move_target = fields.Selection( |
||||
|
selection='_get_move_targets', |
||||
|
default='all', |
||||
|
required=True, |
||||
|
) |
||||
|
sort_option = fields.Selection( |
||||
|
selection='_get_sort_options', |
||||
|
default='move_name', |
||||
|
required=True, |
||||
|
) |
||||
|
group_option = fields.Selection( |
||||
|
selection='_get_group_options', |
||||
|
default='journal', |
||||
|
required=True, |
||||
|
) |
||||
|
journal_ids = fields.Many2many( |
||||
|
comodel_name='account.journal', |
||||
|
required=True, |
||||
|
) |
||||
|
report_journal_ledger_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_journal', |
||||
|
inverse_name='report_id', |
||||
|
) |
||||
|
report_move_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_move', |
||||
|
inverse_name='report_id', |
||||
|
) |
||||
|
report_move_line_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_move_line', |
||||
|
inverse_name='report_id', |
||||
|
) |
||||
|
report_journal_ledger_tax_line_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_journal_tax_line', |
||||
|
inverse_name='report_id', |
||||
|
) |
||||
|
report_tax_line_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_report_tax_line', |
||||
|
inverse_name='report_id', |
||||
|
) |
||||
|
foreign_currency = fields.Boolean() |
||||
|
with_account_name = fields.Boolean() |
||||
|
|
||||
|
@api.model |
||||
|
def _get_move_targets(self): |
||||
|
return self.env['journal.ledger.report.wizard']._get_move_targets() |
||||
|
|
||||
|
@api.model |
||||
|
def _get_sort_options(self): |
||||
|
return self.env['journal.ledger.report.wizard']._get_sort_options() |
||||
|
|
||||
|
@api.model |
||||
|
def _get_group_options(self): |
||||
|
return self.env['journal.ledger.report.wizard']._get_group_options() |
||||
|
|
||||
|
@api.multi |
||||
|
def compute_data_for_report(self): |
||||
|
self.ensure_one() |
||||
|
self._inject_journal_values() |
||||
|
self._inject_move_values() |
||||
|
self._inject_move_line_values() |
||||
|
self._inject_journal_tax_values() |
||||
|
self._update_journal_report_total_values() |
||||
|
|
||||
|
if self.group_option == 'none': |
||||
|
self._inject_report_tax_values() |
||||
|
|
||||
|
# Refresh cache because all data are computed with SQL requests |
||||
|
self.invalidate_cache() |
||||
|
|
||||
|
@api.multi |
||||
|
def _inject_journal_values(self): |
||||
|
self.ensure_one() |
||||
|
sql = """ |
||||
|
DELETE |
||||
|
FROM report_journal_ledger_journal |
||||
|
WHERE report_id = %s |
||||
|
""" |
||||
|
params = ( |
||||
|
self.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
sql = """ |
||||
|
INSERT INTO report_journal_ledger_journal ( |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
report_id, |
||||
|
journal_id, |
||||
|
name, |
||||
|
code, |
||||
|
company_id, |
||||
|
currency_id |
||||
|
) |
||||
|
SELECT |
||||
|
%s as create_uid, |
||||
|
NOW() as create_date, |
||||
|
%s as report_id, |
||||
|
aj.id as journal_id, |
||||
|
aj.name as name, |
||||
|
aj.code as code, |
||||
|
aj.company_id as company_id, |
||||
|
COALESCE(aj.currency_id, company.currency_id) as currency_id |
||||
|
FROM |
||||
|
account_journal aj |
||||
|
LEFT JOIN |
||||
|
res_company company on (company.id = aj.company_id) |
||||
|
WHERE |
||||
|
aj.id in %s |
||||
|
AND |
||||
|
aj.company_id = %s |
||||
|
ORDER BY |
||||
|
aj.name |
||||
|
""" |
||||
|
params = ( |
||||
|
self.env.uid, |
||||
|
self.id, |
||||
|
tuple(self.journal_ids.ids), |
||||
|
self.company_id.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _inject_move_values(self): |
||||
|
self.ensure_one() |
||||
|
sql = """ |
||||
|
DELETE |
||||
|
FROM report_journal_ledger_move |
||||
|
WHERE report_id = %s |
||||
|
""" |
||||
|
params = ( |
||||
|
self.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
sql = self._get_inject_move_insert() |
||||
|
sql += self._get_inject_move_select() |
||||
|
sql += self._get_inject_move_where_clause() |
||||
|
sql += self._get_inject_move_order_by() |
||||
|
params = self._get_inject_move_params() |
||||
|
self.env.cr.execute(sql, params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_inject_move_insert(self): |
||||
|
return """ |
||||
|
INSERT INTO report_journal_ledger_move ( |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
report_id, |
||||
|
report_journal_ledger_id, |
||||
|
move_id, |
||||
|
name, |
||||
|
company_id |
||||
|
) |
||||
|
""" |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_inject_move_select(self): |
||||
|
return """ |
||||
|
SELECT |
||||
|
%s as create_uid, |
||||
|
NOW() as create_date, |
||||
|
rjqj.report_id as report_id, |
||||
|
rjqj.id as report_journal_ledger_id, |
||||
|
am.id as move_id, |
||||
|
am.name as name, |
||||
|
am.company_id as company_id |
||||
|
FROM |
||||
|
account_move am |
||||
|
INNER JOIN |
||||
|
report_journal_ledger_journal rjqj |
||||
|
on (rjqj.journal_id = am.journal_id) |
||||
|
""" |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_inject_move_where_clause(self): |
||||
|
self.ensure_one() |
||||
|
where_clause = """ |
||||
|
WHERE |
||||
|
rjqj.report_id = %s |
||||
|
AND |
||||
|
am.date >= %s |
||||
|
AND |
||||
|
am.date <= %s |
||||
|
""" |
||||
|
if self.move_target != 'all': |
||||
|
where_clause += """ |
||||
|
AND |
||||
|
am.state = %s |
||||
|
""" |
||||
|
return where_clause |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_inject_move_order_by(self): |
||||
|
self.ensure_one() |
||||
|
order_by = """ |
||||
|
ORDER BY |
||||
|
""" |
||||
|
if self.sort_option == 'move_name': |
||||
|
order_by += " am.name" |
||||
|
elif self.sort_option == 'date': |
||||
|
order_by += " am.date, am.name" |
||||
|
return order_by |
||||
|
|
||||
|
@api.multi |
||||
|
def _get_inject_move_params(self): |
||||
|
params = [ |
||||
|
self.env.uid, |
||||
|
self.id, |
||||
|
self.date_from, |
||||
|
self.date_to |
||||
|
] |
||||
|
|
||||
|
if self.move_target != 'all': |
||||
|
params.append(self.move_target) |
||||
|
|
||||
|
return tuple(params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _inject_move_line_values(self): |
||||
|
self.ensure_one() |
||||
|
sql = """ |
||||
|
DELETE |
||||
|
FROM report_journal_ledger_move_line |
||||
|
WHERE report_id = %s |
||||
|
""" |
||||
|
params = ( |
||||
|
self.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
sql = """ |
||||
|
INSERT INTO report_journal_ledger_move_line ( |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
report_id, |
||||
|
report_journal_ledger_id, |
||||
|
report_move_id, |
||||
|
move_line_id, |
||||
|
account_id, |
||||
|
account, |
||||
|
account_code, |
||||
|
account_type, |
||||
|
partner_id, |
||||
|
partner, |
||||
|
date, |
||||
|
entry, |
||||
|
label, |
||||
|
debit, |
||||
|
credit, |
||||
|
company_currency_id, |
||||
|
amount_currency, |
||||
|
currency_id, |
||||
|
currency_name, |
||||
|
tax_id, |
||||
|
taxes_description, |
||||
|
company_id |
||||
|
) |
||||
|
SELECT |
||||
|
%s as create_uid, |
||||
|
NOW() as create_date, |
||||
|
rjqm.report_id as report_id, |
||||
|
rjqm.report_journal_ledger_id as report_journal_ledger_id, |
||||
|
rjqm.id as report_move_id, |
||||
|
aml.id as move_line_id, |
||||
|
aml.account_id as account_id, |
||||
|
aa.name as account, |
||||
|
aa.code as account_code, |
||||
|
aa.internal_type as account_type, |
||||
|
aml.partner_id as partner_id, |
||||
|
p.name as partner, |
||||
|
aml.date as date, |
||||
|
rjqm.name as entry, |
||||
|
aml.name as label, |
||||
|
aml.debit as debit, |
||||
|
aml.credit as credit, |
||||
|
aml.company_currency_id as currency_id, |
||||
|
aml.amount_currency as amount_currency, |
||||
|
aml.currency_id as currency_id, |
||||
|
currency.name as currency_name, |
||||
|
aml.tax_line_id as tax_id, |
||||
|
CASE |
||||
|
WHEN |
||||
|
aml.tax_line_id is not null |
||||
|
THEN |
||||
|
COALESCE(at.description, at.name) |
||||
|
WHEN |
||||
|
aml.tax_line_id is null |
||||
|
THEN |
||||
|
(SELECT |
||||
|
array_to_string( |
||||
|
array_agg(COALESCE(at.description, at.name) |
||||
|
), ', ') |
||||
|
FROM |
||||
|
account_move_line_account_tax_rel aml_at_rel |
||||
|
LEFT JOIN |
||||
|
account_tax at on (at.id = aml_at_rel.account_tax_id) |
||||
|
WHERE |
||||
|
aml_at_rel.account_move_line_id = aml.id) |
||||
|
ELSE |
||||
|
'' |
||||
|
END as taxes_description, |
||||
|
aml.company_id as company_id |
||||
|
FROM |
||||
|
account_move_line aml |
||||
|
INNER JOIN |
||||
|
report_journal_ledger_move rjqm |
||||
|
on (rjqm.move_id = aml.move_id) |
||||
|
LEFT JOIN |
||||
|
account_account aa |
||||
|
on (aa.id = aml.account_id) |
||||
|
LEFT JOIN |
||||
|
res_partner p |
||||
|
on (p.id = aml.partner_id) |
||||
|
LEFT JOIN |
||||
|
account_tax at |
||||
|
on (at.id = aml.tax_line_id) |
||||
|
LEFT JOIN |
||||
|
res_currency currency |
||||
|
on (currency.id = aml.currency_id) |
||||
|
WHERE |
||||
|
rjqm.report_id = %s |
||||
|
""" |
||||
|
params = ( |
||||
|
self.env.uid, |
||||
|
self.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _inject_report_tax_values(self): |
||||
|
self.ensure_one() |
||||
|
sql_distinct_tax_id = """ |
||||
|
SELECT |
||||
|
distinct(jrqjtl.tax_id) |
||||
|
FROM |
||||
|
report_journal_ledger_journal_tax_line jrqjtl |
||||
|
WHERE |
||||
|
jrqjtl.report_id = %s |
||||
|
""" |
||||
|
self.env.cr.execute(sql_distinct_tax_id, (self.id,)) |
||||
|
rows = self.env.cr.fetchall() |
||||
|
tax_ids = set([row[0] for row in rows]) |
||||
|
|
||||
|
sql = """ |
||||
|
INSERT INTO report_journal_ledger_report_tax_line ( |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
report_id, |
||||
|
tax_id, |
||||
|
tax_name, |
||||
|
tax_code, |
||||
|
base_debit, |
||||
|
base_credit, |
||||
|
tax_debit, |
||||
|
tax_credit |
||||
|
) |
||||
|
SELECT |
||||
|
%s as create_uid, |
||||
|
NOW() as create_date, |
||||
|
%s as report_id, |
||||
|
%s as tax_id, |
||||
|
at.name as tax_name, |
||||
|
at.description as tax_code, |
||||
|
( |
||||
|
SELECT sum(base_debit) |
||||
|
FROM report_journal_ledger_journal_tax_line jrqjtl2 |
||||
|
WHERE jrqjtl2.report_id = %s |
||||
|
AND jrqjtl2.tax_id = %s |
||||
|
) as base_debit, |
||||
|
( |
||||
|
SELECT sum(base_credit) |
||||
|
FROM report_journal_ledger_journal_tax_line jrqjtl2 |
||||
|
WHERE jrqjtl2.report_id = %s |
||||
|
AND jrqjtl2.tax_id = %s |
||||
|
) as base_credit, |
||||
|
( |
||||
|
SELECT sum(tax_debit) |
||||
|
FROM report_journal_ledger_journal_tax_line jrqjtl2 |
||||
|
WHERE jrqjtl2.report_id = %s |
||||
|
AND jrqjtl2.tax_id = %s |
||||
|
) as tax_debit, |
||||
|
( |
||||
|
SELECT sum(tax_credit) |
||||
|
FROM report_journal_ledger_journal_tax_line jrqjtl2 |
||||
|
WHERE jrqjtl2.report_id = %s |
||||
|
AND jrqjtl2.tax_id = %s |
||||
|
) as tax_credit |
||||
|
FROM |
||||
|
report_journal_ledger_journal_tax_line jrqjtl |
||||
|
LEFT JOIN |
||||
|
account_tax at |
||||
|
on (at.id = jrqjtl.tax_id) |
||||
|
WHERE |
||||
|
jrqjtl.report_id = %s |
||||
|
AND |
||||
|
jrqjtl.tax_id = %s |
||||
|
""" |
||||
|
|
||||
|
for tax_id in tax_ids: |
||||
|
params = ( |
||||
|
self.env.uid, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
self.id, |
||||
|
tax_id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _inject_journal_tax_values(self): |
||||
|
self.ensure_one() |
||||
|
sql = """ |
||||
|
DELETE |
||||
|
FROM report_journal_ledger_journal_tax_line |
||||
|
WHERE report_id = %s |
||||
|
""" |
||||
|
params = ( |
||||
|
self.id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
sql_distinct_tax_id = """ |
||||
|
SELECT |
||||
|
distinct(jrqml.tax_id) |
||||
|
FROM |
||||
|
report_journal_ledger_move_line jrqml |
||||
|
WHERE |
||||
|
jrqml.report_journal_ledger_id = %s |
||||
|
""" |
||||
|
|
||||
|
tax_ids_by_journal_id = {} |
||||
|
for report_journal in self.report_journal_ledger_ids: |
||||
|
if report_journal.id not in tax_ids_by_journal_id: |
||||
|
tax_ids_by_journal_id[report_journal.id] = [] |
||||
|
self.env.cr.execute(sql_distinct_tax_id, (report_journal.id,)) |
||||
|
rows = self.env.cr.fetchall() |
||||
|
tax_ids_by_journal_id[report_journal.id].extend([ |
||||
|
row[0] for row in rows if row[0] |
||||
|
]) |
||||
|
|
||||
|
sql = """ |
||||
|
INSERT INTO report_journal_ledger_journal_tax_line ( |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
report_id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
tax_name, |
||||
|
tax_code, |
||||
|
base_debit, |
||||
|
base_credit, |
||||
|
tax_debit, |
||||
|
tax_credit |
||||
|
) |
||||
|
SELECT |
||||
|
%s as create_uid, |
||||
|
NOW() as create_date, |
||||
|
%s as report_id, |
||||
|
%s as report_journal_ledger_id, |
||||
|
%s as tax_id, |
||||
|
at.name as tax_name, |
||||
|
at.description as tax_code, |
||||
|
( |
||||
|
SELECT sum(debit) |
||||
|
FROM report_journal_ledger_move_line jrqml2 |
||||
|
WHERE jrqml2.report_journal_ledger_id = %s |
||||
|
AND ( |
||||
|
SELECT |
||||
|
count(*) |
||||
|
FROM |
||||
|
account_move_line_account_tax_rel aml_at_rel |
||||
|
WHERE |
||||
|
aml_at_rel.account_move_line_id = |
||||
|
jrqml2.move_line_id |
||||
|
AND |
||||
|
aml_at_rel.account_tax_id = %s |
||||
|
) > 0 |
||||
|
) as base_debit, |
||||
|
( |
||||
|
SELECT sum(credit) |
||||
|
FROM report_journal_ledger_move_line jrqml2 |
||||
|
WHERE jrqml2.report_journal_ledger_id = %s |
||||
|
AND ( |
||||
|
SELECT |
||||
|
count(*) |
||||
|
FROM |
||||
|
account_move_line_account_tax_rel aml_at_rel |
||||
|
WHERE |
||||
|
aml_at_rel.account_move_line_id = |
||||
|
jrqml2.move_line_id |
||||
|
AND |
||||
|
aml_at_rel.account_tax_id = %s |
||||
|
) > 0 |
||||
|
) as base_credit, |
||||
|
( |
||||
|
SELECT sum(debit) |
||||
|
FROM report_journal_ledger_move_line jrqml2 |
||||
|
WHERE jrqml2.report_journal_ledger_id = %s |
||||
|
AND jrqml2.tax_id = %s |
||||
|
) as tax_debit, |
||||
|
( |
||||
|
SELECT sum(credit) |
||||
|
FROM report_journal_ledger_move_line jrqml2 |
||||
|
WHERE jrqml2.report_journal_ledger_id = %s |
||||
|
AND jrqml2.tax_id = %s |
||||
|
) as tax_credit |
||||
|
FROM |
||||
|
report_journal_ledger_journal rjqj |
||||
|
LEFT JOIN |
||||
|
account_tax at |
||||
|
on (at.id = %s) |
||||
|
WHERE |
||||
|
rjqj.id = %s |
||||
|
""" |
||||
|
|
||||
|
for report_journal_ledger_id in tax_ids_by_journal_id: |
||||
|
tax_ids = tax_ids_by_journal_id[report_journal_ledger_id] |
||||
|
for tax_id in tax_ids: |
||||
|
params = ( |
||||
|
self.env.uid, |
||||
|
self.id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
report_journal_ledger_id, |
||||
|
tax_id, |
||||
|
tax_id, |
||||
|
report_journal_ledger_id, |
||||
|
) |
||||
|
self.env.cr.execute(sql, params) |
||||
|
|
||||
|
@api.multi |
||||
|
def _update_journal_report_total_values(self): |
||||
|
self.ensure_one() |
||||
|
sql = """ |
||||
|
UPDATE |
||||
|
report_journal_ledger_journal rjqj |
||||
|
SET |
||||
|
debit = ( |
||||
|
SELECT sum(rjqml.debit) |
||||
|
FROM report_journal_ledger_move_line rjqml |
||||
|
WHERE rjqml.report_journal_ledger_id = rjqj.id |
||||
|
), |
||||
|
credit = ( |
||||
|
SELECT sum(rjqml.credit) |
||||
|
FROM report_journal_ledger_move_line rjqml |
||||
|
WHERE rjqml.report_journal_ledger_id = rjqj.id |
||||
|
) |
||||
|
WHERE |
||||
|
rjqj.report_id = %s |
||||
|
""" |
||||
|
self.env.cr.execute(sql, (self.id,)) |
||||
|
|
||||
|
@api.multi |
||||
|
def print_report(self, report_type): |
||||
|
self.ensure_one() |
||||
|
if report_type == 'xlsx': |
||||
|
report_name = 'a_f_r.report_journal_ledger_xlsx' |
||||
|
else: |
||||
|
report_name = 'account_financial_report.' \ |
||||
|
'report_journal_ledger_qweb' |
||||
|
return self.env['ir.actions.report'].search( |
||||
|
[('report_name', '=', report_name), |
||||
|
('report_type', '=', report_type)], limit=1).report_action(self) |
||||
|
|
||||
|
def _get_html(self): |
||||
|
result = {} |
||||
|
rcontext = {} |
||||
|
context = dict(self.env.context) |
||||
|
report = self.browse(context.get('active_id')) |
||||
|
if report: |
||||
|
rcontext['o'] = report |
||||
|
result['html'] = self.env.ref( |
||||
|
'account_financial_report.report_journal_ledger').render( |
||||
|
rcontext) |
||||
|
return result |
||||
|
|
||||
|
@api.model |
||||
|
def get_html(self, given_context=None): |
||||
|
return self._get_html() |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedgerJournal(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger_journal' |
||||
|
|
||||
|
name = fields.Char( |
||||
|
required=True, |
||||
|
) |
||||
|
code = fields.Char() |
||||
|
report_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
journal_id = fields.Many2one( |
||||
|
comodel_name='account.journal', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
report_move_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_move', |
||||
|
inverse_name='report_journal_ledger_id', |
||||
|
) |
||||
|
report_tax_line_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_journal_tax_line', |
||||
|
inverse_name='report_journal_ledger_id', |
||||
|
) |
||||
|
debit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
credit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
company_id = fields.Many2one( |
||||
|
comodel_name='res.company', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
currency_id = fields.Many2one( |
||||
|
comodel_name='res.currency', |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedgerMove(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger_move' |
||||
|
|
||||
|
report_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
report_journal_ledger_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger_journal', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
move_id = fields.Many2one( |
||||
|
comodel_name='account.move', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
report_move_line_ids = fields.One2many( |
||||
|
comodel_name='report_journal_ledger_move_line', |
||||
|
inverse_name='report_move_id', |
||||
|
) |
||||
|
name = fields.Char() |
||||
|
company_id = fields.Many2one( |
||||
|
comodel_name='res.company', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedgerMoveLine(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger_move_line' |
||||
|
_order = 'partner_id desc, account_id desc' |
||||
|
|
||||
|
report_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
report_journal_ledger_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger_journal', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
report_move_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger_move', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
move_line_id = fields.Many2one( |
||||
|
comodel_name='account.move.line', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
account_id = fields.Many2one( |
||||
|
comodel_name='account.account' |
||||
|
) |
||||
|
account = fields.Char() |
||||
|
account_code = fields.Char() |
||||
|
account_type = fields.Char() |
||||
|
partner = fields.Char() |
||||
|
partner_id = fields.Many2one( |
||||
|
comodel_name='res.partner', |
||||
|
) |
||||
|
date = fields.Date() |
||||
|
entry = fields.Char() |
||||
|
label = fields.Char() |
||||
|
debit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
credit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
company_currency_id = fields.Many2one( |
||||
|
comodel_name='res.currency', |
||||
|
) |
||||
|
amount_currency = fields.Monetary( |
||||
|
currency_field='currency_id', |
||||
|
) |
||||
|
currency_id = fields.Many2one( |
||||
|
comodel_name='res.currency', |
||||
|
) |
||||
|
currency_name = fields.Char() |
||||
|
taxes_description = fields.Char() |
||||
|
tax_id = fields.Many2one( |
||||
|
comodel_name='account.tax' |
||||
|
) |
||||
|
company_id = fields.Many2one( |
||||
|
comodel_name='res.company', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedgerReportTaxLine(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger_report_tax_line' |
||||
|
_order = 'tax_code' |
||||
|
|
||||
|
report_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger', |
||||
|
required=True, |
||||
|
ondelete='cascade' |
||||
|
) |
||||
|
tax_id = fields.Many2one( |
||||
|
comodel_name='account.tax' |
||||
|
) |
||||
|
tax_name = fields.Char() |
||||
|
tax_code = fields.Char() |
||||
|
base_debit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
base_credit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
base_balance = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
compute='_compute_base_balance', |
||||
|
) |
||||
|
tax_debit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
tax_credit = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
) |
||||
|
tax_balance = fields.Float( |
||||
|
digits=DIGITS, |
||||
|
compute='_compute_tax_balance' |
||||
|
) |
||||
|
|
||||
|
@api.multi |
||||
|
def _compute_base_balance(self): |
||||
|
for rec in self: |
||||
|
rec.base_balance = rec.base_debit - rec.base_credit |
||||
|
|
||||
|
@api.multi |
||||
|
def _compute_tax_balance(self): |
||||
|
for rec in self: |
||||
|
rec.tax_balance = rec.tax_debit - rec.tax_credit |
||||
|
|
||||
|
|
||||
|
class ReportJournalLedgerJournalTaxLine(models.TransientModel): |
||||
|
|
||||
|
_name = 'report_journal_ledger_journal_tax_line' |
||||
|
_inherit = 'report_journal_ledger_report_tax_line' |
||||
|
_order = 'tax_code' |
||||
|
|
||||
|
report_journal_ledger_id = fields.Many2one( |
||||
|
comodel_name='report_journal_ledger_journal', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
@ -0,0 +1,249 @@ |
|||||
|
# Author: Damien Crier |
||||
|
# Author: Julien Coux |
||||
|
# Copyright 2016 Camptocamp SA |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from odoo import _, models |
||||
|
|
||||
|
|
||||
|
class JournalLedgerXslx(models.AbstractModel): |
||||
|
_name = 'report.a_f_r.report_journal_ledger_xlsx' |
||||
|
_inherit = 'report.account_financial_report.abstract_report_xlsx' |
||||
|
|
||||
|
def _get_report_name(self): |
||||
|
return _('Journal Ledger') |
||||
|
|
||||
|
def _get_report_columns(self, report): |
||||
|
columns = [ |
||||
|
{ |
||||
|
'header': _('Entry'), |
||||
|
'field': 'entry', |
||||
|
'width': 18 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Date'), |
||||
|
'field': 'date', |
||||
|
'width': 11 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Account'), |
||||
|
'field': 'account_code', |
||||
|
'width': 9 |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
if report.with_account_name: |
||||
|
columns.append({ |
||||
|
'header': _('Account Name'), |
||||
|
'field': 'account', |
||||
|
'width': 15 |
||||
|
}) |
||||
|
|
||||
|
columns += [ |
||||
|
{ |
||||
|
'header': _('Partner'), |
||||
|
'field': 'partner', |
||||
|
'width': 25 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Ref - Label'), |
||||
|
'field': 'label', |
||||
|
'width': 40 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Taxes'), |
||||
|
'field': 'taxes_description', |
||||
|
'width': 11 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Debit'), |
||||
|
'field': 'debit', |
||||
|
'type': 'amount', |
||||
|
'width': 14, |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Credit'), |
||||
|
'field': 'credit', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
} |
||||
|
] |
||||
|
|
||||
|
if report.foreign_currency: |
||||
|
columns += [ |
||||
|
{ |
||||
|
'header': _('Currency'), |
||||
|
'field': 'currency_id', |
||||
|
'type': 'many2one', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
{ |
||||
|
'header': _('Amount Currency'), |
||||
|
'field': 'amount_currency', |
||||
|
'type': 'amount', |
||||
|
'width': 18 |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
columns_as_dict = {} |
||||
|
for i, column in enumerate(columns): |
||||
|
columns_as_dict[i] = column |
||||
|
return columns_as_dict |
||||
|
|
||||
|
def _get_journal_tax_columns(self, report): |
||||
|
return { |
||||
|
0: { |
||||
|
'header': _('Name'), |
||||
|
'field': 'tax_name', |
||||
|
'width': 35 |
||||
|
}, |
||||
|
1: { |
||||
|
'header': _('Description'), |
||||
|
'field': 'tax_code', |
||||
|
'width': 18 |
||||
|
}, |
||||
|
2: { |
||||
|
'header': _('Base Debit'), |
||||
|
'field': 'base_debit', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
3: { |
||||
|
'header': _('Base Credit'), |
||||
|
'field': 'base_credit', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
4: { |
||||
|
'header': _('Base Balance'), |
||||
|
'field': 'base_balance', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
5: { |
||||
|
'header': _('Tax Debit'), |
||||
|
'field': 'tax_debit', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
6: { |
||||
|
'header': _('Tax Credit'), |
||||
|
'field': 'tax_credit', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
7: { |
||||
|
'header': _('Tax Balance'), |
||||
|
'field': 'tax_balance', |
||||
|
'type': 'amount', |
||||
|
'width': 14 |
||||
|
}, |
||||
|
} |
||||
|
|
||||
|
def _get_col_count_filter_name(self): |
||||
|
return 2 |
||||
|
|
||||
|
def _get_col_count_filter_value(self): |
||||
|
return 3 |
||||
|
|
||||
|
def _get_report_filters(self, report): |
||||
|
target_label_by_value = { |
||||
|
value: label |
||||
|
for value, label in |
||||
|
self.env['journal.ledger.report.wizard']._get_move_targets() |
||||
|
} |
||||
|
|
||||
|
sort_option_label_by_value = { |
||||
|
value: label |
||||
|
for value, label in |
||||
|
self.env['journal.ledger.report.wizard']._get_sort_options() |
||||
|
} |
||||
|
|
||||
|
return [ |
||||
|
[ |
||||
|
_('Company'), |
||||
|
report.company_id.name |
||||
|
], |
||||
|
[ |
||||
|
_('Date range filter'), |
||||
|
_('From: %s To: %s') % (report.date_from, report.date_to) |
||||
|
], |
||||
|
[ |
||||
|
_('Target moves filter'), |
||||
|
_("%s") % target_label_by_value[report.move_target], |
||||
|
], |
||||
|
[ |
||||
|
_('Entries sorted by'), |
||||
|
_("%s") % sort_option_label_by_value[report.sort_option], |
||||
|
], |
||||
|
[ |
||||
|
_('Journals'), |
||||
|
', '.join([ |
||||
|
"%s - %s" % (report_journal.code, report_journal.name) |
||||
|
for report_journal in report.report_journal_ledger_ids |
||||
|
]) |
||||
|
|
||||
|
] |
||||
|
] |
||||
|
|
||||
|
def _generate_report_content(self, workbook, report): |
||||
|
group_option = report.group_option |
||||
|
if group_option == 'journal': |
||||
|
for report_journal in report.report_journal_ledger_ids: |
||||
|
self._generate_journal_content(workbook, report_journal) |
||||
|
elif group_option == 'none': |
||||
|
self._generate_no_group_content(workbook, report) |
||||
|
|
||||
|
def _generate_no_group_content(self, workbook, report): |
||||
|
self._generate_moves_content( |
||||
|
workbook, report, "Report", report.report_move_ids) |
||||
|
self._generate_no_group_taxes_summary(workbook, report) |
||||
|
|
||||
|
def _generate_journal_content(self, workbook, report_journal): |
||||
|
sheet_name = "%s (%s) - %s" % ( |
||||
|
report_journal.code, |
||||
|
report_journal.currency_id.name, |
||||
|
report_journal.name, |
||||
|
) |
||||
|
self._generate_moves_content( |
||||
|
workbook, report_journal.report_id, sheet_name, |
||||
|
report_journal.report_move_ids) |
||||
|
self._generate_journal_taxes_summary(workbook, report_journal) |
||||
|
|
||||
|
def _generate_no_group_taxes_summary(self, workbook, report): |
||||
|
self._generate_taxes_summary( |
||||
|
workbook, report, "Tax Report", report.report_tax_line_ids) |
||||
|
|
||||
|
def _generate_journal_taxes_summary(self, workbook, report_journal): |
||||
|
sheet_name = "Tax - %s (%s) - %s" % ( |
||||
|
report_journal.code, |
||||
|
report_journal.currency_id.name, |
||||
|
report_journal.name, |
||||
|
) |
||||
|
report = report_journal.report_id |
||||
|
self._generate_taxes_summary( |
||||
|
workbook, report, sheet_name, report_journal.report_tax_line_ids) |
||||
|
|
||||
|
def _generate_moves_content(self, workbook, report, sheet_name, moves): |
||||
|
self.workbook = workbook |
||||
|
self.sheet = workbook.add_worksheet(sheet_name) |
||||
|
self._set_column_width() |
||||
|
|
||||
|
self.row_pos = 1 |
||||
|
|
||||
|
self.write_array_title(sheet_name) |
||||
|
self.row_pos += 2 |
||||
|
|
||||
|
self.write_array_header() |
||||
|
for move in moves: |
||||
|
for line in move.report_move_line_ids: |
||||
|
self.write_line(line) |
||||
|
self.row_pos += 1 |
||||
|
|
||||
|
def _generate_taxes_summary(self, workbook, report, sheet_name, tax_lines): |
||||
|
self.workbook = workbook |
||||
|
self.sheet = workbook.add_worksheet(sheet_name) |
||||
|
|
||||
|
self.row_pos = 1 |
||||
|
self.write_array_title(sheet_name) |
||||
|
self.row_pos += 2 |
@ -0,0 +1,463 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<template id="report_journal_ledger_qweb"> |
||||
|
<t t-call="web.html_container"> |
||||
|
<t t-foreach="docs" t-as="o"> |
||||
|
<t t-call="account_financial_report.internal_layout"> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_base"/> |
||||
|
</t> |
||||
|
</t> |
||||
|
</t> |
||||
|
</template> |
||||
|
|
||||
|
<template id="report_journal_ledger_base"> |
||||
|
<t t-set="title">Journal Ledger</t> |
||||
|
<t t-set="company_name" t-value="o.company_id.name"/> |
||||
|
<t t-set="display_currency" t-value="o.foreign_currency"/> |
||||
|
<t t-set="display_account_name" t-value="o.with_account_name"/> |
||||
|
|
||||
|
<div class="page"> |
||||
|
<t t-if="o.group_option == 'none'"> |
||||
|
<div class="page_break"> |
||||
|
<t t-call="account_financial_report.report_journal_all"/> |
||||
|
<br/> |
||||
|
<t t-call="account_financial_report.report_journal_all_taxes"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
<t t-if="o.group_option == 'journal'"> |
||||
|
<t t-foreach="o.report_journal_ledger_ids" t-as="journal"> |
||||
|
<div class="page_break"> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_journal"/> |
||||
|
<br/> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_journal_taxes"/> |
||||
|
<br/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</t> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_all"> |
||||
|
<div class="act_as_table list_table" style="margin-top: 10px;"/> |
||||
|
<div class="act_as_table data_table" style="width: 100%;"> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_journal_table_header"/> |
||||
|
<t t-foreach="o.report_move_ids" t-as="move"> |
||||
|
<t t-call="account_financial_report.report_journal_move"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_ledger_journal"> |
||||
|
<div class="act_as_table list_table" style="margin-top: 10px;"/> |
||||
|
<div class="act_as_caption account_title" style="width: 100%;"> |
||||
|
<span t-field="journal.name"/> (<span t-field="journal.currency_id.display_name"/>) - <span t-field="o.date_from"/> to <span t-field="o.date_to"/> - <span t-field="o.move_target"/> Moves |
||||
|
</div> |
||||
|
|
||||
|
<div class="act_as_table data_table" style="width: 100%;"> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_journal_table_header"/> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_journal_first_line"/> |
||||
|
<t t-foreach="journal.report_move_ids" t-as="move"> |
||||
|
<t t-call="account_financial_report.report_journal_move"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_ledger_journal_table_header"> |
||||
|
<t t-if="not display_account_name"> |
||||
|
<t t-set="account_column_style"> |
||||
|
width: 8.11%; |
||||
|
</t> |
||||
|
<t t-set="label_column_style"> |
||||
|
width: 38.92%; |
||||
|
</t> |
||||
|
</t> |
||||
|
<t t-else=""> |
||||
|
<t t-set="account_column_style"> |
||||
|
width: 23.78%; |
||||
|
</t> |
||||
|
<t t-set="label_column_style"> |
||||
|
width: 23.24%; |
||||
|
</t> |
||||
|
</t> |
||||
|
|
||||
|
<div class="act_as_thead"> |
||||
|
<div class="act_as_row labels"> |
||||
|
<div class="act_as_cell first_column" |
||||
|
name="entry" |
||||
|
style="width: 7.57%;"> |
||||
|
Entry |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="date" |
||||
|
style="width: 5.41%;"> |
||||
|
Date |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="account" t-att-style="account_column_style"> |
||||
|
Account |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="partner" |
||||
|
style="width: 15.14%;"> |
||||
|
Partner |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="label" t-att-style="label_column_style"> |
||||
|
Ref - Label |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="taxes" |
||||
|
style="width: 7.57%;"> |
||||
|
Taxes |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="debit" |
||||
|
style="width: 8.65%;"> |
||||
|
Debit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="credit" |
||||
|
style="width: 8.65%;"> |
||||
|
Credit |
||||
|
</div> |
||||
|
<t t-if="display_currency"> |
||||
|
<div class="act_as_cell" |
||||
|
name="currency_name" |
||||
|
style="width: 2.16%;"> |
||||
|
Cur. |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="amount_currency" |
||||
|
style="width: 6.49%;"> |
||||
|
Amount Cur. |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_ledger_journal_first_line"> |
||||
|
<div class="act_as_row lines"> |
||||
|
<div class="act_as_cell" |
||||
|
name="entry"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="date"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="account"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="partner"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="label"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="taxes"/> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="debit"> |
||||
|
<b><span t-field="journal.debit"/></b> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="credit"> |
||||
|
<b><span t-field="journal.credit"/></b> |
||||
|
</div> |
||||
|
<t t-if="display_currency"> |
||||
|
<div class="act_as_cell" |
||||
|
name="currency_name"> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="amount_currency"> |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
<div style="width: 100%"/> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_move"> |
||||
|
<t t-set="display_move_info" t-value="True"/> |
||||
|
<t t-set="last_partner" t-eval="None"/> |
||||
|
<t t-set="display_partner" t-eval="True"/> |
||||
|
<t t-foreach="move.report_move_line_ids" t-as="move_line"> |
||||
|
<div class="act_as_row lines"> |
||||
|
<t t-set="current_partner" t-value="move_line.partner_id"/> |
||||
|
<t t-set="display_partner" t-value="current_partner != last_partner"/> |
||||
|
<t t-call="account_financial_report.report_journal_move_line"/> |
||||
|
<t t-set="last_partner" t-value="current_partner"/> |
||||
|
<t t-set="display_move_info" t-value="False"/> |
||||
|
</div> |
||||
|
</t> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_move_line"> |
||||
|
<div class="act_as_cell left" |
||||
|
name="entry"> |
||||
|
<span t-if="display_move_info" t-field="move_line.entry"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="date"> |
||||
|
<span t-if="display_move_info" t-field="move_line.date"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="account"> |
||||
|
<span t-field="move_line.account_code"/> |
||||
|
<span t-if="display_account_name"> |
||||
|
- <span t-field="move_line.account"/> |
||||
|
</span> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="partner"> |
||||
|
<span t-if="display_partner" t-field="move_line.partner"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="label"> |
||||
|
<span t-field="move_line.label"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="taxes"> |
||||
|
<span t-field="move_line.taxes_description"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="debit"> |
||||
|
<t t-if="move_line.debit"> |
||||
|
<span t-field="move_line.debit"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="credit"> |
||||
|
<t t-if="move_line.credit"> |
||||
|
<span t-field="move_line.credit"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
<t t-if="display_currency"> |
||||
|
<div class="act_as_cell" |
||||
|
name="currency_name"> |
||||
|
<t t-if="move_line.currency_name"> |
||||
|
<span t-field="move_line.currency_name"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="amount_currency"> |
||||
|
<t t-if="move_line.amount_currency"> |
||||
|
<span t-field="move_line.amount_currency"/> |
||||
|
</t> |
||||
|
</div> |
||||
|
</t> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_ledger_journal_taxes"> |
||||
|
<b>Taxes summary</b> |
||||
|
<div class="act_as_table data_table" style="width: 100%;"> |
||||
|
<div class="act_as_thead"> |
||||
|
<div class="act_as_row labels"> |
||||
|
<div class="act_as_cell first_column" |
||||
|
name="name" |
||||
|
style="width: 30.97%;"> |
||||
|
Name |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="description" |
||||
|
style="width: 13.27%;"> |
||||
|
Description |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_amount" |
||||
|
style="width: 27.88%;"> |
||||
|
Base Amount |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_amount" |
||||
|
style="width: 27.88%;"> |
||||
|
Tax Amount |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="act_as_table data_table" style="width: 100%;"> |
||||
|
<div class="act_as_row labels"> |
||||
|
<div class="act_as_cell first_column" |
||||
|
name="name" |
||||
|
style="width: 30.97%;"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="description" |
||||
|
style="width: 13.27%;"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_debit" |
||||
|
style="width: 9.29%;"> |
||||
|
Debit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_credit" |
||||
|
style="width: 9.29%;"> |
||||
|
Credit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_balance" |
||||
|
style="width: 9.29%;"> |
||||
|
Balance |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_debit" |
||||
|
style="width: 9.29%;"> |
||||
|
Debit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_credit" |
||||
|
style="width: 9.29%;"> |
||||
|
Credit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_balance" |
||||
|
style="width: 9.29%;"> |
||||
|
Balance |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<t t-foreach="journal.report_tax_line_ids" t-as="tax_line"> |
||||
|
<div class="act_as_row lines"> |
||||
|
<div class="act_as_cell left" |
||||
|
name="tax_name"> |
||||
|
<span t-field="tax_line.tax_name"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="tax_code"> |
||||
|
<span t-field="tax_line.tax_code"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_debit"> |
||||
|
<span t-field="tax_line.base_debit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_credit"> |
||||
|
<span t-field="tax_line.base_credit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_balance"> |
||||
|
<span t-field="tax_line.base_balance"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_debit"> |
||||
|
<span t-field="tax_line.tax_debit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_credit"> |
||||
|
<span t-field="tax_line.tax_credit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_balance"> |
||||
|
<span t-field="tax_line.tax_balance"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<template id="account_financial_report.report_journal_all_taxes"> |
||||
|
<b>Taxes summary</b> |
||||
|
<div class="act_as_table data_table" style="width: 100%;"> |
||||
|
<div class="act_as_thead"> |
||||
|
<div class="act_as_row labels"> |
||||
|
<div class="act_as_cell first_column" |
||||
|
name="name" |
||||
|
style="width: 30.97%;"> |
||||
|
Name |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="description" |
||||
|
style="width: 13.27%;"> |
||||
|
Description |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_amount" |
||||
|
style="width: 27.88%;"> |
||||
|
Base Amount |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_amount" |
||||
|
style="width: 27.88%;"> |
||||
|
Tax Amount |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="act_as_table data_table" style="width: 100%;">10 |
||||
|
<div class="act_as_row labels"> |
||||
|
<div class="act_as_cell first_column" |
||||
|
name="name" |
||||
|
style="width: 30.97%;"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="description" |
||||
|
style="width: 13.27%;"/> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_debit" |
||||
|
style="width: 9.29%;"> |
||||
|
Debit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_credit" |
||||
|
style="width: 9.29%;"> |
||||
|
Credit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="base_balance" |
||||
|
style="width: 9.29%;"> |
||||
|
Balance |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_debit" |
||||
|
style="width: 9.29%;"> |
||||
|
Debit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_credit" |
||||
|
style="width: 9.29%;"> |
||||
|
Credit |
||||
|
</div> |
||||
|
<div class="act_as_cell" |
||||
|
name="tax_balance" |
||||
|
style="width: 9.29%;"> |
||||
|
Balance |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<t t-foreach="o.report_tax_line_ids" t-as="tax_line"> |
||||
|
<div class="act_as_row lines"> |
||||
|
<div class="act_as_cell left" |
||||
|
name="tax_name"> |
||||
|
<span t-field="tax_line.tax_name"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell left" |
||||
|
name="tax_code"> |
||||
|
<span t-field="tax_line.tax_code"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_debit"> |
||||
|
<span t-field="tax_line.base_debit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_credit"> |
||||
|
<span t-field="tax_line.base_credit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="base_balance"> |
||||
|
<span t-field="tax_line.base_balance"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_debit"> |
||||
|
<span t-field="tax_line.tax_debit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_credit"> |
||||
|
<span t-field="tax_line.tax_credit"/> |
||||
|
</div> |
||||
|
<div class="act_as_cell amount" |
||||
|
name="tax_balance"> |
||||
|
<span t-field="tax_line.tax_balance"/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</t> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,78 @@ |
|||||
|
# Copyright 2018 Forest and Biomass Romania |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import logging |
||||
|
from . import abstract_test |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
class AbstractTestForeignCurrency(abstract_test.AbstractTest): |
||||
|
"""Common technical tests for all reports.""" |
||||
|
|
||||
|
def _chart_template_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._chart_template_create() |
||||
|
# Account for foreign payments |
||||
|
self.account_type_other = self.env['account.account.type'].create( |
||||
|
{'name': 'foreign expenses', |
||||
|
'type': 'other', |
||||
|
}) |
||||
|
act = self.env['account.account.template'].create({ |
||||
|
'code': '0012', |
||||
|
'name': 'Foreign Expenses', |
||||
|
'user_type_id': self.account_type_other.id, |
||||
|
'chart_template_id': self.chart.id, |
||||
|
'currency_id': self.env.ref('base.EUR').id, |
||||
|
}) |
||||
|
self.env['ir.model.data'].create({ |
||||
|
'res_id': act.id, |
||||
|
'model': act._name, |
||||
|
'name': 'foreign expenses', |
||||
|
}) |
||||
|
return True |
||||
|
|
||||
|
def _add_chart_of_accounts(self): |
||||
|
super(AbstractTestForeignCurrency, self)._add_chart_of_accounts() |
||||
|
self.foreign_expense = self.env['account.account'].search( |
||||
|
[('currency_id', '=', self.env.ref('base.EUR').id)], limit=1) |
||||
|
self.foreign_currency_id = self.foreign_expense.currency_id |
||||
|
return True |
||||
|
|
||||
|
def _journals_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._journals_create() |
||||
|
self.journal_foreign_purchases = self.env['account.journal'].create({ |
||||
|
'company_id': self.company.id, |
||||
|
'name': 'Test journal for purchase', |
||||
|
'type': 'purchase', |
||||
|
'code': 'TFORPUR', |
||||
|
'default_debit_account_id': self.foreign_expense.id, |
||||
|
'default_credit_account_id': self.foreign_expense.id, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
}) |
||||
|
return True |
||||
|
|
||||
|
def _invoice_create(self): |
||||
|
super(AbstractTestForeignCurrency, self)._invoice_create() |
||||
|
# vendor bill foreign currency |
||||
|
foreign_vendor_invoice_lines = [(0, False, { |
||||
|
'name': 'Test description #1', |
||||
|
'account_id': self.revenue.id, |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100.0, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
}), (0, False, { |
||||
|
'name': 'Test description #2', |
||||
|
'account_id': self.revenue.id, |
||||
|
'quantity': 2.0, |
||||
|
'price_unit': 25.0, |
||||
|
'currency_id': self.foreign_currency_id.id, |
||||
|
})] |
||||
|
self.foreign_invoice_in = self.env['account.invoice'].create({ |
||||
|
'partner_id': self.partner.id, |
||||
|
'type': 'in_invoice', |
||||
|
'invoice_line_ids': foreign_vendor_invoice_lines, |
||||
|
'account_id': self.partner.property_account_payable_id.id, |
||||
|
'journal_id': self.journal_foreign_purchases.id, |
||||
|
}) |
||||
|
self.foreign_invoice_in.action_invoice_open() |
||||
|
return True |
@ -0,0 +1,366 @@ |
|||||
|
# Copyright 2017 ACSONE SA/NV |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
import time |
||||
|
|
||||
|
from datetime import datetime |
||||
|
from dateutil.relativedelta import relativedelta |
||||
|
|
||||
|
from odoo.fields import Date |
||||
|
from odoo.tests.common import TransactionCase |
||||
|
|
||||
|
from . import abstract_test_foreign_currency as a_t_f_c |
||||
|
|
||||
|
|
||||
|
class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency): |
||||
|
""" |
||||
|
Technical tests for General Ledger Report. |
||||
|
""" |
||||
|
def _getReportModel(self): |
||||
|
return self.env['report_journal_ledger'] |
||||
|
|
||||
|
def _getQwebReportName(self): |
||||
|
return 'account_financial_report.report_journal_ledger_qweb' |
||||
|
|
||||
|
def _getXlsxReportName(self): |
||||
|
return 'a_f_r.report_journal_ledger_xlsx' |
||||
|
|
||||
|
def _getXlsxReportActionName(self): |
||||
|
return 'account_financial_report.' \ |
||||
|
'action_report_journal_ledger_xlsx' |
||||
|
|
||||
|
def _getReportTitle(self): |
||||
|
return 'Odoo' |
||||
|
|
||||
|
def _getBaseFilters(self): |
||||
|
return { |
||||
|
'date_from': time.strftime('%Y-01-01'), |
||||
|
'date_to': time.strftime('%Y-12-31'), |
||||
|
'company_id': self.company.id, |
||||
|
'journal_ids': [(6, 0, self.journal_sale.ids)] |
||||
|
} |
||||
|
|
||||
|
def _getAdditionalFiltersToBeTested(self): |
||||
|
return [ |
||||
|
{'move_target': "All", |
||||
|
'sort_option': "Date", |
||||
|
'group_option': "Journal", |
||||
|
'with_account_name': True, |
||||
|
'foreign_currency': True}, |
||||
|
] |
||||
|
|
||||
|
def test_02_generation_report_html(self): |
||||
|
"""Check if report HTML is correctly generated""" |
||||
|
|
||||
|
# Check if returned report action is correct |
||||
|
report_type = 'qweb-html' |
||||
|
report_action = self.report.print_report(report_type) |
||||
|
self.assertDictContainsSubset( |
||||
|
{ |
||||
|
'type': 'ir.actions.report', |
||||
|
'report_name': self.qweb_report_name, |
||||
|
'report_type': 'qweb-html', |
||||
|
}, |
||||
|
report_action |
||||
|
) |
||||
|
|
||||
|
# Check if report template is correct |
||||
|
report = self.env['ir.actions.report'].search( |
||||
|
[('report_name', '=', self.qweb_report_name), |
||||
|
('report_type', '=', report_type)], limit=1) |
||||
|
self.assertEqual(report.report_type, 'qweb-html') |
||||
|
|
||||
|
rep = report.render(self.report.ids, {}) |
||||
|
|
||||
|
self.assertTrue(self.report_title.encode('utf8') in rep[0]) |
||||
|
self.assertTrue( |
||||
|
self.report.journal_ids[0].name.encode('utf8') in rep[0] |
||||
|
) |
||||
|
|
||||
|
def test_04_compute_data(self): |
||||
|
return True |
||||
|
|
||||
|
|
||||
|
class TestJournalReport(TransactionCase): |
||||
|
|
||||
|
def setUp(self): |
||||
|
super(TestJournalReport, self).setUp() |
||||
|
self.AccountObj = self.env['account.account'] |
||||
|
self.InvoiceObj = self.env['account.invoice'] |
||||
|
self.JournalObj = self.env['account.journal'] |
||||
|
self.JournalReportObj = self.env['journal.ledger.report.wizard'] |
||||
|
self.MoveObj = self.env['account.move'] |
||||
|
self.ReportJournalLedger = self.env['report_journal_ledger'] |
||||
|
self.TaxObj = self.env['account.tax'] |
||||
|
|
||||
|
self.company = self.env.ref('base.main_company') |
||||
|
|
||||
|
today = datetime.today() |
||||
|
last_year = today - relativedelta(years=1) |
||||
|
|
||||
|
self.previous_fy_date_start = Date.to_string( |
||||
|
last_year.replace(month=1, day=1)) |
||||
|
self.previous_fy_date_end = Date.to_string( |
||||
|
last_year.replace(month=12, day=31)) |
||||
|
self.fy_date_start = Date.to_string( |
||||
|
today.replace(month=1, day=1)) |
||||
|
self.fy_date_end = Date.to_string( |
||||
|
today.replace(month=12, day=31)) |
||||
|
|
||||
|
self.receivable_account = self.AccountObj.search([ |
||||
|
('user_type_id.name', '=', 'Receivable') |
||||
|
], limit=1) |
||||
|
self.income_account = self.AccountObj.search([ |
||||
|
('user_type_id.name', '=', 'Income') |
||||
|
], limit=1) |
||||
|
self.payable_account = self.AccountObj.search([ |
||||
|
('user_type_id.name', '=', 'Payable') |
||||
|
], limit=1) |
||||
|
|
||||
|
self.journal_sale = self.JournalObj.create({ |
||||
|
'name': "Test journal sale", |
||||
|
'code': "TST-JRNL-S", |
||||
|
'type': 'sale', |
||||
|
'company_id': self.company.id, |
||||
|
}) |
||||
|
self.journal_purchase = self.JournalObj.create({ |
||||
|
'name': "Test journal purchase", |
||||
|
'code': "TST-JRNL-P", |
||||
|
'type': 'sale', |
||||
|
'company_id': self.company.id, |
||||
|
}) |
||||
|
|
||||
|
self.tax_15_s = self.TaxObj.create({ |
||||
|
'sequence': 30, |
||||
|
'name': 'Tax 15.0% (Percentage of Price)', |
||||
|
'amount': 15.0, |
||||
|
'amount_type': 'percent', |
||||
|
'include_base_amount': False, |
||||
|
'type_tax_use': 'sale', |
||||
|
}) |
||||
|
|
||||
|
self.tax_20_s = self.TaxObj.create({ |
||||
|
'sequence': 30, |
||||
|
'name': 'Tax 20.0% (Percentage of Price)', |
||||
|
'amount': 20.0, |
||||
|
'amount_type': 'percent', |
||||
|
'include_base_amount': False, |
||||
|
'type_tax_use': 'sale', |
||||
|
}) |
||||
|
|
||||
|
self.tax_15_p = self.TaxObj.create({ |
||||
|
'sequence': 30, |
||||
|
'name': 'Tax 15.0% (Percentage of Price)', |
||||
|
'amount': 15.0, |
||||
|
'amount_type': 'percent', |
||||
|
'include_base_amount': False, |
||||
|
'type_tax_use': 'purchase', |
||||
|
}) |
||||
|
|
||||
|
self.tax_20_p = self.TaxObj.create({ |
||||
|
'sequence': 30, |
||||
|
'name': 'Tax 20.0% (Percentage of Price)', |
||||
|
'amount': 20.0, |
||||
|
'amount_type': 'percent', |
||||
|
'include_base_amount': False, |
||||
|
'type_tax_use': 'purchase', |
||||
|
}) |
||||
|
|
||||
|
self.partner_2 = self.env.ref('base.res_partner_2') |
||||
|
|
||||
|
def _add_move( |
||||
|
self, date, journal, |
||||
|
receivable_debit, receivable_credit, income_debit, income_credit): |
||||
|
move_name = 'move name' |
||||
|
move_vals = { |
||||
|
'journal_id': journal.id, |
||||
|
'date': date, |
||||
|
'line_ids': [ |
||||
|
(0, 0, { |
||||
|
'name': move_name, |
||||
|
'debit': receivable_debit, |
||||
|
'credit': receivable_credit, |
||||
|
'account_id': self.receivable_account.id |
||||
|
}), |
||||
|
(0, 0, { |
||||
|
'name': move_name, |
||||
|
'debit': income_debit, |
||||
|
'credit': income_credit, |
||||
|
'account_id': self.income_account.id |
||||
|
}), |
||||
|
] |
||||
|
} |
||||
|
return self.MoveObj.create(move_vals) |
||||
|
|
||||
|
def check_report_journal_debit_credit( |
||||
|
self, report, expected_debit, expected_credit): |
||||
|
self.assertEqual( |
||||
|
expected_debit, |
||||
|
sum([journal.debit for journal in |
||||
|
report.report_journal_ledger_ids]) |
||||
|
) |
||||
|
|
||||
|
self.assertEqual( |
||||
|
expected_credit, |
||||
|
sum([journal.credit for journal in |
||||
|
report.report_journal_ledger_ids]) |
||||
|
) |
||||
|
|
||||
|
def check_report_journal_debit_credit_taxes( |
||||
|
self, report, |
||||
|
expected_base_debit, expected_base_credit, |
||||
|
expected_tax_debit, expected_tax_credit): |
||||
|
|
||||
|
self.assertEqual( |
||||
|
expected_base_debit, |
||||
|
sum([ |
||||
|
journal.base_debit |
||||
|
for journal in report.report_journal_ledger_tax_line_ids |
||||
|
]) |
||||
|
) |
||||
|
self.assertEqual( |
||||
|
expected_base_credit, |
||||
|
sum([ |
||||
|
journal.base_credit |
||||
|
for journal in report.report_journal_ledger_tax_line_ids |
||||
|
]) |
||||
|
) |
||||
|
self.assertEqual( |
||||
|
expected_tax_debit, |
||||
|
sum([ |
||||
|
journal.tax_debit |
||||
|
for journal in report.report_journal_ledger_tax_line_ids |
||||
|
]) |
||||
|
) |
||||
|
self.assertEqual( |
||||
|
expected_tax_credit, |
||||
|
sum([ |
||||
|
journal.tax_credit |
||||
|
for journal in report.report_journal_ledger_tax_line_ids |
||||
|
]) |
||||
|
) |
||||
|
|
||||
|
def test_01_test_total(self): |
||||
|
today_date = Date.today() |
||||
|
last_year_date = Date.to_string( |
||||
|
datetime.today() - relativedelta(years=1)) |
||||
|
|
||||
|
move1 = self._add_move( |
||||
|
today_date, self.journal_sale, |
||||
|
0, 100, 100, 0) |
||||
|
move2 = self._add_move( |
||||
|
last_year_date, self.journal_sale, |
||||
|
0, 100, 100, 0) |
||||
|
|
||||
|
report = self.ReportJournalLedger.create({ |
||||
|
'date_from': self.fy_date_start, |
||||
|
'date_to': self.fy_date_end, |
||||
|
'company_id': self.company.id, |
||||
|
'journal_ids': [(6, 0, self.journal_sale.ids)] |
||||
|
}) |
||||
|
report.compute_data_for_report() |
||||
|
|
||||
|
self.check_report_journal_debit_credit(report, 100, 100) |
||||
|
|
||||
|
move3 = self._add_move( |
||||
|
today_date, self.journal_sale, |
||||
|
0, 100, 100, 0) |
||||
|
|
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 200, 200) |
||||
|
|
||||
|
report.move_target = 'posted' |
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 0, 0) |
||||
|
|
||||
|
move1.post() |
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 100, 100) |
||||
|
|
||||
|
move2.post() |
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 100, 100) |
||||
|
|
||||
|
move3.post() |
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 200, 200) |
||||
|
|
||||
|
report.date_from = self.previous_fy_date_start |
||||
|
report.compute_data_for_report() |
||||
|
self.check_report_journal_debit_credit(report, 300, 300) |
||||
|
|
||||
|
def test_02_test_taxes_out_invoice(self): |
||||
|
invoice_values = { |
||||
|
'journal_id': self.journal_sale.id, |
||||
|
'partner_id': self.partner_2.id, |
||||
|
'type': 'out_invoice', |
||||
|
'invoice_line_ids': [ |
||||
|
(0, 0, { |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100, |
||||
|
'account_id': self.receivable_account.id, |
||||
|
'name': "Test", |
||||
|
'invoice_line_tax_ids': [(6, 0, [self.tax_15_s.id])], |
||||
|
}), |
||||
|
(0, 0, { |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100, |
||||
|
'account_id': self.receivable_account.id, |
||||
|
'name': "Test", |
||||
|
'invoice_line_tax_ids': [(6, 0, [ |
||||
|
self.tax_15_s.id, self.tax_20_s.id |
||||
|
])], |
||||
|
}) |
||||
|
] |
||||
|
} |
||||
|
invoice = self.InvoiceObj.create(invoice_values) |
||||
|
invoice.action_invoice_open() |
||||
|
|
||||
|
report = self.ReportJournalLedger.create({ |
||||
|
'date_from': self.fy_date_start, |
||||
|
'date_to': self.fy_date_end, |
||||
|
'company_id': self.company.id, |
||||
|
'journal_ids': [(6, 0, self.journal_sale.ids)] |
||||
|
}) |
||||
|
report.compute_data_for_report() |
||||
|
|
||||
|
self.check_report_journal_debit_credit(report, 250, 250) |
||||
|
self.check_report_journal_debit_credit_taxes(report, 0, 300, 0, 50) |
||||
|
|
||||
|
def test_03_test_taxes_in_invoice(self): |
||||
|
invoice_values = { |
||||
|
'journal_id': self.journal_sale.id, |
||||
|
'partner_id': self.partner_2.id, |
||||
|
'type': 'in_invoice', |
||||
|
'invoice_line_ids': [ |
||||
|
(0, 0, { |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100, |
||||
|
'account_id': self.payable_account.id, |
||||
|
'name': "Test", |
||||
|
'invoice_line_tax_ids': [(6, 0, [self.tax_15_p.id])], |
||||
|
}), |
||||
|
(0, 0, { |
||||
|
'quantity': 1.0, |
||||
|
'price_unit': 100, |
||||
|
'account_id': self.payable_account.id, |
||||
|
'name': "Test", |
||||
|
'invoice_line_tax_ids': [(6, 0, [ |
||||
|
self.tax_15_p.id, self.tax_20_p.id |
||||
|
])], |
||||
|
}) |
||||
|
] |
||||
|
} |
||||
|
invoice = self.InvoiceObj.create(invoice_values) |
||||
|
invoice.action_invoice_open() |
||||
|
|
||||
|
report = self.ReportJournalLedger.create({ |
||||
|
'date_from': self.fy_date_start, |
||||
|
'date_to': self.fy_date_end, |
||||
|
'company_id': self.company.id, |
||||
|
'journal_ids': [(6, 0, self.journal_sale.ids)] |
||||
|
}) |
||||
|
report.compute_data_for_report() |
||||
|
|
||||
|
self.check_report_journal_debit_credit(report, 250, 250) |
||||
|
self.check_report_journal_debit_credit_taxes(report, 300, 0, 50, 0) |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<template id="report_journal_ledger"> |
||||
|
<div class="o_account_financial_reports_page"> |
||||
|
<t t-call="account_financial_report.report_buttons"/> |
||||
|
<t t-call="account_financial_report.report_journal_ledger_base"/> |
||||
|
</div> |
||||
|
</template> |
||||
|
</odoo> |
@ -1,5 +1,6 @@ |
|||||
from . import aged_partner_balance_wizard |
from . import aged_partner_balance_wizard |
||||
from . import general_ledger_wizard |
from . import general_ledger_wizard |
||||
|
from . import journal_ledger_wizard |
||||
from . import open_items_wizard |
from . import open_items_wizard |
||||
from . import trial_balance_wizard |
from . import trial_balance_wizard |
||||
from . import vat_report_wizard |
from . import vat_report_wizard |
@ -0,0 +1,142 @@ |
|||||
|
# Copyright 2017 ACSONE SA/NV |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
from odoo import api, fields, models, _ |
||||
|
from odoo.tools.safe_eval import safe_eval |
||||
|
from odoo.tools import pycompat |
||||
|
|
||||
|
|
||||
|
class JournalLedgerReportWizard(models.TransientModel): |
||||
|
"""Journal Ledger report wizard.""" |
||||
|
|
||||
|
_name = 'journal.ledger.report.wizard' |
||||
|
_description = "Journal Ledger Report Wizard" |
||||
|
|
||||
|
company_id = fields.Many2one( |
||||
|
comodel_name='res.company', |
||||
|
default=lambda self: self.env.user.company_id, |
||||
|
string='Company', |
||||
|
required=True, |
||||
|
ondelete='cascade', |
||||
|
) |
||||
|
date_range_id = fields.Many2one( |
||||
|
comodel_name='date.range', |
||||
|
string='Date range', |
||||
|
domain="['|', " |
||||
|
"('company_id', '=', False)," |
||||
|
"('company_id', '=', company_id)]", |
||||
|
) |
||||
|
date_from = fields.Date( |
||||
|
string="Start date", |
||||
|
required=True |
||||
|
) |
||||
|
date_to = fields.Date( |
||||
|
string="End date", |
||||
|
required=True |
||||
|
) |
||||
|
journal_ids = fields.Many2many( |
||||
|
comodel_name='account.journal', |
||||
|
string="Journals", |
||||
|
domain="[('company_id', '=', company_id)]", |
||||
|
required=True, |
||||
|
) |
||||
|
move_target = fields.Selection( |
||||
|
selection='_get_move_targets', |
||||
|
default='all', |
||||
|
required=True, |
||||
|
) |
||||
|
foreign_currency = fields.Boolean() |
||||
|
sort_option = fields.Selection( |
||||
|
selection='_get_sort_options', |
||||
|
string="Sort entries by", |
||||
|
default='move_name', |
||||
|
required=True, |
||||
|
) |
||||
|
group_option = fields.Selection( |
||||
|
selection='_get_group_options', |
||||
|
string="Group entries by", |
||||
|
default='journal', |
||||
|
required=True, |
||||
|
) |
||||
|
with_account_name = fields.Boolean( |
||||
|
default=False, |
||||
|
) |
||||
|
|
||||
|
@api.model |
||||
|
def _get_move_targets(self): |
||||
|
return [ |
||||
|
('all', _("All")), |
||||
|
('posted', _("Posted")), |
||||
|
('draft', _("Not Posted")) |
||||
|
] |
||||
|
|
||||
|
@api.model |
||||
|
def _get_sort_options(self): |
||||
|
return [ |
||||
|
('move_name', _("Entry number")), |
||||
|
('date', _("Date")), |
||||
|
] |
||||
|
|
||||
|
@api.model |
||||
|
def _get_group_options(self): |
||||
|
return [ |
||||
|
('journal', _("Journal")), |
||||
|
('none', _("No group")), |
||||
|
] |
||||
|
|
||||
|
@api.onchange('date_range_id') |
||||
|
def onchange_date_range_id(self): |
||||
|
self.date_from = self.date_range_id.date_start |
||||
|
self.date_to = self.date_range_id.date_end |
||||
|
|
||||
|
@api.multi |
||||
|
def button_export_html(self): |
||||
|
self.ensure_one() |
||||
|
action = self.env.ref( |
||||
|
'account_financial_report.action_report_journal_ledger') |
||||
|
vals = action.read()[0] |
||||
|
context1 = vals.get('context', {}) |
||||
|
if isinstance(context1, pycompat.string_types): |
||||
|
context1 = safe_eval(context1) |
||||
|
model = self.env['report_journal_ledger'] |
||||
|
report = model.create(self._prepare_report_journal_ledger()) |
||||
|
report.compute_data_for_report() |
||||
|
context1['active_id'] = report.id |
||||
|
context1['active_ids'] = report.ids |
||||
|
vals['context'] = context1 |
||||
|
return vals |
||||
|
|
||||
|
@api.multi |
||||
|
def button_export_pdf(self): |
||||
|
self.ensure_one() |
||||
|
report_type = 'qweb-pdf' |
||||
|
return self._export(report_type) |
||||
|
|
||||
|
@api.multi |
||||
|
def button_export_xlsx(self): |
||||
|
self.ensure_one() |
||||
|
report_type = 'xlsx' |
||||
|
return self._export(report_type) |
||||
|
|
||||
|
@api.multi |
||||
|
def _prepare_report_journal_ledger(self): |
||||
|
self.ensure_one() |
||||
|
return { |
||||
|
'date_from': self.date_from, |
||||
|
'date_to': self.date_to, |
||||
|
'move_target': self.move_target, |
||||
|
'foreign_currency': self.foreign_currency, |
||||
|
'company_id': self.company_id.id, |
||||
|
'journal_ids': [(6, 0, self.journal_ids.ids)], |
||||
|
'sort_option': self.sort_option, |
||||
|
'group_option': self.group_option, |
||||
|
'with_account_name': self.with_account_name, |
||||
|
} |
||||
|
|
||||
|
def _export(self, report_type): |
||||
|
"""Default export is PDF.""" |
||||
|
self.ensure_one() |
||||
|
model = self.env['report_journal_ledger'] |
||||
|
report = model.create(self._prepare_report_journal_ledger()) |
||||
|
report.compute_data_for_report() |
||||
|
return report.print_report(report_type) |
@ -0,0 +1,66 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- Copyright 2017 ACSONE SA/NV |
||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
||||
|
|
||||
|
<odoo> |
||||
|
|
||||
|
|
||||
|
<record id="journal_ledger_wizard" model="ir.ui.view"> |
||||
|
<field name="name">Journal Ledger</field> |
||||
|
<field name="model">journal.ledger.report.wizard</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form> |
||||
|
<group> |
||||
|
<field name="company_id" groups="base.group_multi_company"/> |
||||
|
</group> |
||||
|
|
||||
|
<separator string="Periods"/> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="date_range_id"/> |
||||
|
<field name="date_from"/> |
||||
|
<field name="date_to"/> |
||||
|
</group> |
||||
|
<group/> |
||||
|
</group> |
||||
|
|
||||
|
<separator string="Options"/> |
||||
|
<group name="options"> |
||||
|
<group> |
||||
|
<field name="move_target" widget="radio" options="{'horizontal': true}"/> |
||||
|
<field name="sort_option"/> |
||||
|
<field name="group_option"/> |
||||
|
<field name="foreign_currency"/> |
||||
|
<field name="with_account_name"/> |
||||
|
</group> |
||||
|
<group/> |
||||
|
</group> |
||||
|
|
||||
|
<separator string="Journals"/> |
||||
|
<group> |
||||
|
<field name="journal_ids" widget="many2many_tags"/> |
||||
|
</group> |
||||
|
|
||||
|
<footer> |
||||
|
<button name="button_export_html" string="View" |
||||
|
type="object" default_focus="1" class="oe_highlight"/> |
||||
|
or |
||||
|
<button name="button_export_pdf" string="Export PDF" type="object"/> |
||||
|
or |
||||
|
<button name="button_export_xlsx" string="Export XLSX" type="object"/> |
||||
|
or |
||||
|
<button string="Cancel" class="oe_link" special="cancel" /> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<act_window id="action_journal_ledger_wizard" |
||||
|
name="Journal Ledger" |
||||
|
res_model="journal.ledger.report.wizard" |
||||
|
view_type="form" |
||||
|
view_mode="form" |
||||
|
view_id="journal_ledger_wizard" |
||||
|
target="new" /> |
||||
|
|
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue