From 49e7e67a27b3d393a8234bc2c466b0c642ce157b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 2 Apr 2015 15:00:05 +0200 Subject: [PATCH 1/5] [FIX] mrp: allow same product on different bom line Relax the constraint on BoM to allow to have two different lines with the same product. As the error message says, the purpose of the constraint was to forbid having the manufactured product as one of the components but had this side effect. Such scenario of the same product twice makes sense when using the date attributes on the lines (e.g. changing quantities) opw 621468 --- addons/mrp/mrp.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 2167f04190e..a85dd7316ae 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -257,19 +257,17 @@ class mrp_bom(osv.osv): return True def _check_product(self, cr, uid, ids, context=None): - all_prod = [] boms = self.browse(cr, uid, ids, context=context) - def check_bom(boms): + def check_bom(boms, all_prod): res = True for bom in boms: if bom.product_id.id in all_prod: - res = res and False - all_prod.append(bom.product_id.id) - lines = bom.bom_lines - if lines: - res = res and check_bom([bom_id for bom_id in lines if bom_id not in boms]) + return False + if bom.bom_lines: + res = res and check_bom([b for b in bom.bom_lines if b not in boms], all_prod + [bom.product_id.id]) return res - return check_bom(boms) + return check_bom(boms, []) + _constraints = [ (_check_recursion, 'Error ! You cannot create recursive BoM.', ['parent_id']), From 3bd29a348385dfaded8ff70240435b8c9ee89773 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 2 Apr 2015 09:49:15 +0200 Subject: [PATCH 2/5] [FIX] mail: display messages in chatter of inactive records The method search inside _find_allowed_model_wise must consider records with active field=True. opw:630295 --- addons/mail/mail_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 8ac047fb77e..f05320aee25 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -572,7 +572,8 @@ class mail_message(osv.Model): def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None): doc_ids = doc_dict.keys() - allowed_doc_ids = self.pool.get(doc_model).search(cr, uid, [('id', 'in', doc_ids)], context=context) + ctx = dict(context or {}, active_test=False) + allowed_doc_ids = self.pool.get(doc_model).search(cr, uid, [('id', 'in', doc_ids)], context=ctx) return set([message_id for allowed_doc_id in allowed_doc_ids for message_id in doc_dict[allowed_doc_id]]) def _find_allowed_doc_ids(self, cr, uid, model_ids, context=None): From eaad70daac22fd0fde1c63484b7f29eae6302e41 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 3 Apr 2015 12:40:57 +0200 Subject: [PATCH 3/5] [FIX] ir_attachment: upload of attachment for non-employees This rev. is related to eb9113c04d66627fbe04b473b9010e5de973c6aa if a model or a resource id is not defined on an attachment restrict access to employees only if the creator of this attachment is not the current user. So non-employees can access their attachments without models/resource id, which includes attachment of discussions threads. Fixes #4309 Closes #4310 --- openerp/addons/base/ir/ir_attachment.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_attachment.py b/openerp/addons/base/ir/ir_attachment.py index 6452b0d4f47..73bf8c94b43 100644 --- a/openerp/addons/base/ir/ir_attachment.py +++ b/openerp/addons/base/ir/ir_attachment.py @@ -197,10 +197,11 @@ class ir_attachment(osv.osv): if ids: if isinstance(ids, (int, long)): ids = [ids] - cr.execute('SELECT DISTINCT res_model, res_id FROM ir_attachment WHERE id = ANY (%s)', (ids,)) - for rmod, rid in cr.fetchall(): + cr.execute('SELECT DISTINCT res_model, res_id, create_uid FROM ir_attachment WHERE id = ANY (%s)', (ids,)) + for rmod, rid, create_uid in cr.fetchall(): if not (rmod and rid): - require_employee = True + if create_uid != uid: + require_employee = True continue res_ids.setdefault(rmod,set()).add(rid) if values: From 3d11e6fae3e02dfb464185e87e8f8e7835ec90fb Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Sun, 15 Feb 2015 00:59:14 +0200 Subject: [PATCH 4/5] [FIX] ir_mail_server: _get_default_bounce_address fails due to ir.config_parameter permission At rev. 80017b04c2fefe895659f56e5e8d34bd59093e13 ir.config_parameter model has been restricted to employees Getting parameter from this model should therefore be done as SUPERUSER_ID where the uid could be a user which is not an employee. Closes #5280 --- openerp/addons/base/ir/ir_mail_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_mail_server.py b/openerp/addons/base/ir/ir_mail_server.py index 6a7784fead1..12fde39baac 100644 --- a/openerp/addons/base/ir/ir_mail_server.py +++ b/openerp/addons/base/ir/ir_mail_server.py @@ -375,10 +375,10 @@ class ir_mail_server(osv.osv): ''' get_param = self.pool['ir.config_parameter'].get_param - postmaster = get_param(cr, uid, 'mail.catchall.alias', + postmaster = get_param(cr, SUPERUSER_ID, 'mail.catchall.alias', default='postmaster-odoo', context=context,) - domain = get_param(cr, uid, 'mail.catchall.domain', context=context) + domain = get_param(cr, SUPERUSER_ID, 'mail.catchall.domain', context=context) if postmaster and domain: return '%s@%s' % (postmaster, domain) From 5042d9133063bbd1fd6ca4ad75221c52df515e73 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 7 Apr 2015 12:37:11 +0200 Subject: [PATCH 5/5] [FIX] base: translation update When updating translations, the source (`src`) is irrelevant for `field` and `help` translations. Theses translation types are only matched through their `name`. --- openerp/addons/base/ir/ir_translation.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py index cdbec59c65c..0d03ca843c8 100644 --- a/openerp/addons/base/ir/ir_translation.py +++ b/openerp/addons/base/ir/ir_translation.py @@ -110,18 +110,22 @@ class ir_translation_import_cursor(object): # Records w/o res_id must _not_ be inserted into our db, because they are # referencing non-existent data. - cr.execute("DELETE FROM %s WHERE res_id IS NULL AND module IS NOT NULL" % \ - self._table_name) + cr.execute("DELETE FROM %s WHERE res_id IS NULL AND module IS NOT NULL" % self._table_name) - find_expr = "irt.lang = ti.lang AND irt.type = ti.type " \ - " AND irt.name = ti.name AND irt.src = ti.src " \ - " AND (ti.type != 'model' OR ti.res_id = irt.res_id) " + find_expr = """ + irt.lang = ti.lang + AND irt.type = ti.type + AND irt.name = ti.name + AND (ti.type IN ('field', 'help') OR irt.src = ti.src) + AND (ti.type != 'model' OR ti.res_id = irt.res_id) + """ # Step 2: update existing (matching) translations if self._overwrite: cr.execute("""UPDATE ONLY %s AS irt SET value = ti.value, - state = 'translated' + src = ti.src, + state = 'translated' FROM %s AS ti WHERE %s AND ti.value IS NOT NULL AND ti.value != '' """ % (self._parent_table, self._table_name, find_expr))