Skip to content

Commit c3d8777

Browse files
author
Sharoon Thomas
committed
[IMP]Back to html widget according to community opinion, [FIX]The server action condition is now evaluated
1 parent d7f2ee4 commit c3d8777

File tree

3 files changed

+299
-236
lines changed

3 files changed

+299
-236
lines changed

poweremail_mailbox_view.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<field name="pem_body_text" nolabel="1" colspan="4" select="1"/>
3535
</page>
3636
<page string="Body (HTML-Web Client Only)">
37-
<field name="pem_body_html" nolabel="1" colspan="4" />
37+
<field name="pem_body_html" nolabel="1" colspan="4" widget="text_html"/>
3838
<!--<label string="Note: HTML body can't be edited with GTK desktop client." colspan="4"/>
3939
--></page>
4040

poweremail_serveraction.py

+47-19
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,75 @@
2424
#########################################################################
2525
#__author__="sharoon"
2626
#__date__ ="$4 Aug, 2009 1:47:16 PM$"
27-
from osv import fields,osv
27+
from osv import fields, osv
2828
import netsvc
2929
from tools.translate import _
3030

3131
class actions_server(osv.osv):
3232
_inherit = 'ir.actions.server'
3333
_description = 'Server action with Power Email update'
3434
_columns = {
35-
'state': fields.selection([
36-
('poweremail','Power Email'),
37-
('client_action','Client Action'),
38-
('dummy','Dummy'),
39-
('loop','Iteration'),
40-
('code','Python Code'),
41-
('trigger','Trigger'),
42-
('email','Email'),
43-
('sms','SMS'),
44-
('object_create','Create Object'),
45-
('object_write','Write Object'),
46-
('other','Multi Actions'),
47-
], 'Action Type', required=True, size=32, help="Type of the Action that is to be executed"),
48-
'poweremail_template':fields.many2one('poweremail.templates','Template',ondelete='cascade')#In view customize such that domain('object_name','=',model_id)
35+
'state': fields.selection(
36+
[
37+
('poweremail', 'Power Email'),
38+
('client_action', 'Client Action'),
39+
('dummy', 'Dummy'),
40+
('loop', 'Iteration'),
41+
('code', 'Python Code'),
42+
('trigger', 'Trigger'),
43+
('email', 'Email'),
44+
('sms', 'SMS'),
45+
('object_create', 'Create Object'),
46+
('object_write', 'Write Object'),
47+
('other', 'Multi Actions'),
48+
], 'Action Type',
49+
required=True, size=32,
50+
help="Type of the Action that is to be executed"),
51+
'poweremail_template':fields.many2one(
52+
'poweremail.templates',
53+
'Template',
54+
ondelete='cascade')
4955
}
5056

5157
def run(self, cr, uid, ids, context=None):
52-
print cr,uid,ids,context
58+
"""
59+
Crap code inherited from Server Actions
60+
TODO:
61+
Improve quality and check if it affects
62+
Looks like var names are important in the call
63+
"""
5364
if context is None:
5465
context = {}
5566
logger = netsvc.Logger()
56-
logger.notifyChannel('Server Action', netsvc.LOG_INFO, 'Started Server Action with Power Email update')
67+
logger.notifyChannel(
68+
'Server Action',
69+
netsvc.LOG_INFO,
70+
'Started Server Action with Power Email update')
5771

5872
for action in self.browse(cr, uid, ids, context):
59-
if action.state=='poweremail':
73+
obj_pool = self.pool.get(action.model_id.model)
74+
obj = obj_pool.browse(cr, uid, context['active_id'], context=context)
75+
cxt = {
76+
'context':context,
77+
'object': obj,
78+
'time':time,
79+
'cr': cr,
80+
'pool' : self.pool,
81+
'uid' : uid
82+
}
83+
expr = eval(str(action.condition), cxt)
84+
if not expr:
85+
continue
86+
87+
if action.state == 'poweremail':
6088
if not action.poweremail_template:
6189
raise osv.except_osv(_('Error'), _("Please specify an template to use for auto email in poweremail !"))
6290
templ_id = action.poweremail_template.id
6391

6492
self.pool.get('poweremail.templates').generate_mail(cr, uid, templ_id, [context['active_id']], context)
6593
return False
6694
else:
67-
return super(actions_server,self).run(cr, uid, ids, context)
95+
return super(actions_server, self).run(cr, uid, ids, context)
6896
actions_server()
6997

7098
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

0 commit comments

Comments
 (0)