From 78cade20a308bf13c487351d3c6cf1912d29e6d4 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Fri, 23 Apr 2010 15:24:22 +0200 Subject: [PATCH 01/10] [FIX] crm: mailgateway -> If not header, return an empty string bzr revid: stephane@openerp.com-20100423132422-zg7arhxh7u0dn7vr --- addons/crm/scripts/openerp_mailgate/openerp_mailgate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py b/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py index de8fac00fce..5e6ab5a094c 100755 --- a/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py +++ b/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py @@ -168,8 +168,8 @@ class email_parser(object): def _decode_header(self, s): from email.Header import decode_header - s = decode_header(s) - return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s)) + s = decode_header(s) + return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or [])) def msg_new(self, msg): message = self.msg_body_get(msg) From 1864724d6cd498cbe3fe2a2dba0eae6dac017c54 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 26 Apr 2010 14:49:18 +0200 Subject: [PATCH 02/10] [FIX] account: proper correction for typo in backport of bugfix for price accuracy bzr revid: odo@openerp.com-20100426124918-6aoa465pmcfkr91a --- addons/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index b7dcb6a3b8d..74531102073 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1062,7 +1062,7 @@ class account_move(osv.osv): # Example: # difference == 0.01 is OK iff price_accuracy <= 1! # difference == 0.0001 is OK iff price_accuracy <= 3! - if abs(amount) < 10 ** -(int(config['price_accuracy'])): + if abs(amount) < 10 ** -(int(config['price_accuracy'])+1): if not len(line_draft_ids): continue self.pool.get('account.move.line').write(cr, uid, line_draft_ids, { From 3f9d50dd8486aab69a7fb022431fd7d435a43d93 Mon Sep 17 00:00:00 2001 From: "PAP(OpenERP)" <> Date: Tue, 27 Apr 2010 13:20:30 +0530 Subject: [PATCH 03/10] Fixed one2many, comment on yaml _inherits field problems bzr revid: hda@tinyerp.com-20100427075030-8bda1t3z4wtrnpxa --- .../base_module_record/base_module_record.py | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/addons/base_module_record/base_module_record.py b/addons/base_module_record/base_module_record.py index 97c0ada4bca..899241b4188 100644 --- a/addons/base_module_record/base_module_record.py +++ b/addons/base_module_record/base_module_record.py @@ -30,19 +30,26 @@ import tools #objects_proxy = netsvc.ExportService.getService('object').__class__ class recording_objects_proxy(osv_pool): def execute(self, *args, **argv): - if len(args) >= 6 and isinstance(args[5], dict): + if args[3] == 'create': + _old_args = args[4].copy() + elif args[3] == 'write': _old_args = args[5].copy() + elif len(args) >= 5 and isinstance(args[4], dict): + _old_args = args[4].copy() else: _old_args = None res = super(recording_objects_proxy, self).execute(*args, **argv) pool = pooler.get_pool(args[0]) mod = pool.get('ir.module.record') + if mod and mod.recording: if args[3] not in ('default_get','read','fields_view_get','fields_get','search','search_count','name_search','name_get','get','request_get', 'get_sc', 'unlink'): if _old_args is not None: - args[5].update(_old_args) - if args[5]: - mod.recording_data.append(('query', args, argv,res)) + if args[3] == 'create': + args[4].update(_old_args) + elif args[3] == 'write': + args[5].update(_old_args) + mod.recording_data.append(('query', args, argv,res)) return res def exec_workflow(self, *args, **argv): @@ -125,7 +132,8 @@ class base_module_record(osv.osv): name = filter(lambda x: x in string.letters, (data.get('name','') or '').lower()) except: name='' - val = model.replace('.','_')+'_'+name+ str(i) +# name=data.get('name','') or ''.lower() + val = model.replace('.','_')+'_'+ name + str(i) i+=1 if val not in self.ids.values(): break @@ -146,7 +154,6 @@ class base_module_record(osv.osv): def _create_record(self, cr, uid, doc, model, data, record_id, noupdate=False): - data_pool = self.pool.get('ir.model.data') model_pool = self.pool.get(model) record = doc.createElement('record') @@ -196,12 +203,26 @@ class base_module_record(osv.osv): fname = model_pool._columns[key]._fields_id else: fname = model_pool._inherit_fields[key][2]._fields_id - valitem[2][fname] = record_id - newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) - if not newid: + if valitem[0] == 0: newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) + valitem[1]=newid + else: + newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) + if not newid: + newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) + valitem[1]=newid self.ids[(fields[key]['relation'], valitem[1])] = newid - +# if valitem[0] in (0,1): +# if key in model_pool._columns: +# fname = model_pool._columns[key]._fields_id +# else: +# fname = model_pool._inherit_fields[key][2]._fields_id +# valitem[2][fname] = record_id +# newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) +# if not newid: +# newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) +# self.ids[(fields[key]['relation'], valitem[1])] = newid +# childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid) noupdate = noupdate or update record_list += childrecord @@ -245,7 +266,7 @@ class base_module_record(osv.osv): for key,val in data.items(): if ((key in defaults[model]) and (val == defaults[model][key])) and not(fields[key].get('required',False)): continue - if not (val or (fields[key]['type']=='boolean')): + if not (val or (fields[key]['type']=='function')): continue elif fields[key]['type'] in ('boolean',): if not val: @@ -267,12 +288,9 @@ class base_module_record(osv.osv): fname = model_pool._columns[key]._fields_id else: fname = model_pool._inherit_fields[key][2]._fields_id - valitem[2][fname] = record_id - newid,update = self._get_id(cr, uid, fields[key]['relation'], valitem[1]) - if not newid: - newid = self._create_id(cr, uid, fields[key]['relation'], valitem[2]) - self.ids[(fields[key]['relation'], valitem[1])] = newid - childrecord = self._create_yaml_record(cr, uid, fields[key]['relation'],valitem[2], newid) + del valitem[2][fname] #delete parent_field from child's fields list + + childrecord = self._create_yaml_record(cr, uid, fields[key]['relation'],valitem[2], None) items[0].append(childrecord['attrs']) attrs[key] = items elif fields[key]['type'] in ('many2many',): @@ -289,11 +307,11 @@ class base_module_record(osv.osv): if m2m[0]: attrs[key] = m2m else: - val=val.replace('"','\'') try: attrs[key]=str(val) except: attrs[key]=tools.ustr(val) + attrs[key]=attrs[key].replace('"','\'') record['attrs'] = attrs return record @@ -311,7 +329,7 @@ class base_module_record(osv.osv): for f in filter(lambda a: isinstance(obj._columns[a], fields.function)\ and (not obj._columns[a].store),obj._columns): del data[f] - + for key,val in data.items(): if result.has_key(key): continue @@ -361,16 +379,16 @@ class base_module_record(osv.osv): def _generate_object_xml(self, cr, uid, rec, recv, doc, result=None): record_list = [] noupdate = False - if rec[4]=='write': - for id in rec[5]: - id,update = self._get_id(cr, uid, rec[3], id) + if rec[3]=='write': + for id in rec[4]: + id,update = self._get_id(cr, uid, rec[2], id) noupdate = noupdate or update if not id: continue - record,update = self._create_record(cr, uid, doc, rec[3], rec[6], id) + record,update = self._create_record(cr, uid, doc, rec[2], rec[5], id) noupdate = noupdate or update record_list += record - + elif rec[4] in ('menu_create',): for id in rec[5]: id,update = self._get_id(cr, uid, rec[3], id) @@ -487,7 +505,10 @@ class base_module_record(osv.osv): yaml_file += str(object) + '''\n\n''' else: record= self._generate_object_yaml(cr, uid, rec[1],rec[3]) - yaml_file+="!comment Creating an %s record"%(record['model']) + '''\n''' + if self.mode == "create" or self.mode == "copy": + yaml_file+="!comment Creating a %s record"%(record['model']) + '''\n''' + else: + yaml_file+="!comment Modifying a %s record"%(record['model']) + '''\n''' object= yaml.load(unicode('''\n !record %s \n'''%record,'iso-8859-1')) yaml_file += str(object) + '''\n''' attrs=yaml.dump(object.attrs, default_flow_style=False) From d754240f973617b1b3db88cd29a8655f5e0cd1d7 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 27 Apr 2010 16:50:56 +0530 Subject: [PATCH 04/10] [IMP]: implement new feature that will take care for the attachments bzr revid: mga@tinyerp.com-20100427112056-ba31r6ww8t97vydc --- addons/fetchmail/fetchmail.py | 26 ++++++++++++++------------ addons/fetchmail/fetchmail_view.xml | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 611b7c178fb..32b4ade2d27 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -137,7 +137,8 @@ class email_server(osv.osv): ('imap','IMAP Server'), ],'State', select=True, readonly=False), 'is_ssl':fields.boolean('SSL ?', required=False), - 'date': fields.date('Date'), + 'attach':fields.boolean('Add Attachments ?', required=False), + 'date': fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}), 'user' : fields.char('User Name', size=256, required=True, readonly=True, states={'draft':[('readonly',False)]}), 'password' : fields.char('Password', size=1024, invisible=True, required=True, readonly=True, states={'draft':[('readonly',False)]}), 'note': fields.text('Description'), @@ -292,17 +293,18 @@ class email_server(osv.osv): else: logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_new is not define in model %s' % (model_pool._name)) return False - -# for attactment in attachents or []: -# data_attach = { -# 'name': attactment, -# 'datas':binascii.b2a_base64(str(attachents.get(attactment))), -# 'datas_fname': attactment, -# 'description': 'Mail attachment', -# 'res_model': server.object_id.model, -# 'res_id': res_id, -# } -# self.pool.get('ir.attachment').create(cr, uid, data_attach) + + if server.attach: + for attactment in attachents or []: + data_attach = { + 'name': attactment, + 'datas':binascii.b2a_base64(str(attachents.get(attactment))), + 'datas_fname': attactment, + 'description': 'Mail attachment', + 'res_model': server.object_id.model, + 'res_id': res_id, + } + self.pool.get('ir.attachment').create(cr, uid, data_attach) if server.action_id: action_pool = self.pool.get('ir.actions.server') diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index a3a8534b559..d457f9636f1 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -26,15 +26,15 @@ - - + + From 98df501e00ee3ced050cef92633ecc2eb683db5c Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Tue, 27 Apr 2010 20:14:13 +0530 Subject: [PATCH 05/10] [IMP]: improvement in fetchmail module bzr revid: mga@tinyerp.com-20100427144413-1y5w8db8g1ovy7uu --- addons/fetchmail/fetchmail.py | 13 +++++++++---- addons/fetchmail/fetchmail_view.xml | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 32b4ade2d27..3639decf3dc 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -321,10 +321,15 @@ class email_server(osv.osv): his_id = history_pool.create(cr, uid, res) return res_id - - def __fetch_mail(self, cr, uid, ids, context={}): - sendmail_thread = threading.Thread(target=self.fetch_mail, args=(cr, uid, ids)) - sendmail_thread.start() + + def set_draft(self, cr, uid, ids, context={}): + self.write(cr, uid, ids , {'state':'draft'}) + return True + + def button_fetch_mail(self, cr, uid, ids, context={}): + self.fetch_mail(cr, uid, ids) +# sendmail_thread = threading.Thread(target=self.fetch_mail, args=(cr, uid, ids)) +# sendmail_thread.start() return True def _fetch_mails(self, cr, uid, ids=False, context={}): diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index d457f9636f1..ea08706b62d 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -58,7 +58,8 @@ -