Browse Source

Fix S0024 : add responsible as follower

pull/14/head
EliseDup 8 years ago
parent
commit
018ee9044a
  1. 17
      beesdoo_inventory/models/stock.py

17
beesdoo_inventory/models/stock.py

@ -5,21 +5,20 @@ class StockPicking(models.Model):
_inherit = 'stock.picking' _inherit = 'stock.picking'
max_shipping_date = fields.Datetime("End Shipping Date") 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): 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 @api.multi
def write(self, values): def write(self, values):
res = super(StockPicking, self).write(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 return res
@api.model @api.model

Loading…
Cancel
Save