Browse Source

[FIX] update parent_id for relocated children

Before only main message get new parent_id. This had led to issue in inbox: moved messages was not shown
pull/2/head
Ivan Yelizariev 10 years ago
parent
commit
df1fe5e50d
  1. 26
      mail_move_message_models.py

26
mail_move_message_models.py

@ -140,7 +140,11 @@ class mail_message(models.Model):
moved_by_message_id = self.id moved_by_message_id = self.id
moved_by_user_id = self.env.user.id moved_by_user_id = self.env.user.id
first_move = not self.moved_by_user_id first_move = not self.moved_by_user_id
vals = {'parent_id': parent_id}
vals = {'parent_id': parent_id,
'res_id': res_id,
'model': model,
'moved_by_user_id': moved_by_user_id,
'moved_by_message_id': moved_by_message_id}
if first_move: if first_move:
# moved_from_* variables contain not last, but original # moved_from_* variables contain not last, but original
# reference # reference
@ -148,24 +152,18 @@ class mail_message(models.Model):
elif move_back: elif move_back:
# clear moved_from_* variabls if we move everything back # clear moved_from_* variabls if we move everything back
vals['moved_from_parent_id'] = None vals['moved_from_parent_id'] = None
self.sudo().write(vals)
for r in self.all_child_ids:
vals = {'res_id': res_id,
'model': model,
'moved_by_user_id': moved_by_user_id,
'moved_by_message_id': moved_by_message_id}
if move_back:
vals['moved_by_user_id'] = None vals['moved_by_user_id'] = None
vals['moved_by_message_id'] = None vals['moved_by_message_id'] = None
for r in self.all_child_ids:
r_vals = vals.copy()
if not r.moved_by_user_id or r.id == self.id and first_move: if not r.moved_by_user_id or r.id == self.id and first_move:
vals['moved_from_res_id'] = r.res_id
vals['moved_from_model'] = r.model
r_vals['moved_from_res_id'] = r.res_id
r_vals['moved_from_model'] = r.model
elif move_back: elif move_back:
vals['moved_from_res_id'] = None
vals['moved_from_model'] = None
r.sudo().write(vals)
r_vals['moved_from_res_id'] = None
r_vals['moved_from_model'] = None
r.sudo().write(r_vals)
def name_get(self, cr, uid, ids, context=None): def name_get(self, cr, uid, ids, context=None):
if not (context or {}).get('extended_name'): if not (context or {}).get('extended_name'):

Loading…
Cancel
Save