Arnaud Pineux (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-base-action-rule-api into 
lp:openobject-addons.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-base-action-rule-api/+merge/136603

Base Action Rule has been changed.
- The conditions can only be done by precondition filter and postcondition 
filter.
- Base action rule catch every write and create so:
   - Precondition filter is tested before the write
   - Postcondition filter is tested after the write or create.
There are also tests for that module
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-base-action-rule-api/+merge/136603
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-base-action-rule-api.
=== modified file 'base_action_rule/__init__.py'
--- base_action_rule/__init__.py	2011-01-14 00:11:01 +0000
+++ base_action_rule/__init__.py	2012-11-28 09:48:26 +0000
@@ -20,5 +20,6 @@
 ##############################################################################
 
 import base_action_rule
+import test_models
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'base_action_rule/base_action_rule.py'
--- base_action_rule/base_action_rule.py	2012-11-06 15:04:31 +0000
+++ base_action_rule/base_action_rule.py	2012-11-28 09:48:26 +0000
@@ -23,6 +23,7 @@
 from datetime import timedelta
 import re
 import time
+from openerp import SUPERUSER_ID
 
 from osv import fields, osv, orm
 from tools.translate import _
@@ -54,7 +55,7 @@
 
     def state_get(self, cr, uid, context=None):
         """ Get State """
-        return [('', '')]
+        return [('', ''), ('na','N/A (No previous state)')]
 
     def priority_get(self, cr, uid, context=None):
         """ Get Priority """
@@ -86,8 +87,8 @@
         'trg_user_id':  fields.many2one('res.users', 'Responsible'),
         'trg_partner_id': fields.many2one('res.partner', 'Partner'),
         'trg_partner_categ_id': fields.many2one('res.partner.category', 'Partner Category'),
-        'trg_state_from': fields.selection(_state_get, 'Status', size=16),
-        'trg_state_to': fields.selection(_state_get, 'Button Pressed', size=16),
+        'trg_state_from': fields.selection(_state_get, 'and previously was', size=16),
+        'trg_state_to': fields.selection(_state_get, 'Status changes to', size=16),
 
         'act_user_id': fields.many2one('res.users', 'Set Responsible to'),
         'act_state': fields.selection(_state_get, 'Set State to', size=16),
@@ -96,7 +97,8 @@
 \ne.g.: 'urgent.*' will search for records having name starting with the string 'urgent'\
 \nNote: This is case sensitive search."),
         'server_action_ids': fields.one2many('ir.actions.server', 'action_rule_id', 'Server Action', help="Define Server actions.\neg:Email Reminders, Call Object Service, etc.."), #TODO: set domain [('model_id','=',model_id)]
-        'filter_id':fields.many2one('ir.filters', 'Filter', required=False), #TODO: set domain [('model_id','=',model_id.model)]
+        'filter_id':fields.many2one('ir.filters', 'Precondition Filter', required=False), #TODO: set domain [('model_id','=',model_id.model)]
+        'filter_post_id': fields.many2one('ir.filters', 'Postcondition Filter', required=False),
         'last_run': fields.datetime('Last Run', readonly=1),
     }
 
@@ -109,7 +111,7 @@
     _order = 'sequence'
 
 
-    def post_action(self, cr, uid, ids, model, context=None):
+    def post_action(self, cr, uid, ids, model, precondition_ok=None, context=None):
         # Searching for action rules
         cr.execute("SELECT model.model, rule.id  FROM base_action_rule rule \
                         LEFT JOIN ir_model model on (model.id = rule.model_id) \
@@ -117,11 +119,11 @@
         res = cr.fetchall()
         # Check if any rule matching with current object
         for obj_name, rule_id in res:
-            obj = self.pool.get(obj_name)
+            model_pool = self.pool.get(obj_name)
             # If the rule doesn't involve a time condition, run it immediately
             # Otherwise we let the scheduler run the action
             if self.browse(cr, uid, rule_id, context=context).trg_date_type == 'none':
-                self._action(cr, uid, [rule_id], obj.browse(cr, uid, ids, context=context), context=context)
+                self._action(cr, uid, [rule_id], model_pool.browse(cr, uid, ids, context=context), precondition_ok=precondition_ok, context=context)
         return True
 
     def _create(self, old_create, model, context=None):
@@ -133,8 +135,17 @@
             if context is None:
                 context = {}
             new_id = old_create(cr, uid, vals, context=context)
+            #As it is a new record, we can assume that the precondition is true for every filter. 
+            #(There is nothing before the create so no condition)
+            precondition_ok = {}
+            precondition_ok[new_id] = {}
+            for action in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context):
+                if action.filter_id:
+                    precondition_ok[new_id][action.id] = False
+                else:
+                    precondition_ok[new_id][action.id] = True
             if not context.get('action'):
