You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.0 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api, _
  3. class StockPicking(models.Model):
  4. _inherit = 'stock.picking'
  5. max_shipping_date = fields.Datetime("End Shipping Date")
  6. responsible = fields.Many2one('res.partner', string="Responsible")
  7. def _add_follower(self):
  8. if(self.responsible):
  9. types = self.env['mail.message.subtype'].search(['|',('res_model','=','stock.picking'),('name','=','Discussions')])
  10. self.env['mail.followers'].create({'res_model' : 'stock.picking',
  11. 'res_id' : self.id,
  12. 'partner_id' : self.responsible.id,
  13. 'subtype_ids': [(6, 0, types.ids)]})
  14. @api.multi
  15. def write(self, values):
  16. res = super(StockPicking, self).write(values)
  17. self._add_follower()
  18. return res
  19. @api.model
  20. def create(self, values):
  21. picking = super(StockPicking, self).create(values)
  22. picking._add_follower()
  23. return picking