[FIX] note: notes without user's stage are added to the first user's stage (sort by sequence)

bzr revid: chm@openerp.com-20130422112438-0f1s6we5ggq3t6xn
This commit is contained in:
Christophe Matthieu 2013-04-22 13:24:38 +02:00
parent 3d1e5d6998
commit 0915663545
2 changed files with 21 additions and 8 deletions

View File

@ -141,12 +141,19 @@ class note_note(osv.osv):
#note without user's stage
nb_notes_ws = self.search(cr,uid, domain+[('stage_ids', 'not in', current_stage_ids)], context=context, count=True)
if nb_notes_ws:
result += [{ #notes for unknown stage and if stage_ids is not empty
'__context': {'group_by': groupby[1:]},
'__domain': domain + [('stage_ids', 'not in', current_stage_ids)],
'stage_id': (0, 'Unknown'),
'stage_id_count':nb_notes_ws
}]
# add note to the first column if it's the first stage
dom_not_in = ('stage_ids', 'not in', current_stage_ids)
if result and result[0]['stage_id'][0] == current_stage_ids[0]:
dom_in = result[0]['__domain'].pop()
result[0]['__domain'] = domain + ['|', dom_in, dom_not_in]
else:
# add the first stage column
result = [{
'__context': {'group_by': groupby[1:]},
'__domain': domain + [dom_not_in],
'stage_id': (current_stage_ids[0], stage_name[current_stage_ids[0]]),
'stage_id_count':nb_notes_ws
}] + result
else: # if stage_ids is empty
@ -156,7 +163,7 @@ class note_note(osv.osv):
result = [{ #notes for unknown stage
'__context': {'group_by': groupby[1:]},
'__domain': domain,
'stage_id': (0, 'Unknown'),
'stage_id': False,
'stage_id_count':nb_notes_ws
}]
else:
@ -187,7 +194,7 @@ class res_users(osv.Model):
model_id = data_obj.get_object_reference(cr, uid, 'base', 'group_user') #Employee Group
group_id = model_id and model_id[1] or False
if group_id in [x.id for x in user.groups_id]:
for note_xml_id in ['note_stage_01','note_stage_02','note_stage_03','note_stage_04']:
for note_xml_id in ['note_stage_00','note_stage_01','note_stage_02','note_stage_03','note_stage_04']:
data_id = data_obj._get_id(cr, uid, 'note', note_xml_id)
stage_id = data_obj.browse(cr, uid, data_id, context=context).res_id
note_obj.copy(cr, uid, stage_id, default = {

View File

@ -2,6 +2,12 @@
<openerp>
<data>
<record model="note.stage" id="note_stage_00">
<field name="name">New</field>
<field name="sequence" eval="0"/>
<field name="user_id" eval="ref('base.user_root')"/>
</record>
<record model="note.stage" id="note_stage_01">
<field name="name">Today</field>
<field name="sequence">1</field>