Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
5981 Prikazi

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
Opusti
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
Opusti
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
Opusti
Related Posts Odgovori Prikazi Aktivnost
0
jul. 25
318
2
mar. 15
9657
1
avg. 23
2411
1
jun. 22
11204
1
dec. 23
17811