[MIG] account_financial_report: Finalize migration to 12.0

* Move back to CSS and FIX

  NameError: variable @odoo-view-background-color is undefined in - on line 99, column 23:
  98 .o_account_financial_reports_page {
  99     background-color: @odoo-view-background-color;
  100     color: @odoo-main-text-color;

* Porting: parent_left does not exist anymore. Using parent_path + account code to sort report lines

* FIX js error with date object not converted to string while clicking on initial balance amount
  See https://user-images.githubusercontent.com/1033131/58337566-5d525c80-7e46-11e9-913a-3c3e0115fb3e.gif

* IMP style and metadata

* FIX tests about new date format and partner_id computed field of account.move

* FIX errors like

  2019-06-03 16:11:51,406 17857 ERROR dev_12_account_financial_report odoo.sql_db: bad query: b"\nDELETE FROM 'report_vat_report_tax'\nWHERE COALESCE(\n    write_date, create_date, (now() at time zone 'UTC'))::timestamp\n    < ((now() at time zone 'UTC') - interval '3600.0 seconds')\n"
  ERROR: syntax error at or near "'report_vat_report_tax'"
  LINE 2: DELETE FROM 'report_vat_report_tax'
                    ^
* IMP translation template and IMP Italian translation

* Remove useless comments
* Use AsIs to avoid SQL injection
* Use fields.Date methods
* Remove useless data from tests
* Improve comments
* Fix wizard.multi.charts.accounts
* Move _get_partner_ids_domain to abstract wizard
* Refactor default partners in wizard to use recordsets
* Improve js style
This commit is contained in:
eLBati
2019-05-30 17:55:16 +02:00
committed by chaule97
parent 9f9211b6ea
commit 2360900be1
37 changed files with 11264 additions and 10946 deletions

View File

@@ -2,6 +2,7 @@
# 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):
@@ -13,10 +14,10 @@ class AbstractReport(models.AbstractModel):
"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, (self._table, "%s seconds" % seconds,))
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))

View File

@@ -2,8 +2,7 @@
# Author: Julien Coux
# 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
from odoo import models, fields
import datetime
@@ -191,7 +190,7 @@ 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)
value = fields.Date.to_string(value)
cell_type = column.get('type', 'string')
if cell_type == 'many2one':
self.sheet.write_string(

View File

@@ -224,7 +224,8 @@ 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, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self):
result = {}

View File

@@ -594,7 +594,8 @@ 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, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self):
result = {}

View File

@@ -160,7 +160,8 @@ 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, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self):
result = {}
@@ -638,21 +639,6 @@ ORDER BY
self._compute_account_cumul()
def _compute_partner_cumul(self):
# pylint: disable=sql-injection
where_condition_partner_by_account = """
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
)"""
query_computer_partner_residual_cumul = """
UPDATE
report_open_items_partner
@@ -666,7 +652,20 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s
)
"""
params_compute_partners_residual_cumul = (self.id,)
self.env.cr.execute(query_computer_partner_residual_cumul,
params_compute_partners_residual_cumul)
@@ -684,13 +683,6 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
# Manage currency in partner
where_condition_partner_by_account_cur = """
WHERE
id IN
(
@@ -702,9 +694,14 @@ WHERE
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
ra.report_id = %s
)
"""
"""
params_compute_partner_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_due_cumul,
params_compute_partner_due_cumul)
# Manage currency in partner
query_compute_partners_cur_id_cumul = """
UPDATE
report_open_items_partner
@@ -718,7 +715,20 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_id_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_id_cumul,
params_compute_partners_cur_id_cumul)
@@ -737,7 +747,20 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_residual_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_residual_cumul,
params_compute_partners_cur_residual_cumul)
@@ -756,7 +779,20 @@ SET
WHERE
rml.report_partner_id = report_open_items_partner.id
)
""" + where_condition_partner_by_account_cur
WHERE
id IN
(
SELECT
rp.id
FROM
report_open_items_account ra
INNER JOIN
report_open_items_partner rp
ON ra.id = rp.report_account_id
WHERE
ra.report_id = %s AND ra.currency_id IS NOT NULL
)
"""
params_compute_partners_cur_due_cumul = (self.id,)
self.env.cr.execute(query_compute_partners_cur_due_cumul,
params_compute_partners_cur_due_cumul)

