hi all
i try to create 'mail.activity' from 'stock.scrap'
class InheritStockScrap(models.Model):
_inherit = 'stock.scrap'
def action_confirm_draft(self):
for rec in self:
rec.state = 'inventory_manager_approval'
group_xml_id = 'stock.group_stock_manager'
if group_xml_id:
users = self.env['res.users'].search([("groups_id", "=", self.env.ref(group_xml_id).id)])
note = 'Please Confirm Scrap Stock ..'
activity_type_id = self.env.ref('mail.mail_activity_data_todo').id
for rec in users:
self.env['mail.activity'].create({
'activity_type_id': activity_type_id,
'note': note,
'user_id': rec.id,
'res_id': self.id,
'res_model_id': self.env.ref('stock.model_stock_scrap').id,
'date_deadline': datetime.now().date(),
})
but faced this error .. any idea ?
ValueError: Invalid field stock.scrap.activity_ids in leaf ('activity_ids.user_id', '=', 2)
This link might help as well as it is with an existing model.
http://www.odooninja.com/add-chatter-existing-model/