Need help removing validation - stock entry

Hi Guys ,

I am really struck with the stock entry module please help me , I am trying to achieve two things

  1. Production order field in the stock entry doc should work even when transferring materials from one warehouse to the other .

  2. Production order field in the stock entry doc should work even when the manufacturing gets completed .

To accomplish this I tried these things without success , please help

First I included the
> Material Issue
> Material Receipt
> Material Transfer
in the stock entry purpose field

then edited the stock_entry.js file as below ,
> clean_up: function() {

    		// Clear Production Order record from locals, because it is updated via Stock Entry
    		if(this.frm.doc.production_order &&
    				in_list(["Manufacture", "Material Transfer for Manufacture","Material Transfer","Material Issue","Material Receipt"], this.frm.doc.purpose)) {
    			frappe.model.remove_from_locals("Production Order",
    				this.frm.doc.production_order);

then , I edited as below to remove the validation and to auto populate the items table when selecting the production order ,

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");
				}
			});
		}
	},

but if I select the production order the field vanishes while saving , also the item_code and qty are not getting auto-populated when I select the production order , instead I am getting a message that manufacturing qty is mandatory .

Guys I am really frustrated , I tried all the possible things I could do .

Please help

Thanks

Sup Muth’s,

Well I have not gone to manufacturing yet but ill try my best to help.
and also maybe you can explain me , Why do you need to do those customizations maybe there is a better way to do this

Well for now Maybe:

  1. def validate_production_order on stock_entry.py conflicts
  2. When the problem triggers when you save the problem could be in stock_entry.py
  3. try checking stock_ledger.py and stock_controller.py
1 Like

Hi @claily ,

Many thanks for the reply , the reason why I need to do these changes is the material gets manufactured in the first workstation/warehouse , then the next operation happens in the next warehouse and while doing this the production order has to be referenced . So when I create a query report and enter the production order number it will display where and when the material has transferred and from which warehouse to the other .
This is indeed a necessary function for all manufacturing companies and I wonder why this is not been done so far.

I tried doing few modifications in stock_entry.py and stock_entry.js file as well , but could not achieve what I want .

When a production order is selected in the stock entry it auto populates the final product and qty only when it is for a manufacturing purpose , I will be glad if I could get the same code working for all the purpose I mean for material transfer,issue,receipt.

Tried to auto populate at-least by these codes but nothing works ,

cur_frm.add_fetch('production_order','production_item','item_code');

cur_frm.add_fetch('production_order','qty','qty');

Please help

Thanks

Im Trying to do a Manafacturing cycle right now to understand possible workarounds or modifications.

I noticed that the Main Goal is to Make a Report or Track Where and When the material has transferred.

Is this correct?

1 Like

Exactly … @claily . Many thanks for spending your time to solve my issue,

Hi @Muthu,

Instead of above code, try below custom script

frappe.ui.form.on('Stock Entry', {
  production_order: function(frm, cdt, cdn) {
    frappe.call({
	method: "frappe.client.get_value",
	args: {
		doctype: "Production Order",
		fieldname: ["production_item", "qty"],
		filters: { name: frm.doc.production_order },
	},
	callback: function(r, rt) {
		if(r.message) {
			frm.set_value("item_code", r.message.production_item);
                        frm.set_value("qty", r.message.qty);
		}
	}
    });
  }
})
3 Likes

Hi @rohit_w , Many thanks for the reply , the above code returns a error message

Field item_code not found.
BOM and Manufacturing Quantity are required.

Please help

Thanks

Hi @rohit_w . I just opened the console and saw the below error being displayed
Uncaught frm.set_value
and
Uncaught Error: BOM and Manufacturing Quantity are required

Any help ?

Thanks

Hi @rohit_w . The field item_code is in a child table items , so I modified the above code to

frm.set_value("item_code","items", r.message.production_item);
frm.set_value("qty","items", r.message.qty);  

But even this is not working . Please help

Thanks

Hi @Muthu,

Can you check and confirm item_code, qty fields are available on stock entry, I hope you have created custom script.

Thanks, Rohit

1 Like

Hi @rohit_w , Many thanks for the reply . I have not created any custom scripts or custom fields .

I ensured item_code field is in the stock entry detail child table inside the stock entry doc .

And also my main concern is I have to refer a production order when issuing or receiving a material , so I created a custom field production_order1 , so I would create a report with reference to the production order but the data in the custom field disappears while saving , It will be of much help atleast if this gets sorted out .

Please help

Thanks

Hi @Muthu,

This will require lot of customisation, you can contact to service provider.

Thanks, Rohit

1 Like

Hi @rohit_w .

Many thanks for the reply , I need help with only one thing , the data in my custom field should not disappear while I save the document .

Any help , Please

Thanks

Guys any help ?

Thanks