diff --git a/bloomstack_core/__init__.py b/bloomstack_core/__init__.py index 0835a446..d35d99f0 100644 --- a/bloomstack_core/__init__.py +++ b/bloomstack_core/__init__.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -__version__ = '2.2.0' +__version__ = '2.2.1' diff --git a/bloomstack_core/bloomstack_core/custom/purchase_receipt_item.json b/bloomstack_core/bloomstack_core/custom/purchase_receipt_item.json index 4dd32b9d..073cf5a6 100644 --- a/bloomstack_core/bloomstack_core/custom/purchase_receipt_item.json +++ b/bloomstack_core/bloomstack_core/custom/purchase_receipt_item.json @@ -317,6 +317,59 @@ "translatable": 0, "unique": 0, "width": null + }, + { + "_assign": null, + "_comments": null, + "_liked_by": null, + "_user_tags": null, + "allow_in_quick_entry": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "collapsible_depends_on": null, + "columns": 0, + "creation": "2021-04-28 22:44:11.730666", + "default": null, + "depends_on": null, + "description": null, + "docstatus": 0, + "dt": "Purchase Receipt Item", + "fetch_from": null, + "fetch_if_empty": 0, + "fieldname": "metrc_product_name", + "fieldtype": "Data", + "hidden": 0, + "idx": 7, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "insert_after": "item_name", + "label": "METRC Product Name", + "length": 0, + "modified": "2021-04-28 22:44:11.730666", + "modified_by": "Administrator", + "name": "Purchase Receipt Item-metrc_product_name", + "no_copy": 0, + "options": null, + "owner": "Administrator", + "parent": null, + "parentfield": null, + "parenttype": null, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "print_width": null, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "translatable": 1, + "unique": 0, + "width": null } ], "custom_perms": [], diff --git a/bloomstack_core/bloomtrace/transfer.py b/bloomstack_core/bloomtrace/transfer.py index 9cf2dda7..d01fd543 100644 --- a/bloomstack_core/bloomtrace/transfer.py +++ b/bloomstack_core/bloomtrace/transfer.py @@ -5,12 +5,11 @@ def create_purchase_receipt(transfer): transfer = frappe.parse_json(transfer) for item in transfer.get("items", []): - item_exists = frappe.get_all("Item", filters={"metrc_item_name": item.pop("product_name")}, fields=["name", "item_name"]) - if item_exists: - item.update({ - "item_code": item_exists[0].name, - "item_name": item_exists[0].item_name - }) + supplier_item = frappe.db.get_all("Item Supplier", filters={"supplier_part_no": item.get("product_name")}, fields=["parent"]) + item.update({ + "item_code": supplier_item[0].parent if supplier_item else None, + "metrc_product_name": item.get("product_name") + }) doc = frappe.get_doc({"doctype": "Purchase Receipt"}) doc.update(transfer)