From 828a61f59d156a1ee380fd1994ca270eefffe3ce Mon Sep 17 00:00:00 2001 From: jmf Date: Sat, 21 May 2016 01:05:20 +0200 Subject: [PATCH] [IMPL] Added mail.followers --- beesdoo_inventory/models/stock.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py index 562f6c9..efcbc72 100644 --- a/beesdoo_inventory/models/stock.py +++ b/beesdoo_inventory/models/stock.py @@ -6,3 +6,24 @@ class StockPicking(models.Model): max_shipping_date = fields.Datetime("End Shipping Date") responsible = fields.Many2one("res.partner", string="Responsible Person") + + def _add_follower(self): + self.env['mail.followers'].create({'partner_id': self.responsible.id, + 'res_id': self.id, + 'res_model': "stock.picking",}) + + @api.multi + def write(self, values): + res = super(StockPicking, self).write(values) + print "WRITE" + print values.get('responsible') + if values.get('responsible'): + for picking in self: + picking._add_follower() + return res + + @api.model + def create(self, values): + picking = super(StockPicking, self).create(values) + picking._add_follower() + return picking \ No newline at end of file