Reputation: 133
I understand that OpenERP 7 is outdated and no longer has any support
but as this question is important I need to ask it here I am new to OpenERP 7 and we hired a freelancer to do some work for us
we needed the date of the entry to be limited to today, yesterday and the day before it
The freelancer did limit it though the selection but if the user types the date manually, it will still accept the entry
I mentioned to him this loophole and how it would make problems for us, but he claims that he would need to change a js file and it would be hard to accomplish
I took his word but my manager wants to confirm that I have not been tricked hence, this question
So, how possible is it to accomplish the mentioned above?
Upvotes: 0
Views: 49
Reputation: 669
What you are looking for is absolutely possible. You can use onchange or _constraints for this :
If you want to check a condition on the fly you can use onchange or if you want to check a condition at the time of save you can use _constraints .
Examples:
def _check_duration(self, cr, uid, ids, context=None):
for obj_ac in self.browse(cr, uid, ids, context=context):
if obj_ac.date_stop < obj_ac.date_start:
return False
return True
_constraints = [
(_check_duration, _('Error! The duration of the academic year is invalid.'), ['date_stop']),
]
def onchange_date(self, cr, uid, ids, date, context=None):
if date:
if Condition Here:
warning = "Your text"
return {'value':{'date': None}, 'warning':warning}
else:
return {}
Hope this helps.
Upvotes: 1