I've created my own module for purchase rental and i want to put a constraints in Start Date and End Date. for exmaple, the user input an invalid Dates my created constraints pop up to warn the user that he/she inputs an invalid Date. How will I going to do that? and how will i call my def function in the save button?? here my codes in creating my def:
def _validate_date(self,cr,uid,ids,context=None):
for line in self.browse(cr,uid,ids,context=context):
netsvc.Logger().notifyChannel("NETSV NETSV NETSV NETSV NETSV NETSV NETSV NETSV START DATE", netsvc.LOG_INFO, ' '+str(line.start_date))
netsvc.Logger().notifyChannel("NETSV NETSV NETSV NETSV NETSV NETSV NETSV NETSV ENDSS DATE", netsvc.LOG_INFO, ' '+str(line.end_date))
if line.start_date and not line.end_date:
raise orm.except_orm(
_('Error:'),
_("Missing End Date for purchase order line with"
"Description '%s'.")
% (line.name))
if line.end_date and not line.start_date:
raise orm.except_orm(
_('Error:'),
_("Missing Start Date for purchase order line with"
"Description '%s'.")
% (line.name))
if line.end_date and line.start_date and \
line.start_date > line.end_date:
raise orm.except_orm(
_('Error:'),
_("Start Date should be before or be the same as "
"End Date for purchase order line with Description '%s'.")
% (line.name))
return True
_constraints = [
(_validate_date, "Error msg in raise",
['start_date','end_date','product_id']),
]