[FIX][IMP] mail, rating, website_forum: inherit message_post using kwargs
Several addons inherit from message_post method. Instead of redefining the long list of parameters let us just use kwargs and propagate them to the super call. Only really used parameters are set as explicit. Purpose is to lessen issues when changing some parameters default value or when having some API change.
This commit is contained in:
@@ -240,10 +240,10 @@ class Channel(models.Model):
|
||||
|
||||
@api.multi
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False, attachments=None, content_subtype='html', **kwargs):
|
||||
def message_post(self, **kwargs):
|
||||
# auto pin 'direct_message' channel partner
|
||||
self.filtered(lambda channel: channel.channel_type == 'chat').mapped('channel_last_seen_partner_ids').write({'is_pinned': True})
|
||||
message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(body=body, subject=subject, message_type=message_type, subtype=subtype, parent_id=parent_id, attachments=attachments, content_subtype=content_subtype, **kwargs)
|
||||
message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(**kwargs)
|
||||
return message
|
||||
|
||||
def _alias_check_contact(self, message, message_dict, alias):
|
||||
|
||||
@@ -9,9 +9,9 @@ class MailThread(models.AbstractModel):
|
||||
|
||||
@api.multi
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False, attachments=None, content_subtype='html', **kwargs):
|
||||
def message_post(self, **kwargs):
|
||||
rating_value = kwargs.get('rating_value')
|
||||
message = super(MailThread, self).message_post(body=body, subject=subject, message_type=message_type, subtype=subtype, parent_id=parent_id, attachments=attachments, content_subtype=content_subtype, **kwargs)
|
||||
message = super(MailThread, self).message_post(**kwargs)
|
||||
if rating_value:
|
||||
ir_model = self.env['ir.model'].sudo().search([('model', '=', self._name)])
|
||||
self.env['rating.rating'].create({
|
||||
|
||||
@@ -796,7 +796,7 @@ class Post(models.Model):
|
||||
|
||||
@api.multi
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def message_post(self, message_type='notification', subtype=None, **kwargs):
|
||||
def message_post(self, message_type='notification', **kwargs):
|
||||
question_followers = self.env['res.partner']
|
||||
if self.ids and message_type == 'comment': # user comments have a restriction on karma
|
||||
# add followers of comments on the parent post
|
||||
@@ -816,7 +816,7 @@ class Post(models.Model):
|
||||
raise KarmaError('Not enough karma to comment')
|
||||
if not kwargs.get('record_name') and self.parent_id:
|
||||
kwargs['record_name'] = self.parent_id.name
|
||||
return super(Post, self).message_post(message_type=message_type, subtype=subtype, **kwargs)
|
||||
return super(Post, self).message_post(message_type=message_type, **kwargs)
|
||||
|
||||
@api.multi
|
||||
def message_get_message_notify_values(self, message, message_values):
|
||||
|
||||
Reference in New Issue
Block a user