Browse Source

[MIG] account_financial_report: Migration to 12.0

[IMP] Reformated one query to avoid one sql injection warning message - but no sql injection was possible here
pull/749/head
Wolfgang Pichler 6 years ago
committed by João Marques
parent
commit
a54d7422d1
  1. 3
      account_financial_report/__manifest__.py
  2. 3
      account_financial_report/menuitems.xml
  3. 4
      account_financial_report/report/abstract_report.py
  4. 4
      account_financial_report/report/abstract_report_xlsx.py
  5. 2
      account_financial_report/report/aged_partner_balance.py
  6. 2
      account_financial_report/report/general_ledger.py
  7. 2
      account_financial_report/report/journal_ledger.py
  8. 2
      account_financial_report/report/open_items.py
  9. 4
      account_financial_report/report/trial_balance.py
  10. 2
      account_financial_report/report/vat_report.py
  11. 28
      account_financial_report/static/src/js/account_financial_report_backend.js
  12. 13
      account_financial_report/tests/abstract_test.py
  13. 4
      account_financial_report/tests/test_aged_partner_balance.py
  14. 17
      account_financial_report/tests/test_general_ledger.py
  15. 6
      account_financial_report/tests/test_journal_ledger.py
  16. 4
      account_financial_report/tests/test_open_items.py
  17. 8
      account_financial_report/tests/test_trial_balance.py
  18. 16
      account_financial_report/tests/test_vat_report.py
  19. 5
      account_financial_report/wizard/general_ledger_wizard.py
  20. 6
      account_financial_report/wizard/trial_balance_wizard.py

3
account_financial_report/__manifest__.py

@ -4,7 +4,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Financial Reports',
'version': '11.0.2.5.0',
'version': '12.0.1.0.0',
'category': 'Reporting',
'summary': 'OCA Financial Reports',
'author': 'Camptocamp SA,'
@ -15,7 +15,6 @@
"website": "https://odoo-community.org/",
'depends': [
'account',
'account_invoicing',
'date_range',
'report_xlsx',
],

3
account_financial_report/menuitems.xml

@ -58,6 +58,7 @@
groups="base.group_erp_manager"
/>
<!--
<menuitem
id="account.menu_general_ledger"
name="General Ledger"
@ -96,6 +97,6 @@
action="account.action_account_aged_balance_view"
parent="account.menu_finance_legal_statement"
groups="base.group_erp_manager"
/>
/>-->
</odoo>

4
account_financial_report/report/abstract_report.py

@ -14,9 +14,9 @@ class AbstractReport(models.AbstractModel):
# Never delete rows used in last 5 minutes
seconds = max(seconds, 300)
query = """
DELETE FROM """ + self._table + """
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, ("%s seconds" % seconds,))
self.env.cr.execute(query, (self._table, "%s seconds" % seconds,))

4
account_financial_report/report/abstract_report_xlsx.py

@ -3,6 +3,8 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
import datetime
class AbstractReportXslx(models.AbstractModel):
@ -188,6 +190,8 @@ class AbstractReportXslx(models.AbstractModel):
"""
for col_pos, column in self.columns.items():
value = getattr(line_object, column['field'])
if isinstance(value, datetime.date):
value = datetime.datetime.strftime(value, DEFAULT_SERVER_DATE_FORMAT)
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
self.sheet.write_string(

2
account_financial_report/report/aged_partner_balance.py

@ -195,7 +195,7 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
report = self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1)
return report.report_action(self)
return report.report_action(self, config=False)
def _get_html(self):
result = {}

2
account_financial_report/report/general_ledger.py

@ -224,7 +224,7 @@ class GeneralLedgerReportCompute(models.TransientModel):
'report_general_ledger_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
def _get_html(self):
result = {}

2
account_financial_report/report/journal_ledger.py

@ -594,7 +594,7 @@ class ReportJournalLedger(models.TransientModel):
'report_journal_ledger_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
def _get_html(self):
result = {}

2
account_financial_report/report/open_items.py

@ -160,7 +160,7 @@ class OpenItemsReportCompute(models.TransientModel):
'report_open_items_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
def _get_html(self):
result = {}

4
account_financial_report/report/trial_balance.py

