From eba1c56f9798681eb94496452fb6aed898e7e18c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 8 Dec 2014 15:33:43 +0100 Subject: [PATCH 1/4] [FIX] web: ensure one2many field destruction on button cancel The destruction of one2many fields is forced with the event change:effective_readonly This revision add the forced destruction for cancel(discard) button as well Otherwise, one2many fields are not properly destroyed when hitting the button "discard" (from save or discard). This can be problematic for one2many editable list views (such as invoice lines) if you discard while having a mandatory field not filled in the invoice line: You can't recreate an invoice, the one2many editable list is messed up Use case: Create an invoice, create a line, leave the description, required field, empty. Then, discard. Then, click on create. opw-616946 --- addons/web/static/src/js/view_form.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index be16faa309a..ed246e58da6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3540,16 +3540,18 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ var self = this; self.load_views(); - this.is_loaded.done(function() { - self.on("change:effective_readonly", self, function() { - self.is_loaded = self.is_loaded.then(function() { - self.viewmanager.destroy(); - return $.when(self.load_views()).done(function() { - self.reload_current_view(); - }); + var destroy = function() { + self.is_loaded = self.is_loaded.then(function() { + self.viewmanager.destroy(); + return $.when(self.load_views()).done(function() { + self.reload_current_view(); }); }); + }; + this.is_loaded.done(function() { + self.on("change:effective_readonly", self, destroy); }); + this.view.on("on_button_cancel", self, destroy); this.is_started = true; this.reload_current_view(); }, From 9f9e7ef0e1ca1d2f5fc5e0a166499c95359dbbf3 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 9 Dec 2014 12:40:32 +0100 Subject: [PATCH 2/4] [FIX] web: user lang has the priority on partner lang Potentialy, the timezone too. On item action click (such as menus in More.. and Print..), the data in form view had the priority on user context (through the sidebar_eval_context) Therefore, if a field "lang" was present in the form view (like in partner form), the web/action/load xmlrpc call was using the partner language instead of the user language. Example of wrong use case before the fix: - Set the user language in French, then go to a partner form of a partner with English set as language - Click on any button of the partner form, such as the "Invoices" button, notice that the last item of the breadcrumb is in English, instead of Frenh (the user language) - Click on any menu opening a wizard in the More.. dropdown menu, notice that the wizard title is in English instead of French - Print any report from the Print dropdown menu, notice that the report file name is in English. If you print the same report for the same partner but from the list view, the report file name is in French. --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ed246e58da6..aceb3e665fd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1165,7 +1165,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, build_eval_context: function() { var a_dataset = this.dataset; - return new instance.web.CompoundContext(a_dataset.get_context(), this._build_view_fields_values()); + return new instance.web.CompoundContext(this._build_view_fields_values(), a_dataset.get_context()); }, }); From b035cfb7e9df10dcdcfdf371946aa77057e5393c Mon Sep 17 00:00:00 2001 From: Ravi Gohil Date: Mon, 17 Nov 2014 17:06:37 +0530 Subject: [PATCH 3/4] [FIX] email_template: missing translations in email template When composing an email based on an email template, some parts of the template (the result of name_get on fields) were not translated. This was due to missing language in context when rendering the template. Fixes #3708, opw 617309 --- addons/email_template/email_template.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index c5e24b0da5f..e5ea9a5bb83 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -311,11 +311,14 @@ class email_template(osv.osv): context = {} report_xml_pool = self.pool.get('ir.actions.report.xml') template = self.get_email_template(cr, uid, template_id, res_id, context) + ctx = context.copy() + if template.lang: + ctx['lang'] = template._context.get('lang') values = {} for field in ['subject', 'body_html', 'email_from', 'email_to', 'email_recipients', 'email_cc', 'reply_to']: values[field] = self.render_template(cr, uid, getattr(template, field), - template.model, res_id, context=context) \ + template.model, res_id, context=ctx) \ or False if template.user_signature: signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature @@ -333,12 +336,9 @@ class email_template(osv.osv): attachments = [] # Add report in attachments if template.report_template: - report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=context) + report_name = self.render_template(cr, uid, template.report_name, template.model, res_id, context=ctx) report_service = 'report.' + report_xml_pool.browse(cr, uid, template.report_template.id, context).report_name # Ensure report is rendered using template's language - ctx = context.copy() - if template.lang: - ctx['lang'] = self.render_template(cr, uid, template.lang, template.model, res_id, context) service = netsvc.LocalService(report_service) (result, format) = service.create(cr, uid, [res_id], {'model': template.model}, ctx) # TODO in trunk, change return format to binary to match message_post expected format From db98434e85be8ae0dfdb580a263704e3bac454e2 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 11 Dec 2014 11:44:52 +0100 Subject: [PATCH 4/4] [FIX] account_aged_partner_balance: accurate total In some cases when the move was partially reconciled, the amount of the move wasn't added to the total This is related to rev. abe5c803a0e36f18aec4cc56abc289f66329a749 --- addons/account/report/account_aged_partner_balance.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/report/account_aged_partner_balance.py b/addons/account/report/account_aged_partner_balance.py index b7c26120b48..105720819ec 100644 --- a/addons/account/report/account_aged_partner_balance.py +++ b/addons/account/report/account_aged_partner_balance.py @@ -175,18 +175,20 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header): partners_partial = self.cr.fetchall() partners_amount = dict((i[0],0) for i in partners_partial) for partner_info in partners_partial: + partial = False if partner_info[2]: # in case of partial reconciliation, we want to keep the left amount in the oldest period self.cr.execute('''SELECT MIN(COALESCE(date_maturity,date)) FROM account_move_line WHERE reconcile_partial_id = %s''', (partner_info[2],)) date = self.cr.fetchall() if date and args_list[-3] <= date[0][0] <= args_list[-2]: # partial reconcilation + partial = True self.cr.execute('''SELECT SUM(l.debit-l.credit) FROM account_move_line AS l WHERE l.reconcile_partial_id = %s''', (partner_info[2],)) unreconciled_amount = self.cr.fetchall() partners_amount[partner_info[0]] += unreconciled_amount[0][0] - else: + if not partial: partners_amount[partner_info[0]] += partner_info[1] history.append(partners_amount)