Please help , the following script works everywhere but not in the production module , I do have a field where the qty entered in the production order should automatically get entered ,
{
function compute(doc, cdt, cdn){
if (doc.qty){
doc.qty1 = doc.qty;
refresh_field("qty1");
}}
cur_frm.cscript.custom_qty = compute;
}
not even able to access the qty field in the production module by this command ,
@Muthu,
Is there any other function in which you have write this script? [quote=“Muthu, post:1, topic:15317”]
function compute(doc, cdt, cdn){
if (doc.qty){
doc.qty1 = doc.qty;
refresh_field(“qty1”);
}}
cur_frm.cscript.custom_qty = compute;
[/quote]
I dont have any scripts other than this . My actual problem is when I call the production order number in the stock entry doc it should automatically fetch the item and qty even when the production gets completed . since I am not able to achieve this I am trying weird methods to accomplish this .
Could you please help me with some server side scripts to achieve the above thing .
Thanks a lot for the quick response , entering the above code bricks the system , and I opened the console to see the logs , I saw this VM3425:502 Uncaught SyntaxError: Unexpected token ) but could not figure out exactly where the syntax is wrong .
Also the production order field is not working if the manufacturing is completed . Could you please help me how to override this validation with the server side scripting ?
The problem with your script is that your function never gets called. You probably want it to get triggered when the production order number gets entered:
frappe.ui.form.on("Stock Entry", "production_order", function (doc, cdt, cdn) {
if (doc.qty){
doc.qty1 = doc.qty;
refresh_field("qty1");
}}
})
I’m not quite sure I understand what you’re trying to do though. Is it that you want each of the items from the production order to fill in for the stock entry?
@Nishant_Jariwala . @Ben_Cornwell_Mott. Many thanks for the support. From my observation one thing is clear there is already a code available fro my problem . The only thing I need to do is get the production_order field in the stock entry doc to work even if the manufacturing gets completed .
Please could you guide me how to remove the validation here ?
What I want is ,in stock entry I have to refer the production order number when transferring the materials from one workstation to the other even when the manufacturing gets completed . Once the manufacturing is completed I am not able to use the production order , it shows a error message that BOM is required.
There is a validation in stock entry.py file which has to be removed to achieve this . Could you help me please.
So the issue is that one of these fields is not set:
frm.doc.fg_completed_qty
frm.doc.bom_no
If you use the developer console, you can see which one isn’t getting set and potentially copy the script from stock_entry.js and bypass that. The function that gets called when you enter the production order number is linked here:
I tried to set the values manually with the below code but it is not working , please help . Again same issue I am getting error message that , BOM and manuf qty are required
erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
get_items: function() {
var me = this;
if(!this.frm.doc.fg_completed_qty || !this.frm.doc.bom_no)
{
// if production order / bom is mentioned, get items
return this.frm.call({
doc: me.frm.doc,
method: "get_items",
callback: function(r) {
if(!r.exc) refresh_field("items");
}
});
}
}});
@Ben_Cornwell_Mott . I understand this code in the stock_entry.py file has to be edited , could you please help me on this ?
def validate_production_order(self):
if self.purpose in ("Manufacture", "Material Transfer for Manufacture"):
# check if production order is entered
if self.purpose=="Manufacture" and self.production_order:
if not self.fg_completed_qty:
frappe.throw(_("For Quantity (Manufactured Qty) is mandatory"))
self.check_if_operations_completed()
self.check_duplicate_entry_for_production_order()
elif self.purpose != "Material Transfer":
self.production_order = None