[IMP]: base_action_rule: Improvement in view, Added missing changes back

bzr revid: rpa@tinyerp.com-20100511085948-qkgstav1qlouh84y
This commit is contained in:
rpa (Open ERP) 2010-05-11 14:29:48 +05:30
parent ba6b04d599
commit b3fbffbcfb
3 changed files with 53 additions and 48 deletions

View File

@ -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 users 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
@ -72,7 +63,7 @@ class base_action_rule(osv.osv):
return [('', '')]
_columns = {
'name': fields.many2one('ir.model', 'Model', required=True),
'name': fields.many2one('ir.model', 'Object', required=True),
'max_level': fields.integer('Max Level', help='Specifies maximum level.'),
'create_date': fields.datetime('Create Date', readonly=1),
'active': fields.boolean('Active', help="If the active field is set to true,\
@ -100,13 +91,10 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
'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"),
@ -127,6 +115,7 @@ the rule to mark CC(mail to any other person defined in actions)."),
'regex_name': fields.char('Regular Expression on Model Name', size=128),
'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),
}
_defaults = {
@ -138,8 +127,11 @@ the rule to mark CC(mail to any other person defined in actions)."),
'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 """
@ -198,6 +190,10 @@ the rule to mark CC(mail to any other person defined in actions)."),
@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'):
@ -215,10 +211,6 @@ the rule to mark CC(mail to any other person defined in actions)."),
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:
@ -256,10 +248,6 @@ the rule to mark CC(mail to any other person defined in actions)."),
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:
@ -294,7 +282,9 @@ the rule to mark CC(mail to any other person defined in actions)."),
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

View File

@ -16,7 +16,9 @@
<form string="Action Rule">
<field name="name" select="1"/>
<field name="active"/>
<field name="sequence"/>
<field name="max_level" />
<field name="domain" colspan="4"/>
<notebook colspan="4">
<page string="Conditions">
<group col="2" colspan="2" name="model">
@ -34,46 +36,46 @@
<field name="trg_state_from"/>
<field name="trg_state_to"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Conditions on Priority Range"/>
<field name="trg_priority_from"/>
<field name="trg_priority_to"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Conditions on Timing"/>
<field name="trg_date_type"/>
<label align="1.0" string="Delay After Trigger Date:"/>
<group col="2" colspan="1">
<field name="trg_date_range" nolabel="1"/>
<group col="3" colspan="2" attrs="{'invisible': [('trg_date_type', '=', 'none')]}">
<field name="trg_date_range" string="Delay After Trigger Date"/>
<field name="trg_date_range_type" nolabel="1"/>
</group>
</group>
</group>
<separator colspan="4" string="Note"/>
<label align="0.0" string="The rule use a AND operator. The model must match all non empty fields so that the rule execute the action described in the 'Actions' tab." colspan="4"/>
<label align="0.0" colspan="4" width="900"
string="The rule use a AND operator. The model must match all non empty fields so that the rule execute the action described in the 'Actions' tab." />
</page>
<page string="Actions">
<separator colspan="4" string="Fields to Change"/>
<field name="act_user_id"/>
<field name="act_state"/>
<field name="act_priority"/>
<separator colspan="4" string="E-Mail Reminders (includes the content of the object)"/>
<field name="act_remind_partner"/>
<field name="act_remind_attach"/>
<field name="act_remind_user"/>
<group col="2" colspan="2" attrs="{'invisible': [('act_remind_user','=',False)]}">
<field name="act_reply_to" attrs="{'required':[('act_remind_user','=',True)]}"/>
</group>
<field colspan="4" name="act_email_cc"/>
<separator colspan="4" string="Server Action to be Triggered"/>
<field name="server_action_id"/>
<field name="filter_id"/>
</page>
<page string="E-Mail Actions">
<separator colspan="4" string="Template of Email to Send"/>
<field name="act_mail_to_user"/>
<field name="act_mail_to_watchers"/>
<field colspan="4" name="act_mail_to_email"/>
<field colspan="4" name="act_mail_body" attrs="{'required':[('act_remind_user','=',True)]}"/>
<!-- <group col="4" colspan="2">-->
<separator colspan="4" string="Template of Email to Send"/>
<field name="act_mail_to_watchers"/>
<field name="act_mail_to_user"/>
<field colspan="4" name="act_mail_to_email"/>
<!-- </group>-->
<!-- <group col="4" colspan="2">-->
<separator colspan="4" string="E-Mail Reminders (includes the content of the object)"/>
<field name="act_remind_partner"/>
<field name="act_remind_attach"/>
<field name="act_remind_user"/>
<group col="2" colspan="2" attrs="{'invisible': [('act_remind_user','=',False)]}">
<field name="act_reply_to" attrs="{'required':[('act_remind_user','=',True)]}"/>
</group>
<field colspan="4" name="act_email_cc"/>
<!-- </group>-->
<separator colspan="4" string="Mail Body"/>
<field colspan="4" name="act_mail_body" height="250"
nolabel="1" attrs="{'required':[('act_remind_user','=',True)]}" />
<separator colspan="4" string="Special Keywords to Be Used in The Body"/>
<label align="0.0" string="%%(object_id)s = Object ID" colspan="2"/>
<label align="0.0" string="%%(object_subject)s = Object subject" colspan="2"/>
@ -84,7 +86,6 @@
<label align="0.0" string="%%(object_user)s = Responsible name" colspan="2"/>
<label align="0.0" string="%%(object_user_email)s = Responsible email" colspan="2"/>
<label align="0.0" string="%%(object_user_phone)s = Responsible phone" colspan="2"/>
<label align="0.0" string="%% = The &apos;%%&apos; Character" colspan="2"/>
</page>
</notebook>
</form>
@ -100,7 +101,9 @@
<field name="arch" type="xml">
<tree string="Action Rule">
<field name="name" colspan="4"/>
<field name="sequence"/>
<field name="max_level"/>
<field name="domain"/>
</tree>
</field>
</record>

View File

@ -43,9 +43,21 @@
<field name="act_user_id" position="after">
<field name="act_section_id"/>
<field name="act_categ_id"/>
</field>
</field>
</record>
<record id="view_base_action_rule_line_form4" model="ir.ui.view">
<field name="name">base.action.rule.form4.inherit</field>
<field name="model">base.action.rule</field>
<field name="inherit_id" ref="base_action_rule.view_base_action_rule_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="act_mail_to_watchers" position="before">
<field name="act_mail_to_partner"/>
</field>
</field>
</record>
</data>
</openerp>