-                self.post_action(cr, uid, [new_id], model, context=context)
+                self.post_action(cr, uid, [new_id], model, precondition_ok=precondition_ok, context=context)
             return new_id
         return wrapper
 
@@ -144,39 +155,66 @@
         `post_action`, in that order.
         """
         def wrapper(cr, uid, ids, vals, context=context):
+            old_records = {}
             if context is None:
                 context = {}
             if isinstance(ids, (str, int, long)):
                 ids = [ids]
+            model_pool = self.pool.get(model)
+            # We check for the pre-filter. We must apply it before the write
+            precondition_ok = {}
+            for id in ids:
+                precondition_ok[id] = {}
+                for action in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context):
+                    precondition_ok[id][action.id] = True
+                    if action.filter_id and action.model_id.model == action.filter_id.model_id:
+                        ctx = dict(context)
+                        ctx.update(eval(action.filter_id.context))
+                        obj_ids = []
+                        if self.pool.get(action.model_id.model)!=None:
+                            obj_ids = self.pool.get(action.model_id.model).search(cr, uid, eval(action.filter_id.domain), context=ctx)
+                        precondition_ok[id][action.id] = id in obj_ids
             old_write(cr, uid, ids, vals, context=context)
             if not context.get('action'):
-                self.post_action(cr, uid, ids, model, context=context)
+                self.post_action(cr, uid, ids, model, precondition_ok=precondition_ok, context=context)
             return True
         return wrapper
 
-    def _register_hook(self, cr, uid, ids, context=None):
-        """
-        Wrap every `create` and `write` methods of the models specified by
-        the rules (given by `ids`).
-        """
-        for action_rule in self.browse(cr, uid, ids, context=context):
+    def _register_hook(self, cr):
+        """
+        Wrap every `create` and `write` methods of the models specified by
+        the rules (given by `ids`).
+        """
+        ids = self.search(cr,SUPERUSER_ID,[])
+        return self._register_hook_(cr,SUPERUSER_ID,ids,context=None)
+
+    def _register_hook_(self, cr, uid, ids, context=None):
+        """
+        Wrap every `create` and `write` methods of the models specified by
+        the rules (given by `ids`).
+        """
+        reg_ids = []
+        if not isinstance(ids, list):
+            reg_ids.append(ids)
+        else:
+            reg_ids.extend(ids)
+        for action_rule in self.browse(cr, uid, reg_ids, context=context):
             model = action_rule.model_id.model
             obj_pool = self.pool.get(model)
             if not hasattr(obj_pool, 'base_action_ruled'):
-                obj_pool.create = self._create(obj_pool.create, model, context=context)
-                obj_pool.write = self._write(obj_pool.write, model, context=context)
+                obj_pool.create = self._create(obj_pool.create, model, context=None)
+                obj_pool.write = self._write(obj_pool.write, model, context=None)
                 obj_pool.base_action_ruled = True
-
         return True
 
     def create(self, cr, uid, vals, context=None):
         res_id = super(base_action_rule, self).create(cr, uid, vals, context=context)
-        self._register_hook(cr, uid, [res_id], context=context)
+        self._register_hook_(cr, uid, res_id,context=context)
         return res_id
 
     def write(self, cr, uid, ids, vals, context=None):
         super(base_action_rule, self).write(cr, uid, ids, vals, context=context)
-        self._register_hook(cr, uid, ids, context=context)
+        self._register_hook_(cr, uid, ids, context=context)
         return True
 
     def _check(self, cr, uid, automatic=False, use_new_cursor=False, \
@@ -185,7 +223,7 @@
         This Function is call by scheduler.
         """
         rule_ids = self.search(cr, uid, [], context=context)
