From 3bad12f1cfe64f271afa350918aaefb9c01306b7 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 1 Mar 2013 12:27:05 +0100 Subject: [PATCH] [IMP] base_action_rule: adapt views to new field bzr revid: rco@openerp.com-20130301112705-hqn8wqz1l20ix2tu --- addons/base_action_rule/base_action_rule.py | 15 +++++-- .../base_action_rule_view.xml | 43 +++++++++++-------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index ba3ef572505..176c2bffe28 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -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 """ diff --git a/addons/base_action_rule/base_action_rule_view.xml b/addons/base_action_rule/base_action_rule_view.xml index 25ea4048bad..131b5cef08b 100644 --- a/addons/base_action_rule/base_action_rule_view.xml +++ b/addons/base_action_rule/base_action_rule_view.xml @@ -26,24 +26,32 @@ - - - - - - - + + + + + -

- Select a filter or a timer as condition.
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.
- To create a new filter:
- - 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)
- - 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"
+

+ Select when the action must be run, and add filters and/or timing conditions. +
+ In order to create a new filter: +

    +
  • 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)
  • +
  • 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"
  • +
The filter must therefore be available in this page.

@@ -76,6 +84,7 @@ +