Browse Source

S0025 : at each creation of a sale_order, create a mail_follower linked

to contact command@bees-coop.be
pull/14/head
EliseDup 9 years ago
parent
commit
2d972ed6c0
  1. 1
      beesdoo_base/data/default_contact.xml
  2. 2
      beesdoo_pos/models/__init__.py
  3. 12
      beesdoo_pos/models/beesdoo_sale_order.py

1
beesdoo_base/data/default_contact.xml

@ -4,6 +4,7 @@
<record model="res.partner" id="commande_beescoop">
<field name="name">commande@bees-coop.be</field>
<field name="email">commande@bees-coop.be</field>
<field name="active">True</field>
</record>
</data>
</odoo>

2
beesdoo_pos/models/__init__.py

@ -1 +1 @@
import beesdoo_pos
import beesdoo_pos, beesdoo_sale_order

12
beesdoo_pos/models/beesdoo_sale_order.py

@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api, _
from openerp import models, api
class SaleOrder(models.Model):
_inherit = 'sale.order'
message_follower_ids = fields.One2many(
'mail.followers', 'res_id', string='Followers',
domain=lambda self: [('res_model', '=', self._name)])
@api.model
def create(self, vals):
sale_order = super(SaleOrder, self).create(vals)
command_contact = self.env['res.partner'].search([('email', '=', 'commande@bees-coop.be')])[0]
# We do not need to update sale_order.mail_followers_ids, the link is automatic ?!
self.env['mail.followers'].create({'res_model' : 'sale.order', 'res_id' : sale_order.id, 'partner_id' : command_contact.id})
return sale_order
Loading…
Cancel
Save