From 5cbc611361297cc4cbeb49d6d7f6ffa13cefb314 Mon Sep 17 00:00:00 2001 From: Anand-Dharampuriya Date: Tue, 1 Jul 2014 15:54:23 +0530 Subject: [PATCH 1/4] [FIX] Solve some mail issues which are currently present in 7.0 --- addons/mail/mail_group.py | 8 +++++++- addons/mail/mail_thread.py | 2 +- openerp/tools/mail.py | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_group.py b/addons/mail/mail_group.py index 481109a8ebe..719dfad161b 100644 --- a/addons/mail/mail_group.py +++ b/addons/mail/mail_group.py @@ -24,7 +24,7 @@ import openerp.tools as tools from openerp.osv import osv from openerp.osv import fields from openerp import SUPERUSER_ID - +from openerp.tools.translate import _ class mail_group(osv.Model): """ A mail_group is a collection of users sharing messages in a discussion @@ -172,6 +172,12 @@ class mail_group(osv.Model): mail_alias = self.pool.get('mail.alias') alias_ids = [group.alias_id.id for group in groups if group.alias_id] # Delete mail_group + try: + all_emp_group = self.pool['ir.model.data'].get_object_reference(cr, uid, 'mail', 'group_all_employees')[1] + except ValueError: + all_emp_group = None + if all_emp_group and all_emp_group in ids: + raise osv.except_osv(_('Warning!'), _('You cannot delete those groups, as the Whole Company group is required by other modules.')) res = super(mail_group, self).unlink(cr, uid, ids, context=context) # Delete alias mail_alias.unlink(cr, SUPERUSER_ID, alias_ids, context=context) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 942daddd439..384fc6d6642 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -951,7 +951,7 @@ class mail_thread(osv.AbstractModel): return result if partner and partner in obj.message_follower_ids: # recipient already in the followers -> skip return result - if partner and partner in [val[0] for val in result[obj.id]]: # already existing partner ID -> skip + if partner and partner.id in [val[0] for val in result[obj.id]]: # already existing partner ID -> skip return result if partner and partner.email: # complete profile: id, name result[obj.id].append((partner.id, '%s<%s>' % (partner.name, partner.email), reason)) diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 1f3e9c1b019..7e2c79800bd 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -211,10 +211,11 @@ def html2plaintext(html, body_id=None, encoding='utf-8'): html = re.sub('', '\n', html) html = re.sub('<.*?>', ' ', html) html = html.replace(' ' * 2, ' ') + html = html.replace('>', '>') + html = html.replace('<', '<') # strip all lines - html = '\n'.join([x.strip() for x in html.splitlines()]) - html = html.replace('\n' * 2, '\n') + html = ''.join([x.strip() for x in html.splitlines(True)]) for i, url in enumerate(url_index): if i == 0: From 437116f3c43d4d97b2c2bd6d3f7a39ffd6c7d844 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 11 Jul 2014 11:39:32 +0200 Subject: [PATCH 2/4] [FIX] orm: custom m2m with different label At rev 84e9a67cdf78db94cb7a09543c1b7ac4ad19d8b4 a check to avoid the creation of ir.model.relation for custom modules was added. The condition is not correct as based on the string instead of the field name. We do not have access to column name at this level but the the m2m relation table do start with x_ for custom fields (see __init__ method). --- openerp/osv/orm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 1f2823b7919..0a38ccf03d4 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3387,7 +3387,8 @@ class BaseModel(object): m2m_tbl, col1, col2 = f._sql_names(self) # do not create relations for custom fields as they do not belong to a module # they will be automatically removed when dropping the corresponding ir.model.field - if not f.string.startswith('x_'): + # table name for custom relation all starts with x_, see __init__ + if not m2m_tbl.startswith('x_'): self._save_relation_table(cr, m2m_tbl) cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname=%s", (m2m_tbl,)) if not cr.dictfetchall(): From 117a26babe64ffc168cab54e5bdd3aeb39b7d83e Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Fri, 11 Jul 2014 11:30:29 +0200 Subject: [PATCH 3/4] [FIX] hr: call hr_employee super's when unlinking Also fixes some weird inheritance bugs in upper versions --- addons/hr/hr.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index dbb20cc8b76..d2a0d11cc81 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -234,6 +234,7 @@ class hr_employee(osv.osv): resource_ids = [] for employee in self.browse(cr, uid, ids, context=context): resource_ids.append(employee.resource_id.id) + super(hr_employee, self).unlink(cr, uid, ids, context=context) return self.pool.get('resource.resource').unlink(cr, uid, resource_ids, context=context) def onchange_address_id(self, cr, uid, ids, address, context=None): From 783b9e1c897e6a36842a7c0b6dc1ded57a95f4f4 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 11 Jul 2014 10:49:48 +0200 Subject: [PATCH 4/4] [FIX] event_sale: reset event-related fields on SO line when switching products --- addons/event_sale/event_sale.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/event_sale/event_sale.py b/addons/event_sale/event_sale.py index 4f32620e667..08021a794d9 100644 --- a/addons/event_sale/event_sale.py +++ b/addons/event_sale/event_sale.py @@ -64,7 +64,11 @@ class sale_order_line(osv.osv): if product: product_res = self.pool.get('product.product').browse(cr, uid, product, context=context) if product_res.event_ok: - res['value'].update({'event_type_id': product_res.event_type_id.id, 'event_ok':product_res.event_ok}) + res['value'].update(event_type_id=product_res.event_type_id.id, + event_ok=product_res.event_ok) + else: + res['value'].update(event_type_id=False, + event_ok=False) return res def button_confirm(self, cr, uid, ids, context=None):