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.

35 lines
1.3 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. print "Values", values
  22. picking = super(StockPicking, self).create(values)
  23. picking._add_follower()
  24. return picking
  25. @api.multi
  26. def copy_qty(self):
  27. self.ensure_one()
  28. for pack_operation in self.pack_operation_product_ids:
  29. pack_operation.qty_done = pack_operation.product_qty
  30. return True