View File

@@ -189,7 +189,7 @@
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -203,7 +203,7 @@
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -219,7 +219,7 @@
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -233,7 +233,7 @@
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from),
('date', '&lt;', o.date_from.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -249,7 +249,7 @@
<t t-if="type == 'account_type'">
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -262,7 +262,7 @@
<t t-set="domain"
t-value="[('account_id', '=', account_or_partner_object.report_account_id.account_id.id),
('partner_id', '=', account_or_partner_object.partner_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"

View File

@@ -246,7 +246,7 @@
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -258,7 +258,7 @@
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -272,7 +272,7 @@
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -288,8 +288,8 @@
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -302,8 +302,8 @@
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -318,8 +318,8 @@
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to),
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -336,8 +336,8 @@
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -350,8 +350,8 @@
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to),
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -366,8 +366,8 @@
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to),
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -384,8 +384,8 @@
<t t-if="line.account_id">
<t t-set="domain"
t-value="[('account_id', '=', line.account_id.id),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to)]"/>
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -397,8 +397,8 @@
<t t-if="line.account_group_id">
<t t-set="domain"
t-value="[('account_id', 'in', line.compute_account_ids.ids),
('date', '&gt;=', line.report_id.date_from),
('date', '&lt;=', line.report_id.date_to)]"/>
('date', '&gt;=', line.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -412,8 +412,8 @@
<t t-set="domain"
t-value="[('account_id', '=', line.report_account_id.account_id.id),
('partner_id', '=', line.partner_id.id),
('date', '&gt;=', line.report_account_id.report_id.date_from),
('date', '&lt;=', line.report_account_id.report_id.date_to)]"/>
('date', '&gt;=', line.report_account_id.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', line.report_account_id.report_id.date_to.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -576,7 +576,7 @@
<div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"
@@ -589,8 +589,8 @@
<div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('debit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -604,8 +604,8 @@
<div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('credit', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -619,8 +619,8 @@
<div class="act_as_cell amount" style="width: 9.64%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&gt;=', account.report_id.date_from),
('date', '&lt;=', account.report_id.date_to),
('date', '&gt;=', account.report_id.date_from.strftime('%Y-%m-%d')),
('date', '&lt;=', account.report_id.date_to.strftime('%Y-%m-%d')),
('period_balance', '&lt;&gt;', 0)]"/>
<span>
<a t-att-data-domain="domain"
@@ -654,7 +654,7 @@
<div class="act_as_cell amount" style="width: 8.86%;">
<t t-set="domain"
t-value="[('account_id', '=', account.account_id.id),
('date', '&lt;', o.date_from)]"/>
('date', '&lt;', o.date_from.strftime('%Y-%m-%d'))]"/>
<span>
<a t-att-data-domain="domain"
t-att-data-res-model="'account.move.line'"

View File

@@ -74,8 +74,10 @@ class TrialBalanceReportAccount(models.TransientModel):
index=True
)
hide_line = fields.Boolean(compute='_compute_hide_line')
# Data fields, used to keep link with real object
sequence = fields.Integer(index=True, default=1)
# Data fields, used to keep link with real object.
# Sequence is a Char later built with 'parent_path' for groups
# and parent_path + account code for accounts
sequence = fields.Char(index=True, default='1')
level = fields.Integer(index=True, default=1)
# Data fields, used to keep link with real object
@@ -209,7 +211,8 @@ 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, config=False)
('report_type', '=', report_type)],
limit=1).report_action(self, config=False)
def _get_html(self):
result = {}
@@ -410,7 +413,7 @@ SELECT
accgroup.parent_id,
coalesce(accgroup.code_prefix, accgroup.name),
accgroup.name,
accgroup.id * 100000,
accgroup.parent_path,
accgroup.level
FROM
account_group accgroup"""
@@ -557,7 +560,7 @@ WHERE report_trial_balance_account.account_group_id = accgroup.id
"""Compute sequence, level for report_trial_balance_account account."""
query_update_account_group = """
UPDATE report_trial_balance_account
SET sequence = newline.sequence + 1,
SET sequence = CONCAT(newline.sequence, newline.code),
level = newline.level + 1
FROM report_trial_balance_account as newline
WHERE newline.account_group_id = report_trial_balance_account.parent_id