i am trying to block previous dates but got this error could you please help me
File "/opt/odoo/odoo/models.py", line 5448, in _onchange_eval method_res = getattr(self._origin, method)(*params) TypeError: onchange_date() takes at least 5 arguments (2 given)
py file:
def onchange_date(self, cr, uid, ids, payment_date, context=None):
if datetime.strptime(payment_date, DEFAULT_SERVER_DATE_FORMAT).date() > datetime.now().date():
return False
return payment_date
xml file:
<field name="payment_date" on_change="onchange_date(payment_date)"/>
A function can have as many parameters as you want, but the more parameters you have, the harder it is to memorize their roles and purposes.
This also means that invoking the function will require 5 arguments.