-        self._register_hook(cr, uid, rule_ids, context=context)
+        self._register_hook_(cr, uid, rule_ids, context=context)
         if context is None:
             context = {}
         for rule in self.browse(cr, uid, rule_ids, context=context):
@@ -242,15 +280,15 @@
                         
                         
 
-    def do_check(self, cr, uid, action, obj, context=None):
+    def do_check(self, cr, uid, action, obj, precondition_ok=True, context=None):
         """ check Action """
         if context is None:
             context = {}
-        ok = True
-        if action.filter_id and action.model_id.model == action.filter_id.model_id:
+        ok = precondition_ok
+        if action.filter_post_id and action.model_id.model == action.filter_post_id.model_id:
             ctx = dict(context)
-            ctx.update(eval(action.filter_id.context))
-            obj_ids = self.pool.get(action.model_id.model).search(cr, uid, eval(action.filter_id.domain), context=ctx)
+            ctx.update(eval(action.filter_post_id.context))
+            obj_ids = self.pool.get(action.model_id.model).search(cr, uid, eval(action.filter_post_id.domain), context=ctx)
             ok = ok and obj.id in obj_ids
         if getattr(obj, 'user_id', False):
             ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==obj.user_id.id)
@@ -263,14 +301,6 @@
                     (action.trg_partner_categ_id.id in map(lambda x: x.id, obj.partner_id.category_id or []))
                 )
             )
-        state_to = context.get('state_to', False)
-        state = getattr(obj, 'state', False)
-        if state:
-            ok = ok and (not action.trg_state_from or action.trg_state_from==state)
-        if state_to:
-            ok = ok and (not action.trg_state_to or action.trg_state_to==state_to)
-        elif action.trg_state_to:
-            ok = False
         reg_name = action.regex_name
         result_name = True
         if reg_name:
@@ -312,21 +342,20 @@
                 model_obj.message_subscribe(cr, uid, [obj.id], new_followers, context=context)
         return True
 
-    def _action(self, cr, uid, ids, objects, scrit=None, context=None):
+    def _action(self, cr, uid, ids, objects, scrit=None, precondition_ok=None, context=None):
         """ Do Action """
         if context is None:
             context = {}
-
         context.update({'action': True})
-        if not scrit:
-            scrit = []
         if not isinstance(objects, list):
             objects = [objects]
         for action in self.browse(cr, uid, ids, context=context):
             for obj in objects:
-                if self.do_check(cr, uid, action, obj, context=context):
+                ok = True
+                if precondition_ok!=None:
+                    ok = precondition_ok[obj.id][action.id]
+                if self.do_check(cr, uid, action, obj, precondition_ok=ok, context=context):
                     self.do_action(cr, uid, action, obj, context=context)
-
         context.update({'action': False})
         return True
 

=== modified file 'base_action_rule/base_action_rule_view.xml'
--- base_action_rule/base_action_rule_view.xml	2012-11-16 15:31:01 +0000
+++ base_action_rule/base_action_rule_view.xml	2012-11-28 09:48:26 +0000
@@ -15,36 +15,31 @@
                     <sheet>
                         <group col="4">
                             <field name="name"/>
+                            <field name="active"/>
                             <field name="model_id"/>
-                            <field name="filter_id" domain="[('model_id','=',model), ('user_id', '=', False)]" context="{'default_model_id': model}"/>
-                            <field name="sequence"/>
-                            <field name="active"/>
                             <field name="model" invisible="1"/>
+                            <field name="sequence" invisible="1"/>
                         </group>
                         <notebook>
                             <page string="Conditions">
+                                <p class="oe_grey">
+                                    Select a filter or a timer as condition.<br/>
+                                    To create a new filter,<br/>
+                                    - Go to your Model's page and set the filter parameters in the "Search" view<br/>
+                                    - In this same "Search" view, select the menu "Save Current Filter", enter the name and add the option "Share with all users"<br/>
+                                    The filter must therefore be available in this page.
+                                </p>
                                 <group>
