openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #03505
lp:~openerp-dev/openobject-addons/trunk-automated_rules-sprint25_backlog_correction-jam into lp:~openerp-dev/openobject-addons/trunk-automated_rules
Jigar Amin - OpenERP has proposed merging lp:~openerp-dev/openobject-addons/trunk-automated_rules-sprint25_backlog_correction-jam into lp:~openerp-dev/openobject-addons/trunk-automated_rules.
Requested reviews:
Bhumika (OpenERP) (sbh-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-automated_rules-sprint25_backlog_correction-jam/+merge/51506
Hello,
Changes with Merge proposal
+ Making Automated rule generic removing the Field and Time triggering Filet
Kindly Review this
Thank You
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-automated_rules-sprint25_backlog_correction-jam/+merge/51506
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-automated_rules.
=== modified file 'base_action_rule/base_action_rule.py'
--- base_action_rule/base_action_rule.py 2011-02-25 12:16:16 +0000
+++ base_action_rule/base_action_rule.py 2011-02-28 09:53:55 +0000
@@ -49,7 +49,6 @@
_name = 'base.action.rule'
_description = 'Action Rules'
-
def btn_create_filter(self, cr, uid, ids, context=None):
"""
This will open ir.filter view view on button click of create filter in form.
@@ -89,37 +88,10 @@
}
_defaults = {
'active': lambda *a: True,
- 'trg_date_range_type': lambda *a: 'days',
}
_order = 'sequence'
- def onchange_model_id(self, cr, uid, ids, model_id, context=None):
- """
- Method will create new state for selecting the states for trigering
- Base Action Rules and id state for curent slected model exists than
- no new state will be created
- """
- action_state_pool =self.pool.get('action.rule.state')
- model_pool = self.pool.get('ir.model')
- if model_id:
- current_model = model_pool.browse(cr, uid, model_id, context=context)
- model = self.pool.get(current_model.model)
- if model:
- state_field = model.fields_get(cr, uid, ['state'], context=context)
- if state_field:
- selection = state_field.get('state', {}).get('selection',[])
- for select in selection:
- vals={}
- vals.update({'name':select[1], 'key':select[0], 'model_id':current_model.id})
- search_domain = [('name','=',select[1]), ('key','=',select[0]), ('model_id','=',current_model.id)]
- state_exists = action_state_pool.search(cr, uid, search_domain, context=context)
- if not state_exists:
- action_state_pool.create(cr, uid, vals, context=context)
-
- return {'value':{'from_state_id':False, 'field_id':False}}
-
-
def _do_run(self, cr, uid, rule=None, model=None, domain=[], context=None):
"""
Method to run the server action on given model with specified domian
@@ -146,26 +118,9 @@
@param rule :pointer to current rule to be evalated
@param domain : pointer to domain
"""
+ if context == None:
+ context = {}
# Preparing the domain using the filters and sate and filed.
- state_filter = []
- field_filter = []
- if rule.from_state_id:
- state_filter = [('state','=',rule.from_state_id.key)]
- if rule.field_id:
- fnct = {
- 'minutes': lambda interval: timedelta(minutes=interval),
- 'days': lambda interval: timedelta(days=interval),
- 'hours': lambda interval: timedelta(hours=interval),
- 'weeks': lambda interval: timedelta(weeks=interval),
- }
- delay = fnct[rule.trg_date_range_type](rule.trg_date_range)
- constrain_date = datetime.now() + delay
- if rule.trg_date_range < 0:
- field_filter = [(rule.field_id.name,'>',constrain_date.strftime("%Y-%m-%d %H:%M:%S"))]
- else:
- field_filter = [(rule.field_id.name,'<',constrain_date.strftime("%Y-%m-%d %H:%M:%S"))]
- domain.extend(state_filter)
- domain.extend(field_filter)
if rule.filter_id:
if rule.model_id.model == rule.filter_id.model_id:
context.update(eval(rule.filter_id.context))
=== modified file 'base_action_rule/base_action_rule_view.xml'
--- base_action_rule/base_action_rule_view.xml 2011-02-25 12:14:06 +0000
+++ base_action_rule/base_action_rule_view.xml 2011-02-28 09:53:55 +0000
@@ -42,18 +42,13 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Action Rule">
- <group col="4" colspan="4">
- <field name="name" colspan="2"/>
+ <group col="6" colspan="6">
+ <field name="name" colspan="2" select="1" />
+ <field name="model_id" select="1" colspan="2"/>
<field name="sequence" colspan="2"/>
- <field name="model_id" select="1" on_change="onchange_model_id(model_id)" colspan="2"/>
- <field name="active" colspan="2"/>
</group>
<notebook colspan="4">
- <page string="Action Parameters">
- <group col="2" colspan="2">
- <separator colspan="4" string="Server Action"/>
- <field name="server_action_id" colspan="2" domain="[('model_id','=',model_id)]"/>
- </group>
+ <page string="Action">
<group col="2" colspan="2" >
<separator colspan="4" string="Filters"/>
<group col="4" colspan="4">
@@ -63,19 +58,13 @@
</group>
</group>
<group col="2" colspan="2">
- <separator colspan="4" string="Triggering Time"/>
- <field name="from_state_id" domain="[('model_id','=',model_id)]"/>
- <field name="field_id" domain="[('ttype','in',['datetime']),
- ('model_id','=',model_id)]" colspan="2"/>
- <group col="3" colspan="2" attrs="{'invisible': [('field_id', '=', False)]}">
- <field name="trg_date_range" string="Delay After Trigger Date"/>
- <field name="trg_date_range_type" nolabel="1"/>
- </group>
- </group>
- <group col="2" colspan="2">
- <separator colspan="4" string="Misecellenious"/>
- <field name="last_run"/>
- </group>
+ <separator colspan="4" string="Server Action"/>
+ <field name="server_action_id" colspan="2" domain="[('model_id','=',model_id)]"/>
+ </group>
+ </page>
+ <page string="Misecellenious">
+ <field name="active"/>
+ <field name="last_run"/>
</page>
</notebook>
</form>
@@ -110,9 +99,6 @@
<field name="help">Use automated actions to automatically trigger actions for various model. Example: On slected model appply verious filters and select server action to be triggered on filtered documents of selcted models.</field>
</record>
- <menuitem id="menu_base_action_rule_form"
- parent="base.menu_base_action_rule" action="base_action_rule_act" sequence="1"/>
-
-
+ <menuitem id="menu_base_action_rule_form" parent="base.menu_base_action_rule" action="base_action_rule_act" sequence="1"/>
</data>
</openerp>
Follow ups