Units in Carton

We sell item in units, however for ease of customers we have to show the number of carton for each item.

For this, I created a custom field “Units in Ctn” in Items doctype. Now while making sales invoices, as soon as the user select a product I want fetch the “Units in Ctn” from Items table as readonly field.

Also after user enter the Qty, I want to show Total ctns in another readonly field

Please guide on how this can be achieved.

Once this is done then I can update my Sales Invoice print format to show Ctns as well as Units.

regards,
Atif

Hi Atif

  1. In Sales Invoice Item, create a custom field called “Units in Ctn” and “Total Ctns” both as Read Only

  2. In the options of The new custom field Units in Ctn specify item_code.units_in_ctn. This will fetch units in ctn from item form whenever you select an item code

  3. In custom script of sales invoice form, write the code to set total Ctns on change of qty

    cur_frm.cscript.custom_qty = function(doc, cdt, can) {
        var item = frappe.get_doc(cdt, cdn);
        item.total_ctns = item.qty * item.units_in_ctn;
    }
    

-Anand

1 Like

@anand I tried this. A new field is showing up in “sales invoice item” but now fetching the units_in_ctn whenever an item is selected? An idea why?

If it is fetching isn’t that what you wanted?

sorry typo. Its NOT fetching the units_in_ctn whenver an item is selected.

Hi Anand,

This is an interesting feature and we ate struggling to put a count on units in a carton. If you could look at adding it as a base feature that would be great. At least please add this on your list of potential features.

Thanks,
Vikram

@anand
Its not fetching the data. I have added a new custom field “units_in_ctn” in “Sales invoice item” and written following code “item_code.units_in_ctn” in options. But nothing happens. An other idea?