-                                    <group name="model" string="Conditions on Model Fields">
-                                        <field name="regex_name"/>
-                                        <field name="trg_user_id"/>
-                                    </group>
-                                    <group name="partner" string="Conditions on Model Partner">
-                                        <field name="trg_partner_id"/>
-                                        <field name="trg_partner_categ_id"/>
-                                    </group>
-                                    <group name="state" string="Conditions on Status">
-                                        <field name="trg_state_from"/>
-                                        <field name="trg_state_to"/>
-                                    </group>
-                                    <group name="timing" string="Conditions on Timing">
+                                    <group name="filter" string="Filter Condition">
+                                        <field name="filter_id" domain="[('model_id','=',model), ('user_id', '=', False)]" context="{'default_model_id': model}"/>
+                                        <field name="filter_post_id" domain="[('model_id','=',model), ('user_id', '=', False)]" context="{'default_model_id': model}"/>
+                                    </group>
+                                    <group name="timing" string="Timer">
                                         <field name="trg_date_type"/>
                                         <field name="trg_date_range" string="Delay After Trigger Date" attrs="{'invisible': [('trg_date_type', '=', 'none')]}"/>
                                         <field name="trg_date_range_type" attrs="{'invisible': [('trg_date_type', '=', 'none')]}"/>
                                     </group>
                                 </group>
-                                <group string="Note">
-                                    <label string="The rule uses the AND operator. The model must match all non-empty fields so that the rule executes the action  described in the 'Actions' tab." />
-                                </group>
                             </page>
                             <page string="Actions">
                                 <group name="action_followers">
@@ -63,7 +58,6 @@
                                         </tree>
                                     </field>
                                 </group>
-                                
                            </page>
                        </notebook>
                     </sheet>

=== added file 'base_action_rule/test_models.py'
--- base_action_rule/test_models.py	1970-01-01 00:00:00 +0000
+++ base_action_rule/test_models.py	2012-11-28 09:48:26 +0000
@@ -0,0 +1,32 @@
+from osv import osv, fields
+
+AVAILABLE_STATES = [
+    ('draft', 'New'),
+    ('cancel', 'Cancelled'),
+    ('open', 'In Progress'),
+    ('pending', 'Pending'),
+    ('done', 'Closed')
+]
+
+class lead_test(osv.Model):
+    _name = "base.action.rule.lead.test"
+
+    _columns = {
+        'name': fields.char('Subject', size=64, required=True, select=1),
+        'user_id': fields.many2one('res.users', 'Responsible'),
+        'state': fields.selection(AVAILABLE_STATES, string="Status", readonly=True),
+        'active': fields.boolean('Active', required=False),
+        'partner_id': fields.many2one('res.partner', 'Partner', ondelete='set null'),
+        'date_action_last': fields.datetime('Last Action', readonly=1),
+    }
+
+    _defaults = {
+        'state' : 'draft',
+        'active' : True,
+    }
+
+    def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, **kwargs):
+        pass
+
+    def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, context=None):
+        pass

