Browse Source

default partner filter and record id change

pull/1/head
Veronika Kotovich 9 years ago
parent
commit
8a790fe109
  1. 12
      mail_move_message_models.py

12
mail_move_message_models.py

@ -35,7 +35,8 @@ class wizard(models.TransientModel):
res['res_id'] = res_id and res_id[0].id res['res_id'] = res_id and res_id[0].id
if 'message_id' in res: if 'message_id' in res:
email_from = self.env['mail.message'].browse(res['message_id']).email_from
message = self.env['mail.message'].browse(res['message_id'])
email_from = message.email_from
parts = email_split(email_from.replace(' ',',')) parts = email_split(email_from.replace(' ',','))
if parts: if parts:
email = parts[0] email = parts[0]
@ -45,6 +46,9 @@ class wizard(models.TransientModel):
res['message_name_from'] = name res['message_name_from'] = name
res['message_email_from'] = email res['message_email_from'] = email
if message.author_id and self.env.uid not in [u.id for u in message.author_id.user_ids]:
res['filter_by_partner'] = True
res['uid'] = self.env.uid res['uid'] = self.env.uid
return res return res
@ -102,7 +106,6 @@ class wizard(models.TransientModel):
def on_change_partner(self): def on_change_partner(self):
domain = {'res_id': []} domain = {'res_id': []}
if self.model and self.filter_by_partner and self.partner_id: if self.model and self.filter_by_partner and self.partner_id:
self.res_id = None
fields = self.env[self.model].fields_get(False) fields = self.env[self.model].fields_get(False)
contact_field = False contact_field = False
for n, f in fields.iteritems(): for n, f in fields.iteritems():
@ -111,6 +114,11 @@ class wizard(models.TransientModel):
break break
if contact_field: if contact_field:
domain['res_id'] = [(contact_field, '=', self.partner_id.id)] domain['res_id'] = [(contact_field, '=', self.partner_id.id)]
if self.model:
res_id = self.env[self.model].search(domain['res_id'], order='id desc', limit=1)
self.res_id = res_id and res_id[0].id
else:
self.res_id = None
return {'domain': domain} return {'domain': domain}
@api.one @api.one

Loading…
Cancel
Save