UOM
UOM Doctypes
A Unit of Measure (UOM) is a unit using which an Item is measured.
-
UOM Category A UOM (Unit of Measure) Category is a way to group similar units of measure. For example, you might have a UOM Category for length that includes units like meters, centimeters, and millimeters. Another UOM Category for weight might include units like kilograms and grams. This Doctype contains only one field Category Name.
-
UOM UOM (Unit of Measure) doctype contains 3 fields:
- Enabled: If checked, the UOM is available to use else it is not available to use anywhere. However existing documents will continue to use it.
- Name: Name of the UOM.
- Must be a Whole Number: If checked, the value of the UOM must be a Whole number else it will throw an error. Eg: Checked in case of Dozen or Unit and Unchecked in case of Kg or Pound.
-
UOM Conversion Factor UOM (Unit of Measure) Conversion Factor is a crucial feature that allows you to define the relationship between different units of measure for the same item. This conversion factor is necessary when dealing with diverse units for the same product in various aspects of your business, such as purchasing, selling, and inventory management. Here's how UOM Conversion Factor works:
- Category: This is the UOM Category i.e. Mass, Energy, Density etc.
- From: This refers to the original or source unit of measure that you are converting from. It is the unit in which the quantity is initially specified.
- To: This is the target or destination unit of measure to which you want to convert the quantity. It is the unit in which you want the quantity to be represented or stored.
- Value: It represents the numerical factor by which you multiply the quantity in the
From UOM
to obtain the equivalent quantity in theTo UOM
. It defines the conversion ratio between the two units.
-
UOM Conversion Detail UOM Conversion Detail is a child table that appears while creating a New Item. This table contains two fields:
- UOM: This defines the UOM that is to be associated with the Item. Eg: For an Item Rice, UOM's could be Tonnes, Kg, Milligrams etc.
- Conversion Factor: Conversion Factor defines the multiplication factor between different uoms of same category. These values are automatically populated if the conversion for the same is available in the UOM Conversion Factor doctype. Default UOM is mandatory for the conversion.
Implementation
UOM can be implemented in the following manner:
-
Create doctype
UOM Category
. -
Create doctype
UOM
. -
Create doctype
UOM Conversion Factor
. -
Create doctype
UOM Conversion Detail
and setIs Child Table
.
UOM Implementation is complete here.
Now we consume the UOM in Item and Item Price.
-
Create doctype
Item
. SetUOMs
toUOM Conversion Detail
table. Set theDisplay Depends On
property for theUOMs
table so that it is only visible when theDefault UOM
is selected. -
Include functions in item.js to set UOMs table to blank when the default UOM is changed and also to call a whitelisted function from item.py to fetch the relevant conversion factor for a particular UOM in the table.
-
Create doctype
Item Price
.
Using Item and Item Price we can create Sales Invoice Item and Sales Invoice.
-
Create doctype
Sales Invoice Item
and setIs Child Table
. -
Create doctype
Sales Invoice
. -
Include functions in sales-invoice.js to accomplish the following tasks:
- Fetch the uom, rate, quantity for the uom and calculate the amount when a particular item is selected.
- Get the conversion factor when the UOM is changed.
- Calculate the amount whenever uom, qty and rate gets manipulated.
-
Add function in sales-invoice.py to throw an error when a UOM is set to whole number and a fraction is entered or vice versa.
Example
1. Create UOM Category
Create a UOM Category Mass
.
2. Create UOM
Create a UOM Grams
and since grams are not whole numbers we keep the Must be a Whole Number
unchecked. Similarly multiple UOMs like Tonne, Kg, Milligrams etc can be created.
3. Create UOM Conversion Factor
- Select a UOM Category.
- Select
From
andTo
UOM. - Enter the multiplication factor for conversion.
- Save.
4. Create Item
- Enter the
Item Name
andItem Code
. - Select the Default UOM.
- Add the relevant UOMs to the table depending upon the item. The corresponding
Conversion Factor
will be automatically populated. - Save.
5. Create Item Price
- Select Item.
Name
andUOM
be automatically populated. - Enter the
Rate
for the item for the particular UOM. - Save.
6. Create Sales Invoice
- Add
Item
to the table. All the other details are automatically populated. Quantity
andRate
changes will affect theAmount