[FIX] 2st test for automated action

bzr revid: api@openerp.com-20121123110056-v059mn0jpgqe6svl
This commit is contained in:
Arnaud Pineux 2012-11-23 12:00:56 +01:00
commit 0ab1526d1a
12 changed files with 70 additions and 84 deletions

View File

@ -5,42 +5,44 @@ var QWeb = instance.web.qweb;
instance.web.Login = instance.web.Login.extend({
start: function() {
this._super.apply(this, arguments);
var self = this;
this._default_error_message = this.$el.find('.oe_login_error_message').text();
this.$openid_selected_button = $();
this.$openid_selected_input = $();
this.$openid_selected_provider = null;
var openIdProvider = null;
if (this.has_local_storage && this.remember_credentials) {
openIdProvider = localStorage.getItem('openid-provider');
}
if (openIdProvider) {
$openid_selected_provider = openIdProvider;
this.do_openid_select('a[href="#' + openIdProvider + '"]', openIdProvider, true);
if (this.has_local_storage && this.remember_credentials) {
this.$openid_selected_input.find('input').val(localStorage.getItem('openid-login'));
var d = self._super.apply(this, arguments).done(function() {
self._default_error_message = self.$el.find('.oe_login_error_message').text();
self.$openid_selected_button = $();
self.$openid_selected_input = $();
self.$openid_selected_provider = null;
var openIdProvider = null;
if (self.has_local_storage && self.remember_credentials) {
openIdProvider = localStorage.getItem('openid-provider');
}
}
else {
this.do_openid_select('a[data-url=""]', 'login,password', true);
}
this.$el.find('a[data-url]').click(function (event) {
event.preventDefault();
var selected_oidh = $(this).attr('href').substr(1);
if (selected_oidh != self.$openid_selected_provider) {
self.do_openid_select(this, selected_oidh);
if (openIdProvider) {
$openid_selected_provider = openIdProvider;
self.do_openid_select('a[href="#' + openIdProvider + '"]', openIdProvider, true);
if (self.has_local_storage && self.remember_credentials) {
self.$openid_selected_input.find('input').val(localStorage.getItem('openid-login'));
}
}
else {
self.do_openid_select('a[data-url=""]', 'login,password', true);
}
self.$el.find('a[data-url]').click(function (event) {
event.preventDefault();
var selected_oidh = $(this).attr('href').substr(1);
if (selected_oidh != self.$openid_selected_provider) {
self.do_openid_select(this, selected_oidh);
}
});
self._check_error();
});
this._check_error();
return d;
},

View File

@ -32,9 +32,11 @@ openerp.auth_signup = function(instance) {
// in case of a signup, retrieve the user information from the token
if (self.params.db && self.params.token) {
d = self.rpc("/auth_signup/retrieve", {dbname: self.params.db, token: self.params.token})
d.done(function() {
self.rpc("/auth_signup/retrieve", {dbname: self.params.db, token: self.params.token})
.done(self.on_token_loaded)
.fail(self.on_token_failed);
.fail(self.on_token_failed)
});
}
return d;
},

View File

@ -109,7 +109,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
_order = 'sequence'
def post_action(self, cr, uid, ids, model, old_records_states=None, context=None):
def post_action(self, cr, uid, ids, model, old_records=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) \
@ -121,7 +121,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
# 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], model_pool.browse(cr, uid, ids, context=context), old_records_states=old_records_states, context=context)
self._action(cr, uid, [rule_id], model_pool.browse(cr, uid, ids, context=context), old_records=old_records, context=context)
return True
def _create(self, old_create, model, context=None):
@ -144,7 +144,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
`post_action`, in that order.
"""
def wrapper(cr, uid, ids, vals, context=context):
old_records_states = {}
old_records = {}
if context is None:
context = {}
if isinstance(ids, (str, int, long)):
@ -152,15 +152,13 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
model_pool = self.pool.get(model)
# get the old records (before the write)
if model and ids:
for record in model_pool.browse(cr,uid,ids,context=context):
old_records_states[record.id] = record.state
#old_records = model_pool.browse(cr,uid,ids,context=context)
#print old_records[0]
#print old_records[0].state
old_records = model_pool.browse(cr,uid,ids,context=context)
# look at records' states to fill the record cache
for record in old_records:
record.state
old_write(cr, uid, ids, vals, context=context)
#print old_records[0].state
if not context.get('action'):
self.post_action(cr, uid, ids, model, old_records_states=old_records_states, context=context)
self.post_action(cr, uid, ids, model, old_records=old_records, context=context)
return True
return wrapper
@ -252,7 +250,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
def do_check(self, cr, uid, action, obj, old_records_states=None, context=None):
def do_check(self, cr, uid, action, obj, old_records=None, context=None):
""" check Action """
if context is None:
context = {}
@ -277,15 +275,13 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
state_to = getattr(obj, 'state', False)
#state_from = nothing or the state of old_records
state_from = ""
if old_records_states != None:
if old_records_states[obj.id]:
state_from = old_records_states[obj.id]
if old_records != None:
for record in old_records:
state_from = record.state
#if we have an action that check the status
if action.trg_state_from:
print action.trg_state_from, " and ", state_to
ok = ok and action.trg_state_from==state_to
if action.trg_state_to:
print action.trg_state_to, " for ", state_from, " and ", state_to
ok = state_from!=state_to
ok = ok and action.trg_state_to==state_to
reg_name = action.regex_name
@ -329,7 +325,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
model_obj.message_subscribe(cr, uid, [obj.id], new_followers, context=context)
return True
def _action(self, cr, uid, ids, objects, scrit=None, old_records_states=None, context=None):
def _action(self, cr, uid, ids, objects, scrit=None, old_records=None, context=None):
""" Do Action """
if context is None:
context = {}
@ -338,7 +334,7 @@ trigger date, like sending a reminder 15 minutes before a meeting."),
objects = [objects]
for action in self.browse(cr, uid, ids, context=context):
for obj in objects:
if self.do_check(cr, uid, action, obj, old_records_states=old_records_states, context=context):
if self.do_check(cr, uid, action, obj, old_records=old_records, context=context):
self.do_action(cr, uid, action, obj, context=context)
context.update({'action': False})

View File

@ -284,7 +284,6 @@ class base_stage(object):
return True
def _action(self, cr, uid, cases, state_to, scrit=None, context=None):
print "--- Base_Stage (_action) ---"
if context is None:
context = {}
context['state_to'] = state_to

View File

@ -157,7 +157,6 @@ class base_state(object):
:params: update_values: values that will be added with the state
update when writing values to the record.
"""
print "-------------------------BASE STATE--------------------------------"
cases = self.browse(cr, uid, ids, context=context)
cases[0].state # fill browse record cache, for _action having old and new values
if update_values is None:

View File

@ -43,8 +43,8 @@ class base_action_rule(osv.osv):
'act_categ_id': fields.many2one('crm.case.categ', 'Set Category to'),
}
def do_check(self, cr, uid, action, obj, old_records_states=None, context=None):
ok = super(base_action_rule, self).do_check(cr, uid, action, obj, old_records_states=old_records_states, context=context)
def do_check(self, cr, uid, action, obj, old_records=None, context=None):
ok = super(base_action_rule, self).do_check(cr, uid, action, obj, old_records=old_records, 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)

View File

@ -381,10 +381,8 @@ class crm_lead(base_stage, format_address, osv.osv):
""" Mark the case as lost: state=cancel and probability=0 """
for lead in self.browse(cr, uid, ids):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0)], context=context)
if not stage_id:
return False
else:
self.write(cr, uid, ids, {'probability' : 0.0, 'stage_id' : stage_id}, context=context)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 0.0}, new_stage_id=stage_id, context=context)
self.case_mark_lost_send_note(cr, uid, ids, context=context)
return True
@ -392,10 +390,8 @@ class crm_lead(base_stage, format_address, osv.osv):
""" Mark the case as lost: state=done and probability=100 """
for lead in self.browse(cr, uid, ids):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0)], context=context)
if not stage_id:
return False
else:
self.write(cr, uid, ids, {'probability' : 100.0, 'stage_id' : stage_id}, context=context)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={'probability': 100.0}, new_stage_id=stage_id, context=context)
self.case_mark_won_send_note(cr, uid, ids, context=context)
return True

