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.

18 lines
838 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, api
  3. class PurchaseOrder(models.Model):
  4. _inherit = 'purchase.order'
  5. @api.model
  6. def create(self, vals):
  7. purchase_order = super(PurchaseOrder, self).create(vals)
  8. command_contact = self.env.ref('beesdoo_base.commande_beescoop', raise_if_not_found=False)
  9. types = self.env['mail.message.subtype'].search(['|',('res_model','=','purchase.order'),('name','=','Discussions')])
  10. if command_contact:
  11. self.env['mail.followers'].create({'res_model' : 'purchase.order',
  12. 'res_id' : purchase_order.id,
  13. 'partner_id' : command_contact.id,
  14. 'subtype_ids': [(6, 0, types.ids)]})
  15. return purchase_order