How to Add Constraints on a Date Field with No Code in Odoo

9 يونيو 2020 بواسطة
How to Add Constraints on a Date Field with No Code in Odoo
Hesham Elmahdy

Odoo 13.0 became a very handy web application that you can configure on the fly with no coding. Much of the customization you need can be done from the browser with some limitations like integration with other apps.

 
 

Follow the below steps to add constraints on a date field with no code.

1. Go to the “Automated Actions” form Sittings.

2. Create new and fill the data:

  • Write the name of the action in the “Action Name” field.

  • Give the object from “Model field”.

  • Choose on creation from “Trigger Condition”.

  • Choose execute python code from “Action To Do”.

  • From “Apply on” you have the option to add domains.

3. Under python code,

“If record.x_new_date<=datetime.datetime.today().date():” 

write this expression to get today's date and compare it with the x new date that will be triggered. Then to show the invalid date warning message write this expression:

“raise warning (“Invalid Date”)”. Then Save.

4. Now from the Sales module Create new quotation and try to add the date of
today or a date in the past, that will trigger the warning message and will not
accept the entered date.

New code lines can be added more if you need and also this can be archived, deleted or duplicated anytime.

Now you can create another sales order in the past with no constraints and no limitations easily. You can get back by un-archiving and just by creating it. This is how to add constraints using Automated Actions with minimal code.


OdooTec is a renowned Odoo Golden Partner in Saudi Arabia . We offer software for warehouse management, project management, POS management, construction management, fleet management, manufacturing and much more. We are also the leading Odoo company in Saudi Arabia. For further information, please contact us.

How to Add Constraints on a Date Field with No Code in Odoo
Hesham Elmahdy 9 يونيو 2020
شارك هذا المنشور
الأرشيف