View File

@ -317,7 +317,7 @@
<div>
<b><field name="name"/></b>
<t t-if="record.planned_revenue.raw_value">
- <b><t t-esc="Math.round(record.planned_revenue.value)"/>
- <b><t t-esc="record.planned_revenue.value"/>
<field name="company_currency"/></b>
</t>
</div>

View File

@ -167,10 +167,8 @@ class crm_claim(base_stage, osv.osv):
""" Mark the case as refused: state=done and case_refused=True """
for lead in self.browse(cr, uid, ids):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, ['&', ('state', '=', 'done'), ('case_refused', '=', True)], context=context)
if not stage_id:
return False
else:
self.write(cr, uid, ids, {'stage_id' : stage_id}, context=context)
if stage_id:
self.case_set(cr, uid, [lead.id], values_to_update={}, new_stage_id=stage_id, context=context)
return self.case_refuse_send_note(cr, uid, ids, context=context)
def onchange_partner_id(self, cr, uid, ids, part, email=False):

View File

@ -96,7 +96,7 @@
<field name="price_extra" groups="product.group_product_variant"/>
</group>
</group>
<field name="description" placeholder="describe the product characteristics for internal use..."/>
<field name="description" placeholder="describe the product characteristics..."/>
</page>
<page string="Procurements" groups="base.group_user">
<group name="procurement">

