partner.py 864 B

12345678910111213141516171819202122
  1. # -*- coding: utf-8 -*-
  2. # Part of BiztechCS. See LICENSE file for full copyright and licensing details.
  3. from openerp.osv import osv, fields
  4. class subscribe_website(osv.Model):
  5. _inherit='res.partner'
  6. _columns={
  7. 'subscribe':fields.boolean("Subscribe",help="Subscribe"),
  8. }
  9. def create(self, cr, uid, vals, context=None):
  10. if vals.has_key('email') and vals['email']:
  11. subscribe_customer=self.search(cr,uid,[('subscribe','=',True),('email','=',vals['email'])])
  12. if subscribe_customer:
  13. vals.update({'subscribe' :True})
  14. self.write(cr,uid,subscribe_customer,vals)
  15. return subscribe_customer[0]
  16. return super(subscribe_website,self).create(cr,uid,vals,context)
  17. subscribe_website()
  18. # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: