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

feat: Enhanced UOM Conversions Table #15865

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
836661b
Added ability to select multiply or divide for item uom conversion fa…
SaiFi0102 Sep 19, 2018
15be06c
Should not remove conversion_factor=1 since it is still a valid value…
SaiFi0102 Sep 26, 2018
4782b71
Remove UOMs with 0 conversion factors
SaiFi0102 Sep 26, 2018
a962d19
Use '/' instead of '*' as default since that's ERPNext's convention
SaiFi0102 Sep 29, 2018
6594747
Graph based UOM Conversion:
SaiFi0102 Oct 30, 2018
6bb0cf6
Merge branch 'staging' of https://saifi0102@github.com/SaiFi0102/erpn…
SaiFi0102 Oct 30, 2018
6790949
Assert from_uom != to_uom
SaiFi0102 Oct 30, 2018
c52bfb4
Added patch
SaiFi0102 Oct 30, 2018
aa00ab8
-Hide old UOMs table to prevent tracking changes everytime item is saved
SaiFi0102 Oct 30, 2018
1bee863
Update Conversion Factors table only if anything has changed
SaiFi0102 Oct 31, 2018
e70f78f
Attempted to fix tests
SaiFi0102 Nov 2, 2018
2b335a3
Improved validation for UOM Conversion Factors overriding values
SaiFi0102 Nov 2, 2018
a45f79e
Increased conversion_factors' precision 9
SaiFi0102 Nov 2, 2018
ad1cb82
Merge branch 'staging' of https://github.com/frappe/erpnext into UOM-…
SaiFi0102 Nov 24, 2018
8473edb
Merge branch 'staging' of https://github.com/frappe/erpnext into UOM-…
SaiFi0102 Dec 2, 2018
fb96308
Merge branch 'staging' of https://github.com/frappe/erpnext into UOM-…
SaiFi0102 Dec 27, 2018
5c9cca2
Merge branch 'staging' of https://github.com/frappe/erpnext.git into …
SaiFi0102 Jan 27, 2019
5b1f97b
test: Use `uom_conversion_graph` for test_records rather than `uoms`
SaiFi0102 Jan 30, 2019
f1662ae
fix: UOM dependent price calculation
SaiFi0102 Jan 30, 2019
94673cf
Merge branch 'master' of https://github.com/frappe/erpnext.git into U…
SaiFi0102 Jan 30, 2019
f8d7ea0
fix: minor change
SaiFi0102 Jan 30, 2019
fa08641
test: Remove workaround for incorrect use of price_not_uom_dependant
SaiFi0102 Jan 31, 2019
b273f5e
test(Item): test_uom_conversion_graph
SaiFi0102 Jan 31, 2019
528e6fb
fix: Handle conversion factor precision problems slightly better
SaiFi0102 Jan 31, 2019
79f4b9c
fix: patch item_uom_conversion_table
SaiFi0102 Jan 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions erpnext/accounts/doctype/loyalty_program/loyalty_program.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
Expand Down Expand Up @@ -390,7 +391,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
Expand Down Expand Up @@ -639,7 +640,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-07-10 19:15:24.994385",
"modified": "2018-10-30 15:14:36.888426",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Loyalty Program",
Expand Down
8 changes: 5 additions & 3 deletions erpnext/accounts/doctype/pricing_rule/test_pricing_rule.py
Expand Up @@ -228,9 +228,11 @@ def test_pricing_rule_for_stock_qty(self):
if not frappe.db.get_value('UOM Conversion Detail',
{'parent': '_Test Item', 'uom': 'box'}):
item = frappe.get_doc('Item', '_Test Item')
item.append('uoms', {
'uom': 'Box',
'conversion_factor': 5
item.append('uom_conversion_graph', {
'from_qty': 1,
'from_uom': 'Box',
'to_qty': 5, # conversion factor
'to_uom': item.stock_uom
})
item.save(ignore_permissions=True)

Expand Down
Expand Up @@ -486,7 +486,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -2626,7 +2626,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:52:00.749414",
"modified": "2018-10-30 15:14:34.952705",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",
Expand All @@ -2641,4 +2641,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -515,7 +515,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
Expand Down Expand Up @@ -2766,7 +2766,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:51:55.018091",
"modified": "2018-10-30 15:14:16.938130",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",
Expand All @@ -2781,4 +2781,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -562,7 +562,7 @@
"oldfieldname": "conversion_factor",
"oldfieldtype": "Currency",
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"print_width": "100px",
Expand Down Expand Up @@ -2344,7 +2344,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:51:57.546323",
"modified": "2018-10-30 15:14:15.694415",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",
Expand All @@ -2359,4 +2359,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -299,6 +299,7 @@
"oldfieldname": "conversion_factor",
"oldfieldtype": "Currency",
"permlevel": 0,
"precision": "9",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -388,7 +389,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:51:58.016007",
"modified": "2018-10-30 15:14:24.115744",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item Supplied",
Expand All @@ -401,4 +402,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -398,6 +398,7 @@
"oldfieldname": "conversion_factor",
"oldfieldtype": "Currency",
"permlevel": 0,
"precision": "9",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -519,7 +520,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:51:59.536291",
"modified": "2018-10-30 15:14:25.023990",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Receipt Item Supplied",
Expand All @@ -534,4 +535,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -620,7 +620,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -1786,7 +1786,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:52:02.125715",
"modified": "2018-10-30 15:14:22.358993",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier Quotation Item",
Expand All @@ -1801,4 +1801,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -291,7 +291,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -411,7 +411,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2018-11-04 03:33:16.833884",
"modified": "2018-11-04 03:33:16.833885",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Clinical Procedure Item",
Expand All @@ -428,4 +428,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
1 change: 0 additions & 1 deletion erpnext/manufacturing/doctype/bom/test_bom.py
Expand Up @@ -97,7 +97,6 @@ def test_bom_cost(self):
self.assertEqual(bom.base_total_cost, 486000)

def test_bom_cost_multi_uom_multi_currency(self):
frappe.db.set_value("Price List", "_Test Price List", "price_not_uom_dependant", 1)
for item_code, rate in (("_Test Item", 3600), ("_Test Item Home Desktop Manufactured", 3000)):
frappe.db.sql("delete from `tabItem Price` where price_list='_Test Price List' and item_code=%s",
item_code)
Expand Down
4 changes: 2 additions & 2 deletions erpnext/manufacturing/doctype/bom_item/bom_item.json
Expand Up @@ -588,7 +588,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
Expand Down Expand Up @@ -1115,4 +1115,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}
1 change: 1 addition & 0 deletions erpnext/patches.txt 100755 → 100644
Expand Up @@ -576,6 +576,7 @@ erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09
erpnext.patches.v11_0.drop_column_max_days_allowed
erpnext.patches.v11_0.change_healthcare_desktop_icons
erpnext.patches.v10_0.update_user_image_in_employee
erpnext.patches.v11_0.item_uom_conversion_table
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
erpnext.patches.v10_0.allow_operators_in_supplier_scorecard
erpnext.patches.v11_0.update_delivery_trip_status
Expand Down
30 changes: 30 additions & 0 deletions erpnext/patches/v11_0/item_uom_conversion_table.py
@@ -0,0 +1,30 @@
import frappe
from frappe.utils import flt

def execute():
frappe.reload_doc("stock", "doctype", "item")
frappe.reload_doc("stock", "doctype", "uom_conversion_detail")
frappe.reload_doc("stock", "doctype", "uom_conversion_graph")

names = frappe.get_all("Item")
for name in names:
doc = frappe.get_doc("Item", name)
for d in doc.uoms:
if d.uom == doc.stock_uom:
continue

if abs(d.conversion_factor) >= 1:
conv = doc.append("uom_conversion_graph", {
"from_qty": flt(d.conversion_factor, doc.precision("to_qty", "uom_conversion_graph")),
"from_uom": doc.stock_uom,
"to_qty": 1.0,
"to_uom": d.uom
})
else:
conv = doc.append("uom_conversion_graph", {
"from_qty": 1.0,
"from_uom": doc.stock_uom,
"to_qty": flt(1/flt(d.conversion_factor), doc.precision("to_qty", "uom_conversion_graph")),
"to_uom": d.uom
})
conv.db_insert()
6 changes: 3 additions & 3 deletions erpnext/selling/doctype/quotation_item/quotation_item.json
Expand Up @@ -494,7 +494,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -1914,7 +1914,7 @@
"istable": 1,
"max_attachments": 0,
"menu_index": 0,
"modified": "2019-01-07 16:51:56.248107",
"modified": "2018-12-27 05:52:46.135944",
"modified_by": "Administrator",
"module": "Selling",
"name": "Quotation Item",
Expand All @@ -1929,4 +1929,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -558,7 +558,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -2477,7 +2477,7 @@
"istable": 1,
"max_attachments": 0,
"menu_index": 0,
"modified": "2019-01-07 16:51:51.852343",
"modified": "2018-10-30 15:14:26.284151",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",
Expand All @@ -2492,4 +2492,4 @@
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}
}
Expand Up @@ -525,7 +525,7 @@
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"precision": "9",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
Expand Down Expand Up @@ -2310,7 +2310,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-01-07 16:51:53.322875",
"modified": "2018-10-30 15:14:19.900827",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note Item",
Expand All @@ -2325,4 +2325,4 @@
"track_changes": 0,
"track_seen": 0,
"track_views": 0
}
}