Skip to content

Commit

Permalink
fix: Added gram, pound to ounce conversion (#21709)
Browse files Browse the repository at this point in the history
* fix: pound, grams to Ounce converion factor added

* fix: patch date updated for UOM Conversion Factor

* fix: grams move to gram

* fix: duplicate entry of uom converion factor and patch added

* fix: typo fix

* fix: minor changes

* Update patches.txt

Co-authored-by: Marica <maricadsouza221197@gmail.com>
  • Loading branch information
vishdha and marination authored May 25, 2020
1 parent 28d1d6c commit 6ff11de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,4 @@ erpnext.patches.v13_0.set_company_field_in_healthcare_doctypes
erpnext.patches.v12_0.update_bom_in_so_mr
execute:frappe.delete_doc("Report", "Department Analytics")
execute:frappe.rename_doc("Desk Page", "Loan Management", "Loan", force=True)
erpnext.patches.v12_0.update_uom_conversion_factor
11 changes: 11 additions & 0 deletions erpnext/patches/v12_0/update_uom_conversion_factor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from __future__ import unicode_literals
import frappe, json

def execute():
from erpnext.setup.setup_wizard.operations.install_fixtures import add_uom_data

frappe.reload_doc("setup", "doctype", "UOM Conversion Factor")
frappe.reload_doc("setup", "doctype", "UOM")
frappe.reload_doc("stock", "doctype", "UOM Category")

add_uom_data()
14 changes: 14 additions & 0 deletions erpnext/setup/setup_wizard/data/uom_conversion_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,5 +1571,19 @@
"to_uom": "Parts Per Million",
"abbr": "ppm",
"value": "10000"
},
{
"category": "Mass",
"from_uom": "Pound",
"to_uom": "Ounce",
"abbr": "oz",
"value": "16"
},
{
"category": "Mass",
"from_uom": "Gram",
"to_uom": "Ounce",
"abbr": "oz",
"value": "0.035274"
}
]
15 changes: 8 additions & 7 deletions erpnext/setup/setup_wizard/operations/install_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,14 @@ def add_uom_data():
"category_name": _(d.get("category"))
}).insert(ignore_permissions=True)

uom_conversion = frappe.get_doc({
"doctype": "UOM Conversion Factor",
"category": _(d.get("category")),
"from_uom": _(d.get("from_uom")),
"to_uom": _(d.get("to_uom")),
"value": d.get("value")
}).insert(ignore_permissions=True)
if not frappe.db.exists("UOM Conversion Factor", {"from_uom": _(d.get("from_uom")), "to_uom": _(d.get("to_uom"))}):
uom_conversion = frappe.get_doc({
"doctype": "UOM Conversion Factor",
"category": _(d.get("category")),
"from_uom": _(d.get("from_uom")),
"to_uom": _(d.get("to_uom")),
"value": d.get("value")
}).insert(ignore_permissions=True)

def add_market_segments():
records = [
Expand Down

0 comments on commit 6ff11de

Please sign in to comment.