partner.py 775 B

123456789101112131415161718192021
  1. # -*- coding: utf-8 -*-
  2. # Part of BiztechCS. See LICENSE file for full copyright and licensing details.
  3. from openerp import api, fields, models, _
  4. class subscribe_website(models.Model):
  5. _inherit = 'res.partner'
  6. subscribe = fields.Boolean(string="Subscribe", help="Subscribe")
  7. @api.model
  8. def create(self, vals):
  9. if vals.has_key('email') and vals['email']:
  10. subscribe_customer = self.search([('subscribe', '=', True),
  11. ('email', '=', vals['email'])])
  12. if subscribe_customer:
  13. vals.update({'subscribe': True})
  14. self.write(subscribe_customer, vals)
  15. return subscribe_customer[0]
  16. return super(subscribe_website, self).create(vals)