@ -209,7 +209,7 @@ class TrialBalanceReportCompute(models.TransientModel):
'report_trial_balance_qweb'
return self.env['ir.actions.report'].search(
[('report_name', '=', report_name),
('report_type', '=', report_type)], limit=1).report_action(self)
('report_type', '=', report_type)], limit=1).report_action(self, config=False)
def _get_html(self):
result = {}
@ -410,7 +410,7 @@ SELECT
accgroup.parent_id,
coalesce(accgroup.code_prefix, accgroup.name),
accgroup.name,
accgroup.parent_left * 100000,
accgroup.id * 100000,
accgroup.level
FROM
account_group accgroup"""

2
account_financial_report/report/vat_report.py

@ -112,7 +112,7 @@ class VATReportCompute(models.TransientModel):
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)
return action.with_context(context).report_action(self, config=False)
def _get_html(self):
result = {}

28
account_financial_report/static/src/js/account_financial_report_backend.js

@ -63,6 +63,31 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
return $.when.apply($, defs);
});
},
// Updates the control panel and render the elements that have yet to be rendered
update_cp: function() {
if (this.$buttons) {
var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(),
cp_content: {$buttons: this.$buttons},
};
return this.update_control_panel(status);
}
},
do_show: function() {
this._super();
this.update_cp();
},
print: function() {
var self = this;
this._rpc({
model: this.given_context.model,
method: 'print_report',
args: [this.given_context.active_id, 'qweb-pdf'],
context: self.odoo_context,
}).then(function(result){
self.do_action(result);
});
},
// Updates the control panel and render the elements that have yet
// to be rendered
update_cp: function () {
@ -101,6 +126,9 @@ odoo.define('account_financial_report.account_financial_report_backend', functio
self.do_action(result);
});
},
canBeRemoved: function () {
return $.when();
},
});
core.action_registry.add(

13
account_financial_report/tests/abstract_test.py

@ -36,7 +36,7 @@ class AbstractTest(common.TransactionCase):
'bank_account_code_prefix': 1014,
'cash_account_code_prefix': 1014,
'currency_id': self.ref('base.USD'),
'transfer_account_id': transfer_account_id.id,
'transfer_account_code_prefix': '000',
})
transfer_account_id.update({
'chart_template_id': self.chart.id,
@ -98,7 +98,6 @@ class AbstractTest(common.TransactionCase):
def _add_chart_of_accounts(self):
self.company = self.env['res.company'].create({
'name': 'Spanish test company',
'external_report_layout': 'standard',
})
self.env.ref('base.group_multi_company').write({
'users': [(4, self.env.uid)],
@ -109,15 +108,7 @@ class AbstractTest(common.TransactionCase):
})
self.with_context(
company_id=self.company.id, force_company=self.company.id)
wizard = self.env['wizard.multi.charts.accounts'].create({
'company_id': self.company.id,
'chart_template_id': self.chart.id,
'code_digits': 4,
'currency_id': self.ref('base.USD'),
'transfer_account_id': self.chart.transfer_account_id.id,
})
wizard.onchange_chart_template_id()
wizard.execute()
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)

4
account_financial_report/tests/test_aged_partner_balance.py

@ -2,7 +2,7 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from . import abstract_test
@ -29,7 +29,7 @@ class TestAgedPartnerBalance(abstract_test.AbstractTest):
def _getBaseFilters(self):
return {
'date_at': time.strftime('%Y-12-31'),
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
}

17
account_financial_report/tests/test_general_ledger.py

@ -5,6 +5,7 @@
import time
from odoo.tests import common
from datetime import date, datetime
from . import abstract_test_foreign_currency as a_t_f_c
@ -31,10 +32,10 @@ class TestGeneralLedger(a_t_f_c.AbstractTestForeignCurrency):
def _getBaseFilters(self):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'fy_start_date': time.strftime('%Y-01-01'),
'fy_start_date': date(date.today().year, 1, 1),
'foreign_currency': True,
}
@ -87,11 +88,11 @@ class TestGeneralLedgerReport(common.TransactionCase):
def setUp(self):
super(TestGeneralLedgerReport, self).setUp()
self.before_previous_fy_year = '2014-05-05'
self.previous_fy_date_start = '2015-01-01'
self.previous_fy_date_end = '2015-12-31'
self.fy_date_start = '2016-01-01'
self.fy_date_end = '2016-12-31'
self.before_previous_fy_year = datetime.strptime('2014-05-05', '%Y-%m-%d')
self.previous_fy_date_start = datetime.strptime('2015-01-01', '%Y-%m-%d')
self.previous_fy_date_end = datetime.strptime('2015-12-31', '%Y-%m-%d')
self.fy_date_start = datetime.strptime('2016-01-01', '%Y-%m-%d')
self.fy_date_end = datetime.strptime('2016-12-31', '%Y-%m-%d')
self.receivable_account = self.env['account.account'].search([
('user_type_id.name', '=', 'Receivable')
], limit=1)

6
account_financial_report/tests/test_journal_ledger.py

@ -3,7 +3,7 @@
import time
from datetime import datetime
from datetime import datetime, date
from dateutil.relativedelta import relativedelta
from odoo.fields import Date
@ -34,8 +34,8 @@ class TestJournalLedger(a_t_f_c.AbstractTestForeignCurrency):
def _getBaseFilters(self):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'journal_ids': [(6, 0, self.journal_sale.ids)]
}

4
account_financial_report/tests/test_open_items.py

@ -2,7 +2,7 @@
# Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from . import abstract_test_foreign_currency as a_t_f_c
@ -28,7 +28,7 @@ class TestOpenItems(a_t_f_c.AbstractTestForeignCurrency):
def _getBaseFilters(self):
return {
'date_at': time.strftime('%Y-12-31'),
'date_at': date(date.today().year, 12, 31),
'company_id': self.company.id,
'foreign_currency': True,
}

8
account_financial_report/tests/test_trial_balance.py

@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from odoo.tests import common
from . import abstract_test_foreign_currency as a_t_f_c
@ -30,10 +30,10 @@ class TestTrialBalance(a_t_f_c.AbstractTestForeignCurrency):
def _getBaseFilters(self):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.company.id,
'fy_start_date': time.strftime('%Y-01-01'),
'fy_start_date': date(date.today().year, 1, 1),
'foreign_currency': True,
'show_partner_details': True,
}

16
account_financial_report/tests/test_vat_report.py

@ -2,7 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import time
from datetime import date
from odoo.tests import common
from . import abstract_test_tax_report
@ -29,8 +29,8 @@ class TestVAT(abstract_test_tax_report.AbstractTest):
def _getBaseFilters(self):
return {
'date_from': time.strftime('%Y-01-01'),
'date_to': time.strftime('%Y-12-31'),
'date_from': date(date.today().year, 1, 1),
'date_to': date(date.today().year, 12, 31),
'company_id': self.env.user.company_id.id,
}
@ -157,7 +157,7 @@ class TestVATReport(common.TransactionCase):
def _get_report_lines(self):
self.cbinvoice.pay_and_reconcile(
self.bank_journal.id, 300, time.strftime('%Y-%m-10'))
self.bank_journal.id, 300, date(date.today().year, date.today().month, 10))
vat_report = self.env['report_vat_report'].create({
'date_from': self.date_from,
'date_to': self.date_to,
@ -274,8 +274,8 @@ class TestVATReport(common.TransactionCase):
'date_to': time.strftime('%Y-%m-01'),
'tax_detail': True})
wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, time.strftime('%Y-%m-01'))
self.assertEqual(wizard.date_to, time.strftime('%Y-%m-28'))
self.assertEqual(wizard.date_from, date(date.today().year, 1, 1))
self.assertEqual(wizard.date_to, date(date.today().year, date.today().month, 28))
wizard._export('qweb-pdf')
wizard.button_export_html()
wizard.button_export_pdf()
@ -287,8 +287,8 @@ class TestVATReport(common.TransactionCase):
'based_on': 'taxgroups',
'tax_detail': True})
wizard.onchange_date_range_id()
self.assertEqual(wizard.date_from, time.strftime('%Y-%m-01'))
self.assertEqual(wizard.date_to, time.strftime('%Y-%m-28'))
self.assertEqual(wizard.date_from, date(date.today().year, 1, 1))
self.assertEqual(wizard.date_to, date(date.today().year, date.today().month, 28))
wizard._export('qweb-pdf')
wizard.button_export_html()
wizard.button_export_pdf()

5
account_financial_report/wizard/general_ledger_wizard.py

@ -9,9 +9,10 @@
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo.tools import pycompat, DEFAULT_SERVER_DATE_FORMAT
from odoo.exceptions import ValidationError
import time
from datetime import datetime
class GeneralLedgerReportWizard(models.TransientModel):
@ -121,7 +122,7 @@ class GeneralLedgerReportWizard(models.TransientModel):
for wiz in self.filtered('date_from'):
date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = res['date_from']
wiz.fy_start_date = datetime.strftime(res['date_from'], DEFAULT_SERVER_DATE_FORMAT)
@api.onchange('company_id')
def onchange_company_id(self):

6
account_financial_report/wizard/trial_balance_wizard.py

@ -6,9 +6,9 @@
from odoo import api, fields, models, _
from odoo.tools.safe_eval import safe_eval
from odoo.tools import pycompat
from odoo.tools import pycompat, DEFAULT_SERVER_DATE_FORMAT
from odoo.exceptions import UserError, ValidationError
from datetime import datetime
class TrialBalanceReportWizard(models.TransientModel):
"""Trial balance report wizard."""
@ -98,7 +98,7 @@ class TrialBalanceReportWizard(models.TransientModel):
for wiz in self.filtered('date_from'):
date = fields.Datetime.from_string(wiz.date_from)
res = self.company_id.compute_fiscalyear_dates(date)
wiz.fy_start_date = res['date_from']
wiz.fy_start_date = datetime.strftime(res['date_from'], DEFAULT_SERVER_DATE_FORMAT)
@api.onchange('company_id')
def onchange_company_id(self):

Loading…
Cancel
Save