跳至内容
菜单
此问题已终结
2 回复
5980 查看

guys how to add message_post to this function?

@api.model
def create(self, vals):

if vals['amount'] <= 0:
raise UserError(_('Cheque amount must be greater than zero !!!'))
self.env['cheque.master'].browse(vals['cheque_id']).write({'state': 'used',
'partner_id': vals['partner_id'],
'partner_account_id': vals['dest_account_id'],
'date_issue': vals['date_issue'],
'cheque_date': vals['cheque_date'],
})
vals['state'] = 'used'
return super(IssueCheque, self).create(vals)


形象
丢弃
最佳答案

Hi,

See a sample of using message_post function from create_method.

@api.model
def create(self, data):
vehicle = super(FleetVehicle, self.with_context(mail_create_nolog=True)).create(data)
vehicle.message_post(body=_('%s %s has been added to the fleet!') % (vehicle.model_id.name, vehicle.license_plate))
return vehicle


Thanks

形象
丢弃
最佳答案

for rec in self:

rec.message_post(
body='message body',
subject='subject',
partner_ids=[recipient_list], # list of recipient partner ids
attachment_ids=[attachment_id], # list of attachment ids
message_type='comment', # type of message (comment, email, etc.)
subtype='mail.mt_comment', # subtype of message
author_id=self.env.user.partner_id.id, # id of the message's author
)


形象
丢弃
相关帖文 回复 查看 活动
0
7月 25
318
2
3月 15
9654
1
8月 23
2411
1
6月 22
11204
1
12月 23
17811