Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added gram, pound to ounce conversion #21709

Merged
merged 7 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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