Skip to content
Snippets Groups Projects
Commit 4207b33b authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[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.
parent 38e6f352
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment