Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
5967 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jul 25
315
2
mar 15
9643
1
ago 23
2399
1
jun 22
11203
1
dic 23
17808