Display "Default Warehouse" on Sales Invoice screen?

I have an issue with people needing to make sure they are creating Sales Invoices that pull inventory from one of 11 different warehouses. How can I get that field displayed as a read only field on the sales invoice entry screen?

BKM

Hi @bkm,
not sure if I understand you correctly as I think the material transaction should be on the Delivery Note. Independent, the default warehouse would typically be defined on each item. In order to have a quick view of the used warehouses, why not add a custom script on the items_add (whenever an item is added or removed) and display this in your custom read-only field? Something like this in your Delivery Note customs script:

frappe.ui.form.on('Delivery Note', {
     // whatever here  
})
  
frappe.ui.form.on('Delivery Note Item', {
    items_add: function(frm) {
      // adding a row ... 
      update_warehouse_quickview(frm);
   },
   items_remove: function(frm) {
      // removing a row ... 
      update_warehouse_quickview(frm); 
   }
});

 function update_warehouse_quickview(frm) {
    var warehouses = "";
    frm.doc.items.forEach(function(entry) {
       if (entry.item_code != null) {
          warehouses = warehouses + entry.warehouse
       } 
    }
   cur_frm.set_value('warehouse_quickview', warehouses);
}

Hope this gets you started…

Ah… Maybe I didn’t explain well enough.

“Normally” when a user is creating a “Sales Invoice” they would check the “use POS” box and it would use their POS Profile to set the default warehouse to sell inventory from. This only affects the sale of items.

The Default Warehouse that is part of the Item Record, is where the items are received into from purchase orders, or deposited into from manufacturing production orders. That instance of “Default Warehouse” only affects where the item originates in the company.

Once the items are moved into other warehouses (different locations) the only way (I think) to control how they are sold is by using the POS profile. However, since there are so many people using so few terminals in the business, sometimes a Sales Invoice is started from a terminal logged in by persons with very different POS profiles.

I want to be able to display the Warehouse where the completed sale will pull the stock from to satisfy the transaction.

Currently this is not displayed anywhere and it would be really useful to know. We have had many occasions where the terminal logged in was by another employee from another warehouse across town. When sales were generated, they were deducted from the wrong warehouse and really messed up our inventory.

The display the warehouse that fulfills the sale would be a huge advantage.

BKM

In Sales Invoice Doctype add a custom link field called warehouse and when adding a new sales invoice choose the warehouse you want.

Go to Custom Script and create a new script for Sales Invoice as follows;

frappe.ui.form.on(“Sales Invoice”,“validate”, function(){ for (var i =0; i < cur_frm.doc.items.length; i++){ cur_frm.doc.items[i].warehouse = cur_frm.doc.warehouse }cur_frm.refresh_field(‘items’) });

with help from mrmo

1 Like

Ok, I will have to look into that some more. I am NOT a developer and do not recognizes anything in that command string as familiar. This may be just a bit over my head.

BKM

Search for Custom Field then New custom Field -

then save

1 Like

Hi @Valdanov

I am just learning to customize ERPNext and I have the same need as bkm, but even though I created the custom script and the custom link field for Sales Invoice, I can’t fetch the warehouses in the dropdown and get the following Error in Custom Script:

setup@http://165.227.109.214/assets/js/form.min.js?ver=1548783065.0:1:59918
_f.Frm.prototype.setup@http://165.227.109.214/assets/js/form.min.js?ver=1548783065.0:1:13013
_f.Frm.prototype.refresh@http://165.227.109.214/assets/js/form.min.js?ver=1548783065.0:1:18904
load@http://165.227.109.214/assets/js/form.min.js?ver=1548783065.0:1:11519
show_doc/<@http://165.227.109.214/assets/js/form.min.js?ver=1548783065.0:1:11368
callback@http://165.227.109.214/assets/js/desk.min.js?ver=1548783065.0:1:114620
success@http://165.227.109.214/assets/js/desk.min.js?ver=1548783065.0:1:48777
200@http://165.227.109.214/assets/js/desk.min.js?ver=1548783065.0:1:49145
Rollup

Here are the screenshots of the changes made, but I changed the “Insert After” to Cost Center, because there is no POS Profile in the Sales Invoice Form, and made it Mandatory.

I really appreciate your help.