[IMP] project_issue: update issue after creating a partner from chatter suggestion

When a message is posted through the chatter and creates a new partner
the issue is now updated so that the partner field is correctly set to
the newly-created partner.

Chatter on issue now uses the reload option so that the view is reloaded
after posting a message. The user therefore sees that the record has been
updated accordingly.
This commit is contained in:
Thibault Delavallée
2017-05-04 14:15:33 +02:00
parent 38e6f35283
commit 4207b33b88
2 changed files with 14 additions and 1 deletions
@@ -327,6 +327,19 @@ class ProjectIssue(models.Model):
self.sudo().write({'date_action_last': fields.Datetime.now()})
return mail_message
def _message_post_after_hook(self, message):
if self.email_from and not self.partner_id:
# we consider that posting a message with a specified recipient (not a follower, a specific one)
# on a document without customer means that it was created through the chatter using
# suggested recipients. This heuristic allows to avoid ugly hacks in JS.
new_partner = message.partner_ids.filtered(lambda partner: partner.email == self.email_from)
if new_partner:
self.search([
('partner_id', '=', False),
('email_from', '=', new_partner.email),
('stage_id.fold', '=', False)]).write({'partner_id': new_partner.id})
return super(ProjectIssue, self)._message_post_after_hook(message)
@api.multi
def message_get_email_values(self, notif_mail=None):
self.ensure_one()
@@ -61,7 +61,7 @@
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="activity_ids" widget="mail_activity"/>
<field name="message_ids" widget="mail_thread"/>
<field name="message_ids" widget="mail_thread" options="{'post_refresh': 'recipients'}"/>
</div>
</form>
</field>