gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
i want create client script on frappe to edit date when sales invoice refresh but if…
- User
i want create client script on frappe to edit date when sales invoice refresh but if it's new
- Assistant
To create a client script on Frappe that edits the date when a Sales Invoice is refreshing for a new record, you can follow these steps:
- Go to the "Custom Scripts" doctype in Frappe.
- Click on "New" to create a new client script.
- Set the "DocType" field to "Sales Invoice".
- Set the "Script Type" field to "Client".
- In the "Script" field, enter the following code:
frappe.ui.form.on('Sales Invoice', { refresh: function(frm) { if (frm.doc.__islocal) { // Check if it is a new record var newDate = frappe.datetime.now_date(); // Set new date frm.set_value('posting_date', newDate); // Update posting_date field } } });- Save the script.
Now, whenever a Sales Invoice is refreshed, if it's a new record, the script will automatically update the
posting_datefield with the current date.Note: Make sure you have the necessary permissions to create and manage custom scripts in your Frappe instance.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.