Hello All,
i Have a field, in which total weight shows of all rows. And want that if total "Sum" is greater than 50 then it shows error that "Weight Exceeded". My function working up-to "if self.sum >= 50: "
My Code is here:
@api.onchange('machine_weight_id', 'weight')
def _onchange_amount_weight(self):
if self.machine_weight_id:
weight_obj = self.machine_weight_id
print "a:", weight_obj
vals = 0;
for rec in weight_obj:
print"v::", rec
if rec.weight:
print "s", rec.weight
vals = vals + rec.weight
print "vals", vals
self.sum = vals
if self.sum >= 50:
raise UserError(_('Weight Exceeded'))