Disable add new row in Delivery note and Sales Invoice conditionally

I want to disable add new row in Delivery note and Sales Invoice conditionally,
Please help.

Thanks
Mithilesh

what’s the condition and why do you want to do this?

Conditions are if get item from Sales Order then Add new row should be disabled otherwise enabled.