Hi,
I'm create a module to try and learn OpenERP. I want a res.partner to have points and for each sale he does he needs to get an extra point.
When you create a res.partner you can give him an initial points value, but it can't be negative. class res_partner(osv.Model): _inherit = 'res.partner'
_columns = {
'points': fields.integer(string = 'Collected points'),
}
_defaults = {
'points': 0,
}
def _check_points(self, cr, uid, ids, context=None):
obj = self.browse(cr, uid, ids[0], context=context)
if obj.points < 0:
return False
return True
_constraints = [
(_check_points, 'Points must be 0 or above', ['points']),
]
How do I write my test?
def test_negative_points(self):
cr, uid = self.cr, self.uid
loyalty_id = self.partner_model.create(cr, uid, dict(
...,
points=-10,
))
Because this always gives me an error.