From c2b5890db237a5a288cb70a5846b0e34f899354d Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 27 Apr 2010 15:49:34 +0530 Subject: [PATCH] [IMP]: base_action_rule: * Removed fields that are not in the crm.case, * Added a domain to be applied on the object, for the conditions bzr revid: rpa@tinyerp.com-20100427101934-3envktbthc7w3n3o --- addons/base_action_rule/base_action_rule.py | 47 +++++-------------- .../base_action_rule_view.xml | 14 +++--- addons/crm/crm_action_rule.py | 23 ++++----- 3 files changed, 31 insertions(+), 53 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 6eb45172dbc..77446c633ee 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -44,15 +44,6 @@ class base_action_rule(osv.osv): return self.state_get(cr, uid, context=context) - def _priority_get(self, cr, uid, context={}): - """ Get Priority - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values """ - - return self.priority_get(cr, uid, context=context) - def state_get(self, cr, uid, context={}): """ Get State @param self: The object pointer @@ -62,15 +53,6 @@ class base_action_rule(osv.osv): return [('','')] - def priority_get(self, cr, uid, context={}): - """ Get Priority - @param self: The object pointer - @param cr: the current row, from the database cursor, - @param uid: the current user’s ID for security checks, - @param context: A standard dictionary for contextual values """ - - return [('','')] - _columns = { 'name': fields.many2one('ir.model', 'Model', required=True), 'max_level': fields.integer('Max Level', help='Specifies maximum level.'), @@ -79,7 +61,6 @@ class base_action_rule(osv.osv): it will allow you to hide the rule without removing it."), 'sequence': fields.integer('Sequence', help="Gives the sequence order when\ displaying a list of rules."), - 'trg_date_type': fields.selection([ ('none','None'), ('create','Creation Date'), @@ -100,13 +81,10 @@ class base_action_rule(osv.osv): 'trg_partner_categ_id': fields.many2one('res.partner.category', 'Partner Category'), 'trg_state_from': fields.selection(_state_get, 'State', size=16), 'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16), - 'trg_priority_from': fields.selection(_priority_get, 'Minimum Priority'), - 'trg_priority_to': fields.selection(_priority_get, 'Maximum Priority'), 'act_method': fields.char('Call Object Method', size=64), 'act_user_id': fields.many2one('res.users', 'Set responsible to'), 'act_state': fields.selection(_state_get, 'Set state to', size=16), - 'act_priority': fields.selection(_priority_get, 'Set priority to'), 'act_email_cc': fields.char('Add watchers (Cc)', size=250, help="These people\ will receive a copy of the future communication between partner and users by email"), @@ -131,6 +109,7 @@ class base_action_rule(osv.osv): 'server_action_id': fields.many2one('ir.actions.server','Server Action',help="Describes the\ action name." \ "eg:on which object which action to be taken on basis of which condition"), + 'domain':fields.char('Domain', size=124, required=False, readonly=False), } _defaults = { @@ -142,8 +121,11 @@ class base_action_rule(osv.osv): 'act_remind_partner': lambda *a: 0, 'act_remind_user': lambda *a: 0, 'act_mail_to_watchers': lambda *a: 0, + 'domain': lambda *a: '[]' } - + + _order = 'sequence' + def format_body(self, body): """ Foramat Action rule's body @param self: The object pointer """ @@ -153,7 +135,6 @@ class base_action_rule(osv.osv): def format_mail(self, obj, body): """ Foramat Mail @param self: The object pointer """ - data = { 'object_id': obj.id, 'object_subject': hasattr(obj, 'name') and obj.name or False, @@ -202,6 +183,10 @@ class base_action_rule(osv.osv): @param context: A standard dictionary for contextual values """ ok = True + if eval(action.domain): + obj_ids = obj._table.search(cr, uid, eval(action.domain), context=context) + if not obj.id in obj_ids: + ok = False if hasattr(obj, 'user_id'): ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==obj.user_id.id) if hasattr(obj, 'partner_id'): @@ -219,10 +204,6 @@ class base_action_rule(osv.osv): if state_to: ok = ok and (not action.trg_state_to or action.trg_state_to==state_to) - if hasattr(obj, 'priority'): - ok = ok and (not action.trg_priority_from or action.trg_priority_from>=obj.priority) - ok = ok and (not action.trg_priority_to or action.trg_priority_to<=obj.priority) - reg_name = action.regex_name result_name = True if reg_name: @@ -260,10 +241,6 @@ class base_action_rule(osv.osv): obj.categ_id = action.act_categ_id write['categ_id'] = action.act_categ_id.id - if hasattr(obj, 'priority') and action.act_priority: - obj.priority = action.act_priority - write['priority'] = action.act_priority - model_obj.write(cr, uid, [obj.id], write, context) if hasattr(model_obj, 'remind_user') and action.act_remind_user: @@ -295,10 +272,11 @@ class base_action_rule(osv.osv): @param ids: List of Basic Action Rule’s IDs, @param objects: pass objects @param context: A standard dictionary for contextual values """ - if not scrit: scrit = [] - for action in self.browse(cr, uid, ids): + cr.execute("select id from base_action_rule order by sequence") + rule_ids = map(lambda x: x[0], cr.fetchall()) + for action in self.browse(cr, uid, rule_ids): level = action.max_level if not level: break @@ -342,7 +320,6 @@ class base_action_rule(osv.osv): model_obj.write(cr, uid, [obj.id], {'date_action_next': dt}, context) else: ok = action.trg_date_type=='none' - if ok: self.do_action(cr, uid, action, model_obj, obj, context) break diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml index 72cf3e5a9fb..f7a476fd09e 100644 --- a/addons/base_action_rule/base_action_rule_view.xml +++ b/addons/base_action_rule/base_action_rule_view.xml @@ -16,7 +16,9 @@
+ + @@ -34,11 +36,6 @@ - - - - - @@ -55,7 +52,6 @@ - @@ -72,7 +68,9 @@ - + +