As we migrate to ERPnext a minor repeated nuisance is that on duplicating a transaction (be it a sales order, purchase invoice, journal entry, etc.) user forgets to put correct Posting date for new transaction as that field already has a value (generally the date of the transaction being duplicated).
Can probably write a custom script for every doctype, but is there a way across the board to have the Posting date field be cleared on duplication? As it is a required field user will be reminded to choose if they forget.
@Mohammad_Ahmad_Zulfi OK. Had preferred not to go that route as then need a custom script for every doctype can possibly be duplicated.
Also, what is the trigger for custom script, it is just a new transaction with some fields pre-filled. Not clear what field would advise this new transaction came from duplicate and not new?
Option 1
on page refresh check if the form is new. frm.is_new() and compare the date field with today. If it is different set it to undefined and refresh the field. frm.refresh_field("fieldname")
Option 2
Add a custom menu button to replicate duplicate function. There you may set the posting date as undefined.
that is not 100% true in all scenarios with ERPNext. I.e. if you duplicate a Supplier, the “Billing Currency” field is cleared, even if the original Supplier had a non-default currency.
Another example is a multi-currency Journal Entry. If you duplicate that all accounts involved are set to the default currency. The actual currency of any non-default currency accounts is not copied from the original document.
It appears to do both though that is contradictory:
script clears posting date
script sends to console value of posting_date which confirms it is null (console.log(‘posting_date=>’ + frm.doc.posting_date + ‘<=’); results in posting_date=>null<= in console)
posting date value visible on form is still current date despite reading as null