=== added directory 'base_action_rule/tests'
=== added file 'base_action_rule/tests/__init__.py'
--- base_action_rule/tests/__init__.py	1970-01-01 00:00:00 +0000
+++ base_action_rule/tests/__init__.py	2012-11-28 09:48:26 +0000
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Business Applications
+#    Copyright (c) 2012-TODAY OpenERP S.A. <http://openerp.com>
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from . import base_action_rule_test
+
+checks = [
+    base_action_rule_test,
+]
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'base_action_rule/tests/base_action_rule_test.py'
--- base_action_rule/tests/base_action_rule_test.py	1970-01-01 00:00:00 +0000
+++ base_action_rule/tests/base_action_rule_test.py	2012-11-28 09:48:26 +0000
@@ -0,0 +1,142 @@
+import tools
+from openerp.tests import common
+from .. import test_models
+
+class base_action_rule_test(common.TransactionCase):
+
+    def setUp(self):
+        """*****setUp*****"""
+        super(base_action_rule_test, self).setUp()
+        cr, uid = self.cr, self.uid
+        self.demo_user = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'user_demo')
+        self.admin_user = self.registry('ir.model.data').get_object_reference(cr, uid, 'base', 'user_admin')
+
+    def create_filter_done(self, cr, uid, context=None):
+        filter_pool = self.registry('ir.filters')
+        return filter_pool.create(cr, uid, {
+            'name': "Lead is in done state",
+            'is_default': False,
+            'model_id': 'base.action.rule.lead.test',
+            'domain' : "[('state','=','done')]",
+            }, context=context)
+
+    def create_filter_draft(self, cr, uid, context=None):
+        filter_pool = self.registry('ir.filters')
+        return filter_pool.create(cr, uid, {
+            'name': "Lead is in draft state",
+            'is_default': False,
+            'model_id': "base.action.rule.lead.test",
+            'domain' : "[('state','=','draft')]",
+            }, context=context)
+
+    def create_lead_test_1(self, cr, uid, context=None):
+        """
+            Create a new lead_test
+        """
+        lead_pool = self.registry('base.action.rule.lead.test')
+        return lead_pool.create(cr, uid, {
+            'name': "Lead Test 1",
+            'user_id': self.admin_user[1],
+            }, context=context)
+
+    def create_rule(self, cr, uid, filter_id=None, filter_post_id=None, context=None):
+        """
+            The "Rule 1" says that when a lead goes to the 'draft' state, the responsible for that lead changes to "demo_user"
+        """
+        self.action_pool = self.registry('base.action.rule')
+        return self.action_pool.create(cr,uid,{
+            'name' : "Rule 1",
+            'model_id': self.registry('ir.model').search(cr, uid, [('model','=','base.action.rule.lead.test')], context=context)[0],
+            'active' : 1,
+            'trg_date_type' : 'none',
+            'filter_post_id' : filter_post_id,
+            'filter_id' : filter_id,
+            'act_user_id': self.demo_user[1],
+            }, context=context)
+
+    def test_00_check_to_state_draft_pre(self):
+        """
+        Check that a new record (with state = draft) doesn't change its responsible when there is a precondition filter which check that the state is draft.
+        """
+        cr, uid = self.cr, self.uid
+        context = {}
+        filter_draft = self.create_filter_draft(cr, uid, context=context)
+        rule_1_id = self.create_rule(cr, uid, filter_id=filter_draft, context=context)
+        new_lead_id = self.create_lead_test_1(cr,uid,context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='draft')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+
+    def test_01_check_to_state_draft_post(self):
+        """
+        Check that a new record (with state = draft) changes its responsible when there is a postcondition filter which check that the state is draft.
+        """
+        cr, uid = self.cr, self.uid
+        context = {}
+        filter_draft = self.create_filter_draft(cr, uid, context=context)
+        rule_1_id = self.create_rule(cr, uid, filter_post_id=filter_draft, context=context)
+        new_lead_id = self.create_lead_test_1(cr,uid,context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='draft')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.demo_user[1], context=context))
+
+    def test_02_check_from_draft_to_done_with_steps(self):
+        """
+        A new record will be created and will goes from draft to done state via the other states (open, pending and cancel)
+        We will create a rule that says in precondition that the record must be in the "draft" state while a postcondition filter says
+        that the record will be done. If the state goes from 'draft' to 'done' the responsible will change. If those two conditions aren't
+        verified, the responsible will stay the same
+        The responsible in that test will never change
+        """
+        cr, uid = self.cr, self.uid
+        context = {}
+        filter_draft = self.create_filter_draft(cr, uid, context=context)
+        filter_done = self.create_filter_done(cr, uid, context=context)
+        self.create_rule(cr, uid, filter_id=filter_draft, filter_post_id=filter_done, context=context)
+        new_lead_id = self.create_lead_test_1(cr,uid,context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='draft')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+        """ change the state of new_lead to open and check that responsible doen't change"""
+        new_lead.write({'state': 'open'}, context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='open')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+        """ change the state of new_lead to pending and check that responsible doen't change"""
+        new_lead.write({'state': 'pending'}, context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='pending')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+        """ change the state of new_lead to cancel and check that responsible doen't change"""
+        new_lead.write({'state': 'cancel'}, context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='cancel')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+        """ change the state of new_lead to done and check that responsible doen't change """
+        new_lead.write({'state': 'done'}, context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='done')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+
+    def test_02_check_from_draft_to_done_without_steps(self):
+        """
+        A new record will be created and will goes from draft to done in one operation
+        We will create a rule that says in precondition that the record must be in the "draft" state while a postcondition filter says
+        that the record will be done. If the state goes from 'draft' to 'done' the responsible will change. If those two conditions aren't
+        verified, the responsible will stay the same
+        The responsible in that test will change to "demo_user"
+        """
+        cr, uid = self.cr, self.uid
+        context = {}
+        filter_draft = self.create_filter_draft(cr, uid, context=context)
+        filter_done = self.create_filter_done(cr, uid, context=context)
+        self.create_rule(cr, uid, filter_id=filter_draft, filter_post_id=filter_done, context=context)
+        new_lead_id = self.create_lead_test_1(cr,uid,context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='draft')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.admin_user[1], context=context))
+        """ change the state of new_lead to done and check that responsible change to Demo_user"""
+        new_lead.write({'state': 'done'}, context=context)
+        new_lead = self.registry('base.action.rule.lead.test').browse(cr, uid, new_lead_id, context=context)
+        self.assertTrue(new_lead.state=='done')
+        self.assertTrue(new_lead.user_id==self.registry('res.users').browse(cr, uid, self.demo_user[1], context=context))
\ No newline at end of file