View File

@ -35,7 +35,7 @@
<record id="project_tt_specification" model="project.task.type">
<field name="sequence">2</field>
<field name="name">Specification</field>
<field name="state">draft</field>
<field name="state">pending</field>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_design" model="project.task.type">
@ -44,37 +44,31 @@
<field name="state">open</field>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_negotiation" model="project.task.type">
<field name="sequence">3</field>
<field name="name">Negotiation</field>
<field name="state">pending</field>
<field name="case_default" eval="False"/>
<field name="fold" eval="True"/>
</record>
<record id="project_tt_development" model="project.task.type">
<field name="sequence">4</field>
<field name="sequence">3</field>
<field name="name">Development</field>
<field name="state">open</field>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_testing" model="project.task.type">
<field name="sequence">5</field>
<field name="sequence">4</field>
<field name="name">Testing</field>
<field name="state">open</field>
<field name="case_default" eval="True"/>
</record>
<record id="project_tt_merge" model="project.task.type">
<field name="sequence">6</field>
<field name="sequence">5</field>
<field name="name">Merge</field>
<field name="state">open</field>
<field name="case_default" eval="False"/>
<field name="fold" eval="True"/>
</record>
<record id="project_tt_deployment" model="project.task.type">
<field name="sequence">7</field>
<field name="sequence">6</field>
<field name="name">Done</field>
<field name="state">done</field>
<field name="case_default" eval="True"/>
<field name="fold" eval="True"/>
</record>
<record id="project_tt_cancel" model="project.task.type">
<field name="sequence">7</field>

View File

@ -36,7 +36,7 @@
<field name="user_id" ref="base.user_demo"/>
<field name="description">Implement new website for Sale and Warehouse Management for a customer.</field>
<field name="alias_model">project.task</field>
<field name="type_ids" eval="[(6, 0, [ref('project_tt_analysis'),ref('project_tt_specification'),ref('project_tt_negotiation'),ref('project_tt_development'),ref('project_tt_testing'),ref('project_tt_deployment')])]"/>
<field name="type_ids" eval="[(6, 0, [ref('project_tt_analysis'),ref('project_tt_specification'),ref('project_tt_development'),ref('project_tt_testing'),ref('project_tt_deployment')])]"/>
</record>
<record id="project_project_2" model="project.project">
@ -114,7 +114,7 @@
<field name="project_id" ref="project.project_project_1"/>
<field name="name">Budget Planning</field>
<field name="date_deadline" eval="time.strftime('%Y-%m-24')"/>
<field name="stage_id" ref="project_tt_negotiation"/>
<field name="stage_id" ref="project_tt_testing"/>
<field name="color">4</field>
</record>
<record id="project_task_4" model="project.task">