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.

37 lines
1.5 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. if not self.env['mail.followers'].search([('res_id', '=', self.id),
  11. ('res_model', '=', 'stock.picking'),
  12. ('partner_id', '=', self.responsible.id)]):
  13. self.env['mail.followers'].create({'res_model' : 'stock.picking',
  14. 'res_id' : self.id,
  15. 'partner_id' : self.responsible.id,
  16. 'subtype_ids': [(6, 0, types.ids)]})
  17. @api.multi
  18. def write(self, values):
  19. res = super(StockPicking, self).write(values)
  20. self._add_follower()
  21. return res
  22. @api.model
  23. def create(self, values):
  24. picking = super(StockPicking, self).create(values)
  25. picking._add_follower()
  26. return picking
  27. @api.multi
  28. def copy_qty(self):
  29. self.ensure_one()
  30. for pack_operation in self.pack_operation_product_ids:
  31. pack_operation.qty_done = pack_operation.product_qty
  32. return True