Browse Source

Merge pull request #503 from i-vyshnevska/10-fix-account-financial-report-qweb-reconcile

[10.0][FIX] account_financial_report_qweb:  Link reconcile model instead just name
pull/508/head
Pedro M. Baeza 6 years ago
committed by GitHub
parent
commit
58388a7d8e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      account_financial_report_qweb/report/abstract_report.py
  2. 6
      account_financial_report_qweb/report/general_ledger.py
  3. 5
      account_financial_report_qweb/report/general_ledger_xlsx.py
  4. 1
      account_financial_report_qweb/report/open_items.py
  5. 14
      account_financial_report_qweb/report/templates/general_ledger.xml
  6. 4
      account_financial_report_qweb/report/templates/open_items.xml
  7. 28
      account_financial_report_qweb/static/src/js/account_financial_report_qweb_backend.js
  8. 40
      account_financial_report_qweb/static/src/js/account_financial_report_qweb_widgets.js
  9. 1
      customer_activity_statement/report/customer_activity_statement.py

1
account_financial_report_qweb/report/abstract_report.py

@ -13,6 +13,7 @@ class AbstractReport(models.AbstractModel):
"Model %s is not transient, it cannot be vacuumed!" % self._name "Model %s is not transient, it cannot be vacuumed!" % self._name
# Never delete rows used in last 5 minutes # Never delete rows used in last 5 minutes
seconds = max(seconds, 300) seconds = max(seconds, 300)
# pylint: disable=sql-injection
query = """ query = """
DELETE FROM """ + self._table + """ DELETE FROM """ + self._table + """
WHERE WHERE

6
account_financial_report_qweb/report/general_ledger.py

@ -186,6 +186,7 @@ class GeneralLedgerReportMoveLine(models.TransientModel):
# Data fields, used to keep link with real object # Data fields, used to keep link with real object
move_line_id = fields.Many2one('account.move.line') move_line_id = fields.Many2one('account.move.line')
matched_ml_id = fields.Many2one("account.full.reconcile")
# Data fields, used for report display # Data fields, used for report display
date = fields.Date() date = fields.Date()
@ -197,7 +198,6 @@ class GeneralLedgerReportMoveLine(models.TransientModel):
label = fields.Char() label = fields.Char()
cost_center = fields.Char() cost_center = fields.Char()
tags = fields.Char() tags = fields.Char()
matching_number = fields.Char()
debit = fields.Float(digits=(16, 2)) debit = fields.Float(digits=(16, 2))
credit = fields.Float(digits=(16, 2)) credit = fields.Float(digits=(16, 2))
cumul_balance = fields.Float(digits=(16, 2)) cumul_balance = fields.Float(digits=(16, 2))
@ -1067,6 +1067,7 @@ INSERT INTO
create_uid, create_uid,
create_date, create_date,
move_line_id, move_line_id,
matched_ml_id,
date, date,
entry, entry,
journal, journal,
@ -1075,7 +1076,6 @@ INSERT INTO
partner, partner,
label, label,
cost_center, cost_center,
matching_number,
debit, debit,
credit, credit,
cumul_balance, cumul_balance,
@ -1096,6 +1096,7 @@ SELECT
%s AS create_uid, %s AS create_uid,
NOW() AS create_date, NOW() AS create_date,
ml.id AS move_line_id, ml.id AS move_line_id,
fr.id AS matched_ml_id,
ml.date, ml.date,
m.name AS entry, m.name AS entry,
j.code AS journal, j.code AS journal,
@ -1139,7 +1140,6 @@ SELECT
query_inject_move_line += """ query_inject_move_line += """
CONCAT_WS(' - ', NULLIF(ml.ref, ''), NULLIF(ml.name, '')) AS label, CONCAT_WS(' - ', NULLIF(ml.ref, ''), NULLIF(ml.name, '')) AS label,
aa.name AS cost_center, aa.name AS cost_center,
fr.name AS matching_number,
ml.debit, ml.debit,
ml.credit, ml.credit,
""" """

5
account_financial_report_qweb/report/general_ledger_xlsx.py

