From eba1c56f9798681eb94496452fb6aed898e7e18c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 8 Dec 2014 15:33:43 +0100 Subject: [PATCH 1/5] [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/5] [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 7831fe631acfa1d3d7ffe39199d121879437360b Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 9 Dec 2014 15:17:10 +0100 Subject: [PATCH 3/5] [FIX] email_template: default model for save as new template feature When sending a message with the "Compose new message" button on the right of the user menu, in the top bar, if you tried to save the message as template, you had a traceback because model field of email.template is mandatory, but was set to True because there is no model in such a case. As there is no any relevant model in such a place, and that the field is mandatory, mail.message is pretty convenient as the default value. --- addons/email_template/wizard/mail_compose_message.py | 2 +- addons/email_template/wizard/mail_compose_message_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 18b8f09de76..1a56c07d223 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -131,7 +131,7 @@ class mail_compose_message(osv.TransientModel): email_template = self.pool.get('email.template') ir_model_pool = self.pool.get('ir.model') for record in self.browse(cr, uid, ids, context=context): - model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model)], context=context) + model_ids = ir_model_pool.search(cr, uid, [('model', '=', record.model or 'mail.message')], context=context) model_id = model_ids and model_ids[0] or False model_name = '' if model_id: diff --git a/addons/email_template/wizard/mail_compose_message_view.xml b/addons/email_template/wizard/mail_compose_message_view.xml index 987ec44acbb..24a9ef9ad8e 100644 --- a/addons/email_template/wizard/mail_compose_message_view.xml +++ b/addons/email_template/wizard/mail_compose_message_view.xml @@ -29,7 +29,7 @@
Use template