71
71
def send_on_create(self, cr, uid, vals, context=None):
72
72
id = self.old_create(cr, uid, vals, context)
73
template = self.pool.get('poweremail.templates').browse(cr, uid, self.template_id, context)
74
# Ensure it's still configured to send on create
75
if template.send_on_create:
76
self.pool.get('poweremail.templates').generate_mail(cr, uid, self.template_id, [id], context)
73
templates = self.pool.get('poweremail.templates').browse(cr, uid, self.template_ids, context)
74
for template in templates:
75
# Ensure it's still configured to send on create
76
if template.send_on_create:
77
self.pool.get('poweremail.templates').generate_mail(cr, uid, template.id, [id], context)
79
80
def send_on_write(self, cr, uid, ids, vals, context=None):
80
81
result = self.old_write(cr, uid, ids, vals, context)
81
template = self.pool.get('poweremail.templates').browse(cr, uid, self.template_id, context)
82
# Ensure it's still configured to send on write
83
if template.send_on_write:
84
self.pool.get('poweremail.templates').generate_mail(cr, uid, self.template_id, ids, context)
82
templates = self.pool.get('poweremail.templates').browse(cr, uid, self.template_ids, context)
83
for template in templates:
84
# Ensure it's still configured to send on write
85
if template.send_on_write:
86
self.pool.get('poweremail.templates').generate_mail(cr, uid, template.id, ids, context)
120
122
if hasattr(obj, 'old_write'):
121
123
obj.write = obj.old_write
122
124
del obj.old_write
125
if not hasattr(obj, 'template_ids'):
126
obj.template_ids = []
128
obj.template_ids.append(id)
125
129
obj.old_create = obj.create
126
130
obj.create = types.MethodType(send_on_create, obj, osv.osv)
132
obj.template_ids.append(id)
129
133
obj.old_write = obj.write
130
134
obj.write = types.MethodType(send_on_write, obj, osv.osv)
423
427
if hasattr(obj, 'old_write'):
424
428
obj.write = obj.old_write
425
429
del obj.old_write
430
if not hasattr(obj, 'template_ids'):
431
obj.template_ids = []
426
432
if template.send_on_create:
427
obj.template_id = template.id
433
obj.template_ids.append(template.id)
428
434
obj.old_create = obj.create
429
435
obj.create = types.MethodType(send_on_create, obj, osv.osv)
430
436
if template.send_on_write:
431
obj.template_id = template.id
437
obj.template_ids.append(template.id)
432
438
obj.old_write = obj.write
433
439
obj.write = types.MethodType(send_on_write, obj, osv.osv)
946
952
if template.use_filter and template.filter:
947
953
filtered_record_ids=[]
948
954
for record in self.pool.get(template.object_name.model).browse(cursor, user, record_ids, context=context):
949
if safe_eval(template.filter, {'o':record, 'self':self, 'cr':cursor, 'context':context}):
955
if safe_eval(template.filter,
956
{'o':record, 'self':self, 'cr':cursor, 'context':context, 'uid': user}):
950
957
filtered_record_ids.append(record.id)
951
958
record_ids=filtered_record_ids