Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
5977 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää
Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
heinäk. 25
318
2
maalisk. 15
9653
1
elok. 23
2410
1
kesäk. 22
11204
1
jouluk. 23
17811