From 56e7fbdf8dfb616501429a5f23275d034d92f000 Mon Sep 17 00:00:00 2001 From: EliseDup Date: Wed, 19 Oct 2016 09:48:00 +0200 Subject: [PATCH] Fix S0024 : add responsible as follower --- beesdoo_inventory/models/stock.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/beesdoo_inventory/models/stock.py b/beesdoo_inventory/models/stock.py index efcbc72..4d76c9a 100644 --- a/beesdoo_inventory/models/stock.py +++ b/beesdoo_inventory/models/stock.py @@ -5,21 +5,20 @@ class StockPicking(models.Model): _inherit = 'stock.picking' max_shipping_date = fields.Datetime("End Shipping Date") - responsible = fields.Many2one("res.partner", string="Responsible Person") + responsible = fields.Many2one('res.partner', string="Responsible") def _add_follower(self): - self.env['mail.followers'].create({'partner_id': self.responsible.id, - 'res_id': self.id, - 'res_model': "stock.picking",}) + if(self.responsible): + types = self.env['mail.message.subtype'].search(['|',('res_model','=','stock.picking'),('name','=','Discussions')]) + self.env['mail.followers'].create({'res_model' : 'stock.picking', + 'res_id' : self.id, + 'partner_id' : self.responsible.id, + 'subtype_ids': [(6, 0, types.ids)]}) @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() + self._add_follower() return res @api.model