'res.partner': (lambda self, cr, uid, ids, c={}: ids, ['free_member'], 10)
}
),
+ 'newsletter': fields.boolean('Want to subsribe to the newsletter?'),
}
+ _defaults = {
+ 'newsletter': lambda *a: True,
+ }
+
+ def _check_email(self, cr, uid, ids, context=None):
+ #TODO : check condition and return boolean accordingly
+ if context is None:
+ context = {}
+ for partner in self.browse(cr, uid, ids, context=context):
+ if partner.newsletter and not partner.email:
+ return False
+ return True
+
+ _constraints = [
+ (_check_email, 'Error: you can\'t subscribe to the newsletter without email!', ['newsletter']),
+ ]
Partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: