Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[FIX] Bug when using OpenERP v6 #19

Merged
merged 1 commit into from

2 participants

@and3p

"report.interface.register_all = new_register_all" is not gonna work cuz
method "register_all" was changed in Openerp V6.0 (see 6.0/revision/2803 in
their bazaar repo). Therefore after server restart after new object creation, and e-mail won't be registered.

Andrius Preimantas Related bug: #17.
Valid commit
44d5379
@sharoonthomas sharoonthomas merged commit a8569d3 into openlabs:dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 9, 2012
  1. Related bug: #17.

    Andrius Preimantas authored
    Valid commit
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 32 deletions.
  1. +23 −32 template.py
View
55 template.py
@@ -64,6 +64,7 @@
_("Django templates not installed")
)
+import poweremail_engines
import tools
import report
import pooler
@@ -85,38 +86,33 @@ def send_on_write(self, cr, uid, ids, vals, context=None):
return result
-# This is an ugly hack to ensure that send_on_create and send_on_write are
-# initialized when the server is started. Note there's a small time window
-# between when the pool is available and when this function is called which
-# may mean allow creating/writing objects without an e-mail being sent.
-
-class report_xml(osv.osv):
-
- _inherit= 'ir.actions.report.xml'
-
+class actions(osv.osv):
+ _name = 'ir.actions.report.xml'
+ _inherit = 'ir.actions.report.xml'
+
def register_all(self, cr):
- res = super(report_xml, self).register_all(cr)
- pool = pooler.get_pool(cr.dbname)
- if not 'poweremail.templates' in pool.obj_list():
- return res
+ value = super(actions, self).register_all(cr)
+ if not 'poweremail.templates' in self.pool.obj_list():
+ return value
+
cr.execute("""
- SELECT
- pt.id,
- im.model,
- pt.send_on_create,
- pt.send_on_write
- FROM
- poweremail_templates pt,
- ir_model im
- WHERE
- pt.object_name = im.id
+ SELECT
+ pt.id,
+ im.model,
+ pt.send_on_create,
+ pt.send_on_write
+ FROM
+ poweremail_templates pt,
+ ir_model im
+ WHERE
+ pt.object_name = im.id
""")
for record in cr.fetchall():
id = record[0]
model = record[1]
soc = record[2]
sow = record[3]
- obj = pool.get(model)
+ obj = self.pool.get(model)
if not obj:
continue
if hasattr(obj, 'old_create'):
@@ -133,10 +129,8 @@ def register_all(self, cr):
obj.template_id = id
obj.old_write = obj.write
obj.write = types.MethodType(send_on_write, obj, osv.osv)
-
- return res
-
-report_xml()
+ return value
+actions()
def get_value(cursor, user, recid, message=None, template=None, context=None):
"""
@@ -953,10 +947,7 @@ def generate_mail(self,
if template.use_filter and template.filter:
filtered_record_ids=[]
for record in self.pool.get(template.object_name.model).browse(cursor, user, record_ids, context=context):
- if safe_eval(template.filter, {'o':record, 'self':self,
- 'cr':cursor,
- 'context':context,
- 'uid': user}):
+ if safe_eval(template.filter, {'o':record, 'self':self, 'cr':cursor, 'context':context}):
filtered_record_ids.append(record.id)
record_ids=filtered_record_ids
Something went wrong with that request. Please try again.