Skip to Content
मेन्यू
This question has been flagged
2 Replies
5988 Views

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)


Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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
)


Avatar
Discard
Related Posts Replies Views Activity
0
जुल॰ 25
319
2
मार्च 15
9662
1
अग॰ 23
2421
1
जून 22
11206
1
दिस॰ 23
17816