@ -37,7 +37,10 @@ class GeneralLedgerXslx(abstract_report_xlsx.AbstractReportXslx):
8: {'header': _('Tags'), 8: {'header': _('Tags'),
'field': 'tags', 'field': 'tags',
'width': 10}, 'width': 10},
9: {'header': _('Rec.'), 'field': 'matching_number', 'width': 5},
9: {'header': _('Rec.'),
'field': 'matched_ml_id',
'type': 'many2one',
'width': 5},
10: {'header': _('Debit'), 10: {'header': _('Debit'),
'field': 'debit', 'field': 'debit',
'field_initial_balance': 'initial_debit', 'field_initial_balance': 'initial_debit',

1
account_financial_report_qweb/report/open_items.py

@ -638,6 +638,7 @@ ORDER BY
self._compute_account_cumul() self._compute_account_cumul()
def _compute_partner_cumul(self): def _compute_partner_cumul(self):
# pylint: disable=sql-injection
where_condition_partner_by_account = """ where_condition_partner_by_account = """
WHERE WHERE
id IN id IN

14
account_financial_report_qweb/report/templates/general_ledger.xml

@ -336,8 +336,8 @@
<a t-att-data-active-id="line.move_line_id.move_id.id" <a t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model" t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action underline-on-hover" class="o_account_financial_reports_web_action underline-on-hover"
style="color: black; cursor: pointer;">
<t t-raw="line.entry"/></a>
t-att-style="style">
<t t-att-style="style" t-raw="line.entry"/></a>
</span> </span>
</div> </div>
<!--## journal--> <!--## journal-->
@ -403,12 +403,12 @@
</t> </t>
<!--## matching_number--> <!--## matching_number-->
<div class="act_as_cell"> <div class="act_as_cell">
<t t-set="res_model" t-value="'account_full_reconcile'"/>
<span t-if="line.matching_number">
<a t-att-data-active-id="line.move_line_id.full_reconcile_id.id"
<t t-set="res_model" t-value="'account.full.reconcile'"/>
<span t-if="line.matched_ml_id">
<a t-att-data-active-id="line.matched_ml_id.id"
t-att-data-res-model="res_model" t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action underline-on-hover"
style="color: black; cursor: pointer;"><t t-raw="line.matching_number"/></a>
class="o_account_financial_reports_web_action underline-on-hover">
<t t-att-style="style" t-raw="line.matched_ml_id.name"/></a>
</span> </span>
</div> </div>
<!--## debit--> <!--## debit-->

4
account_financial_report_qweb/report/templates/open_items.xml

@ -137,8 +137,8 @@
<a t-att-data-active-id="line.move_line_id.move_id.id" <a t-att-data-active-id="line.move_line_id.move_id.id"
t-att-data-res-model="res_model" t-att-data-res-model="res_model"
class="o_account_financial_reports_web_action" class="o_account_financial_reports_web_action"
style="color: black;">
<t t-raw="line.entry"/>
t-att-style="style">
<t t-att-style="style" t-raw="line.entry"/>
</a> </a>
</span> </span>
</div> </div>

28
account_financial_report_qweb/static/src/js/account_financial_report_qweb_backend.js

@ -4,7 +4,8 @@ odoo.define('account_financial_report_qweb.account_financial_report_backend', fu
var core = require('web.core'); var core = require('web.core');
var Widget = require('web.Widget'); var Widget = require('web.Widget');
var ControlPanelMixin = require('web.ControlPanelMixin'); var ControlPanelMixin = require('web.ControlPanelMixin');
var ReportWidget = require('account_financial_report_qweb.account_financial_report_widget');
var ReportWidget = require(
'account_financial_report_qweb.account_financial_report_widget');
var Model = require('web.Model'); var Model = require('web.Model');
@ -22,7 +23,8 @@ var report_backend = Widget.extend(ControlPanelMixin, {
if (action.context.context) { if (action.context.context) {
this.given_context = action.context.context; this.given_context = action.context.context;
} }
this.given_context.active_id = action.context.active_id || action.params.active_id;
this.given_context.active_id = action.context.active_id ||
action.params.active_id;
this.given_context.model = action.context.active_model || false; this.given_context.model = action.context.active_model || false;
this.given_context.ttype = action.context.ttype || false; this.given_context.ttype = action.context.ttype || false;
return this._super.apply(this, arguments); return this._super.apply(this, arguments);
@ -45,23 +47,22 @@ var report_backend = Widget.extend(ControlPanelMixin, {
this.set_html(); this.set_html();
return this._super(); return this._super();
}, },
// Fetches the html and is previous report.context if any, else create it
// Fetches the html and is previous report.context if any,
// else create it
get_html: function () { get_html: function () {
var self = this; var self = this;
var defs = []; var defs = [];
self.model = new Model(this.given_context.model); self.model = new Model(this.given_context.model);
return self.model.call('get_html', [this.given_context], {context: self.odoo_context}).then(function
(result) {
return self.model.call('get_html', [this.given_context],
{context: self.odoo_context}).then(function (result) {
self.html = result.html; self.html = result.html;
defs.push(self.update_cp()); defs.push(self.update_cp());
return $.when.apply($, defs); return $.when.apply($, defs);
}); });
}, },
// Updates the control panel and render the elements that have yet to be rendered
// Updates the control panel and render the elements that have yet to
// be rendered
update_cp: function () { update_cp: function () {
if (!this.$buttons) {
}
var status = { var status = {
breadcrumbs: this.actionManager.get_breadcrumbs(), breadcrumbs: this.actionManager.get_breadcrumbs(),
cp_content: {$buttons: this.$buttons}, cp_content: {$buttons: this.$buttons},
@ -75,7 +76,8 @@ var report_backend = Widget.extend(ControlPanelMixin, {
print: function () { print: function () {
var self = this; var self = this;
self.model = new Model(this.given_context.model); self.model = new Model(this.given_context.model);
self.model.call('print_report', [this.given_context.active_id, 'qweb-pdf'], {context: self.odoo_context})
self.model.call('print_report', [this.given_context.active_id,
'qweb-pdf'], {context: self.odoo_context})
.then(function (result) { .then(function (result) {
self.do_action(result); self.do_action(result);
}); });
@ -83,13 +85,15 @@ var report_backend = Widget.extend(ControlPanelMixin, {
export: function () { export: function () {
var self = this; var self = this;
self.model = new Model(this.given_context.model); self.model = new Model(this.given_context.model);
self.model.call('print_report', [this.given_context.active_id, 'xlsx'], {context: self.odoo_context})
self.model.call('print_report', [this.given_context.active_id,
'xlsx'], {context: self.odoo_context})
.then(function (result) { .then(function (result) {
self.do_action(result); self.do_action(result);
}); });
}, },
}); });
core.action_registry.add("account_financial_report_backend", report_backend);
core.action_registry.add("account_financial_report_backend",
report_backend);
return report_backend; return report_backend;
}); });

40
account_financial_report_qweb/static/src/js/account_financial_report_qweb_widgets.js

@ -7,10 +7,14 @@ var Widget = require('web.Widget');
var accountFinancialReportWidget = Widget.extend({ var accountFinancialReportWidget = Widget.extend({
events: { events: {
'click .o_account_financial_reports_web_action': 'boundLink',
'click .o_account_financial_reports_web_action_multi': 'boundLinkmulti',
'click .o_account_financial_reports_web_action_monetary': 'boundLinkMonetary',
'click .o_account_financial_reports_web_action_monetary_multi': 'boundLinkMonetarymulti',
'click .o_account_financial_reports_web_action':
'boundLink',
'click .o_account_financial_reports_web_action_multi':
'boundLinkmulti',
'click .o_account_financial_reports_web_action_monetary':
'boundLinkMonetary',
'click .o_account_financial_reports_web_action_monetary_multi':
'boundLinkMonetarymulti',
}, },
init: function () { init: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
@ -26,7 +30,7 @@ var accountFinancialReportWidget = Widget.extend({
res_model: res_model, res_model: res_model,
res_id: res_id, res_id: res_id,
views: [[false, 'form']], views: [[false, 'form']],
target: 'current'
target: 'current',
}); });
}, },
boundLinkmulti: function (e) { boundLinkmulti: function (e) {
@ -37,29 +41,41 @@ var accountFinancialReportWidget = Widget.extend({
res_model: res_model, res_model: res_model,
domain: domain, domain: domain,
views: [[false, "list"], [false, "form"]], views: [[false, "list"], [false, "form"]],
target: 'current'
target: 'current',
}); });
}, },
boundLinkMonetary: function (e) { boundLinkMonetary: function (e) {
var res_model = $(e.target.parentElement).data('res-model');
var res_id = $(e.target.parentElement).data('active-id');
var res_model = $(e.target).data('res-model');
var res_id = $(e.target).data('active-id');
// check if we call on appropriate element, amount been wrapped in
// a span by a monetary widget
if (e.target.localName === 'span' ) {
res_model = $(e.target.parentElement).data('res-model');
res_id = $(e.target.parentElement).data('active-id');
}
return this.do_action({ return this.do_action({
type: 'ir.actions.act_window', type: 'ir.actions.act_window',
res_model: res_model, res_model: res_model,
res_id: res_id, res_id: res_id,
views: [[false, 'form']], views: [[false, 'form']],
target: 'current'
target: 'current',
}); });
}, },
boundLinkMonetarymulti: function (e) { boundLinkMonetarymulti: function (e) {
var res_model = $(e.target.parentElement).data('res-model');
var domain = $(e.target.parentElement).data('domain');
var res_model = $(e.target).data('res-model');
var domain = $(e.target).data('domain');
// check if we call on appropriate element, amount been wrapped in
// a span by a monetary widget
if (e.target.localName === 'span' ) {
res_model = $(e.target.parentElement).data('res-model');
domain = $(e.target.parentElement).data('domain');
}
return this.do_action({ return this.do_action({
type: 'ir.actions.act_window', type: 'ir.actions.act_window',
res_model: res_model, res_model: res_model,
domain: domain, domain: domain,
views: [[false, "list"], [false, "form"]], views: [[false, "list"], [false, "form"]],
target: 'current'
target: 'current',
}); });
}, },
}); });

1
customer_activity_statement/report/customer_activity_statement.py

@ -101,6 +101,7 @@ class CustomerActivityStatement(models.AbstractModel):
def _get_account_display_lines(self, company_id, partner_ids, date_start, def _get_account_display_lines(self, company_id, partner_ids, date_start,
date_end): date_end):
# pylint: disable=sql-injection
res = dict(map(lambda x: (x, []), partner_ids)) res = dict(map(lambda x: (x, []), partner_ids))
partners = ', '.join([str(i) for i in partner_ids]) partners = ', '.join([str(i) for i in partner_ids])
date_start = datetime.strptime( date_start = datetime.strptime(

Loading…
Cancel
Save