How to catch duplicate Sales Order recored

I want to catch any duplicate records in Sales Order, (I know the ID is unique) but I faced some customers is create the sales order twice with the same (Items, qty) all fields are same expect the ID,
for example the following

While creating new SO You can search records by Customer name and with Items table. Now you have to check record if all items is similar with another SO item or not if it’s then do some constraints as you required.

Exactly, but I don’t know where is writing this checking (server or client) script and what is the trigger for them.

Firstly You need to override before_insert method as we are using this method because whenever we create SO will check first if it’s exist or not then will continue to add otherwise throw an error at that time.

For overriding before_insert method refer below link.

Let me know if you find any difficulty.

1 Like

Thank you Hardik, it’s a good solution if I open a document that means I need the same functionality but on the list view not on the form view

What it means by list view not form view ? Like that function will be trigger whenever you’ll add any new record.

Do you want to check for existing records ?

Dear, let me explain my case,

we have an e-commerce application (mobile) and a CRM team monitors Sales Orders because sometimes our customer double-click on the (Done) button that creates Sales Orders,
this time creates two Sales Orders (same items and qty), now we want something like an Alarm or Alert message when creating a Sales Order.


  • each time when creating a Sales Order I check just the last 20 Sales Orders not all,
  • I want the alarm to be shown in List View while the CRM team is monitoring

I hope explain all the requirements