[IMP] base_action_rule: adapt views to new field

bzr revid: rco@openerp.com-20130301112705-hqn8wqz1l20ix2tu
This commit is contained in:
Raphael Collet 2013-03-01 12:27:05 +01:00
parent 9c21a6902a
commit 3bad12f1cf
2 changed files with 38 additions and 20 deletions

View File

@ -50,6 +50,7 @@ class base_action_rule(osv.osv):
_name = 'base.action.rule'
_description = 'Action Rules'
_order = 'sequence'
_columns = {
'name': fields.char('Rule Name', size=64, required=True),
@ -81,10 +82,10 @@ class base_action_rule(osv.osv):
ondelete='restrict',
domain="[('model_id', '=', model_id.model)]",
help="If present, this condition must be satisfied before the update of the record."),
'filter_id': fields.many2one('ir.filters', string='After Update Filter',
'filter_id': fields.many2one('ir.filters', string='Filter',
ondelete='restrict',
domain="[('model_id', '=', model_id.model)]",
help="If present, this condition must be satisfied after the update of the record."),
help="If present, this condition must be satisfied before executing the action rule."),
'last_run': fields.datetime('Last Run', readonly=1),
}
@ -93,7 +94,15 @@ class base_action_rule(osv.osv):
'trg_date_range_type': 'day',
}
_order = 'sequence'
def onchange_kind(self, cr, uid, ids, kind, context=None):
clear_fields = []
if kind == 'create':
clear_fields = ['filter_pre_id', 'trg_date_id', 'trg_date_range', 'trg_date_range_type']
elif kind == 'write':
clear_fields = ['trg_date_id', 'trg_date_range', 'trg_date_range_type']
elif kind == 'cron':
clear_fields = ['filter_pre_id']
return {'value': dict.fromkeys(clear_fields, False)}
def _filter(self, cr, uid, action, action_filter, record_ids, context=None):
""" filter the list record_ids that satisfy the action filter """

View File

@ -26,24 +26,32 @@
<notebook>
<page string="Conditions">
<group>
<group name="filter" string="Filter Condition">
<field name="filter_pre_id" domain="[('model_id','=',model), ('user_id', '=', False)]" context="{'default_model_id': model}"/>
<field name="filter_id" domain="[('model_id','=',model), ('user_id', '=', False)]" context="{'default_model_id': model}"/>
</group>
<group name="timing" string="Timer">
<field name="trg_date_id"/>
<label for="trg_date_range" string="Delay After Trigger Date" attrs="{'invisible': [('trg_date_id','=',False)]}"/>
<div attrs="{'invisible': [('trg_date_id','=',False)]}">
<field name="trg_date_range" class="oe_inline"/>
<field name="trg_date_range_type" class="oe_inline" attrs="{'required': [('trg_date_id','!=',False)]}"/>
</div>
</group>
<field name="kind" required="1"
on_change="onchange_kind(kind)"/>
<field name="filter_pre_id"
domain="[('model_id','=',model), ('user_id', '=', False)]"
context="{'default_model_id': model}"
attrs="{'invisible': [('kind', '!=', 'write')]}"/>
<field name="filter_id"
domain="[('model_id','=',model), ('user_id', '=', False)]"
context="{'default_model_id': model}"/>
<field name="trg_date_id"
attrs="{'invisible': [('kind', '!=', 'cron')]}"/>
<label for="trg_date_range" string="Delay After Trigger Date"
attrs="{'invisible': [('trg_date_id','=',False)]}"/>
<div attrs="{'invisible': [('trg_date_id','=',False)]}">
<field name="trg_date_range" class="oe_inline"/>
<field name="trg_date_range_type" class="oe_inline" attrs="{'required': [('trg_date_id','!=',False)]}"/>
</div>
</group>
<p class="oe_grey">
<b>Select a filter or a timer as condition.</b><br/> An action rule is checked when you create or modify the "Related Document Model". The precondition filter is checked right before the modification while the postcondition filter is checked after the modification. A precondition filter will therefore not work during a creation.<br/>
<b>To create a new filter:</b><br/>
- Go to your "Related Document Model" page and set the filter parameters in the "Search" view (Example of filter based on Leads/Opportunities: Creation Date "is equal to" 01/01/2012)<br/>
- In this same "Search" view, select the menu "Save Current Filter", enter the name (Ex: Create the 01/01/2012) and add the option "Share with all users"<br/>
<p>
Select when the action must be run, and add filters and/or timing conditions.
<br/>
In order to create a new filter:
<ul>
<li>Go to your "Related Document Model" page and set the filter parameters in the "Search" view (Example of filter based on Leads/Opportunities: Creation Date "is equal to" 01/01/2012)</li>
<li>In this same "Search" view, select the menu "Save Current Filter", enter the name (Ex: Create the 01/01/2012) and add the option "Share with all users"</li>
</ul>
The filter must therefore be available in this page.
</p>
</page>
@ -76,6 +84,7 @@
<tree string="Action Rule">
<field name="sequence"/>
<field name="name"/>
<field name="kind"/>
<field name="filter_id"/>
</tree>
</field>