[IMP]: base_action_rule: Improvement for computing regex on history and number of history

bzr revid: rpa@tinyerp.com-20100709115422-hu6s5adz77qpzvk5
This commit is contained in:
rpa (Open ERP) 2010-07-09 17:24:22 +05:30
parent 233a39e3cb
commit 86f8d9bc64
3 changed files with 24 additions and 2 deletions

View File

@ -105,7 +105,9 @@ the rule to mark CC(mail to any other person defined in actions)."),
'act_mail_to_email': fields.char('Mail to these Emails', size=128, \
help="Email-id of the persons whom mail is to be sent"),
'act_mail_body': fields.text('Mail body', help="Content of mail"),
'regex_name': fields.char('Regular Expression on Model Name', size=128),
'regex_name': fields.char('Regex on Resource Name', size=128, help="Regular expression for mathching name of the resource\
\ne.g.: urgent.* will search for records having name starting with urgent\
\nNote: This is case sensitive search."),
'server_action_id': fields.many2one('ir.actions.server', 'Server Action', help="Describes the action name.\neg:on which object which action to be taken on basis of which condition"),
'filter_id':fields.many2one('ir.filters', 'Filter', required=False),
'domain':fields.char('Domain', size=124, required=False, readonly=False),

View File

@ -24,7 +24,7 @@
<page string="Conditions">
<group col="2" colspan="2" name="model">
<separator colspan="4" string="Conditions on Model Fields"/>
<field name="regex_name" string="Regex on Model Name" colspan="2"/>
<field name="regex_name" colspan="2"/>
<field name="trg_user_id"/>
</group>
<group col="2" colspan="2" name="partner">

View File

@ -80,6 +80,26 @@ this if you want the rule to send an email to the partner."),
if hasattr(obj, 'categ_id'):
ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==obj.categ_id.id)
#Cheking for history
regex = action.regex_history
result_history = True
if regex:
res = False
ptrn = re.compile(str(regex))
for history in obj.message_ids:
_result = ptrn.search(str(history.name))
if _result:
res = True
break
result_history = res
ok = ok and (not regex or result_history)
res_count = True
if action.trg_max_history:
res_count = False
if len(obj.message_ids) >= action.trg_max_history:
res_count = True
ok = ok and res_count
return ok
def do_action(self, cr, uid, action, model_obj, obj, context={}):