=== modified file 'base_status/base_stage.py'
--- base_status/base_stage.py	2012-11-22 12:19:15 +0000
+++ base_status/base_stage.py	2012-11-28 09:48:26 +0000
@@ -19,6 +19,7 @@
 #
 ##############################################################################
 
+import pdb
 from osv import fields, osv
 from tools.translate import _
 

=== modified file 'base_status/base_state.py'
--- base_status/base_state.py	2012-08-22 11:34:39 +0000
+++ base_status/base_state.py	2012-11-28 09:48:26 +0000
@@ -163,7 +163,7 @@
             update_values = {}
         update_values['state'] = state_name
         self.write(cr, uid, ids, update_values, context=context)
-        self._action(cr, uid, cases, state_name, context=context)
+        #self._action(cr, uid, cases, state_name, context=context)
 
     def _action(self, cr, uid, cases, state_to, scrit=None, context=None):
         if context is None:

=== modified file 'crm/crm_action_rule.py'
--- crm/crm_action_rule.py	2012-11-15 12:38:51 +0000
+++ crm/crm_action_rule.py	2012-11-28 09:48:26 +0000
@@ -43,8 +43,8 @@
         'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
     }
 
-    def do_check(self, cr, uid, action, obj, context=None):
-        ok = super(base_action_rule, self).do_check(cr, uid, action, obj, context=context)
+    def do_check(self, cr, uid, action, obj, precondition_ok=True, context=None):
+        ok = super(base_action_rule, self).do_check(cr, uid, action, obj, precondition_ok=precondition_ok, context=context)
 
         if hasattr(obj, 'section_id'):
             ok = ok and (not action.trg_section_id or action.trg_section_id.id == obj.section_id.id)

=== modified file 'crm/crm_action_rule_view.xml'
--- crm/crm_action_rule_view.xml	2012-10-05 08:08:41 +0000
+++ crm/crm_action_rule_view.xml	2012-11-28 09:48:26 +0000
@@ -7,16 +7,6 @@
             <field name="model">base.action.rule</field>
             <field name="inherit_id" ref="base_action_rule.view_base_action_rule_form"/>
             <field name="arch" type="xml">
-                <xpath expr="//group[@name='partner']" position="after">
-                    <group name="case" string="Conditions on Case Fields">
-                        <field name="trg_section_id" widget="selection"/>
-                        <field name="trg_categ_id"/>
-                    </group>
-                    <group name="communication" string="Conditions on Communication History">
-                        <field name="regex_history"/>
-                        <field name="trg_max_history"/>
-                    </group>
-                </xpath>
                 <xpath expr="//field[@name='act_user_id']" position="after">
                     <field name="act_section_id"/>
                     <field name="act_categ_id"/>

=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2012-11-26 21:52:41 +0000
+++ crm/crm_lead.py	2012-11-28 09:48:26 +0000
@@ -29,6 +29,7 @@
 from tools import html2plaintext
 
 from base.res.res_partner import format_address
+import pdb
 
 CRM_LEAD_PENDING_STATES = (
     crm.AVAILABLE_STATES[2][0], # Cancelled

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to