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.

36 lines
1.5 KiB

  1. from odoo import _, api, fields, models
  2. class StockPicking(models.Model):
  3. _inherit = 'stock.picking'
  4. max_shipping_date = fields.Datetime("End Shipping Date")
  5. responsible = fields.Many2one('res.partner', string="Responsible", default=lambda self: self.env.user.partner_id.id)
  6. def _add_follower(self):
  7. if(self.responsible):
  8. types = self.env['mail.message.subtype'].search(['|',('res_model','=','stock.picking'),('name','=','Discussions')])
  9. if not self.env['mail.followers'].search([('res_id', '=', self.id),
  10. ('res_model', '=', 'stock.picking'),
  11. ('partner_id', '=', self.responsible.id)]):
  12. self.env['mail.followers'].create({'res_model' : 'stock.picking',
  13. 'res_id' : self.id,
  14. 'partner_id' : self.responsible.id,
  15. 'subtype_ids': [(6, 0, types.ids)]})
  16. @api.multi
  17. def write(self, values):
  18. res = super(StockPicking, self).write(values)
  19. self._add_follower()
  20. return res
  21. @api.model
  22. def create(self, values):
  23. picking = super(StockPicking, self).create(values)
  24. picking._add_follower()
  25. return picking
  26. @api.multi
  27. def copy_qty(self):
  28. self.ensure_one()
  29. for pack_operation in self.pack_operation_product_ids:
  30. pack_operation.qty_done = pack_operation.product_qty
  31. return True