From f7dfcd5d9816a2841c3ab3bb71feb3ab71520ae1 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 22 Jul 2014 16:38:52 +0200 Subject: [PATCH 1/4] [FIX] delivery: use unit of measure and not unit of stock to compute price of delivery The computation expects uom and it was wrongly passing uos qunatities. --- addons/delivery/delivery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/delivery.py b/addons/delivery/delivery.py index c6deb3147a3..62d513c8bff 100644 --- a/addons/delivery/delivery.py +++ b/addons/delivery/delivery.py @@ -196,7 +196,7 @@ class delivery_grid(osv.osv): for line in order.order_line: if not line.product_id: continue - q = product_uom_obj._compute_qty(cr, uid, line.product_uom.id, line.product_uos_qty, line.product_id.uom_id.id) + q = product_uom_obj._compute_qty(cr, uid, line.product_uom.id, line.product_uom_qty, line.product_id.uom_id.id) total += line.price_subtotal or 0.0 weight += (line.product_id.weight or 0.0) * q volume += (line.product_id.volume or 0.0) * q From 9a20018166d0633c6b3cee2f13ec5c65c215df60 Mon Sep 17 00:00:00 2001 From: Hardik Ansodariya Date: Wed, 23 Jul 2014 10:03:40 +0200 Subject: [PATCH 2/4] [FIX] stock: allow same serial number for different products Bug lp:1222289, opw 597639 --- addons/stock/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 3b1e70646f1..c14819f9f5f 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1487,7 +1487,7 @@ class stock_production_lot(osv.osv): 'product_id': lambda x, y, z, c: c.get('product_id', False), } _sql_constraints = [ - ('name_ref_uniq', 'unique (name, ref)', 'The combination of Serial Number and internal reference must be unique !'), + ('name_ref_uniq', 'unique (name, ref, product_id, company_id)', 'The combination of Serial Number, internal reference, Product and Company must be unique !'), ] def action_traceability(self, cr, uid, ids, context=None): """ It traces the information of a product From f9d43e83c67691f84f352b2594977a05cbf3d50c Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 23 Jul 2014 12:19:51 +0200 Subject: [PATCH 3/4] [FIX] web: correct rev 680f955 Missing backport of commit f652402 for buffered dataset Again, should not be forwardported --- addons/web/static/src/js/data.js | 28 ++++++++++++++++++++++----- addons/web/static/src/js/view_form.js | 15 ++++++-------- addons/web/static/src/js/view_list.js | 9 +++++---- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index ee24c481a3a..6ae69fbe67b 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -430,12 +430,30 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin, read_ids: function (ids, fields, options) { if (_.isEmpty(ids)) return $.Deferred().resolve([]); - + options = options || {}; - // TODO: reorder results to match ids list - return this._model.call('read', - [ids, fields || false], - {context: this.get_context(options.context)}); + var method = 'read'; + var ids_arg = ids; + var context = this.get_context(options.context); + if (options.check_access_rule === true){ + method = 'search_read'; + ids_arg = [['id', 'in', ids]]; + context = new instance.web.CompoundContext(context, {active_test: false}); + } + return this._model.call(method, + [ids_arg, fields || false], + {context: context}) + .then(function (records) { + if (records.length <= 1) { return records; } + var indexes = {}; + for (var i = 0; i < ids.length; i++) { + indexes[ids[i]] = i; + } + records.sort(function (a, b) { + return indexes[a.id] - indexes[b.id]; + }); + return records; + }); }, /** * Read a slice of the records represented by this DataSet, based on its diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 790fa88caa5..e91955e0a4e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -957,20 +957,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } else { var fields = _.keys(self.fields_view.fields); fields.push('display_name'); - // Use of search_read instead of read to check if we can still read the record (security rules) - return self.dataset.call('search_read', [[['id', '=', self.dataset.ids[self.dataset.index]]], fields], + return self.dataset.read_index(fields, { context: { 'bin_size': true, 'future_display_name': true - } + }, + check_access_rule: true }).then(function(r) { - if (_.isEmpty(r)){ - self.do_action('history_back'); - } - else{ - self.trigger('load_record', r[0]); - } + self.trigger('load_record', r); + }).fail(function (){ + self.do_action('history_back'); }); } }); diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 9d4c781b785..54f7946a9a3 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -529,13 +529,14 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi reload_record: function (record) { var self = this; // Use of search_read instead of read to check if we can still read the record (security rules) - return this.dataset.call('search_read', [ - [['id', '=', record.get('id')]], + return this.dataset.read_ids( + [record.get('id')], _.pluck(_(this.columns).filter(function (r) { return r.tag === 'field'; - }), 'name')] + }), 'name'), + {check_access_rule: true} ).done(function (records) { - var values = _.isEmpty(records) ? undefined : records[0]; + var values = records[0]; if (!values) { self.records.remove(record); return; From 67cca3f1e5489a81996d1ba20586749490d8665a Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Tue, 15 Jul 2014 16:17:36 -0400 Subject: [PATCH 4/4] [FIX] mail: display translated model name at record creation When a record is created, if it inherits from mail.thread, a message 'OBJECT created' is posted. 'created' is translated but the name of the model wasn't. This fix uses the name of the linked ir.model which is already a translatable field. lp:1262000, opw 611043 --- addons/mail/mail_thread.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 384fc6d6642..5691cb9ac73 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -253,7 +253,10 @@ class mail_thread(osv.AbstractModel): # automatic logging unless asked not to (mainly for various testing purpose) if not context.get('mail_create_nolog'): - self.message_post(cr, uid, thread_id, body=_('%s created') % (self._description), context=context) + ir_model_pool = self.pool['ir.model'] + ids = ir_model_pool.search(cr, uid, [('model', '=', self._name)], context=context) + name = ir_model_pool.read(cr, uid, ids, ['name'], context=context)[0]['name'] + self.message_post(cr, uid, thread_id, body=_('%s created') % name, context=context) # auto_subscribe: take values and defaults into account create_values = dict(values)