Skip to content

Commit ebbf4bd

Browse files
committed
fix: add custom field in Purchase Receipt Line Item and search it in supplier part name in Supplier Items
1 parent c6ad91a commit ebbf4bd

2 files changed

Lines changed: 228 additions & 5 deletions

File tree

bloomstack_core/bloomstack_core/custom/purchase_receipt_item.json

Lines changed: 216 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,225 @@
317317
"translatable": 0,
318318
"unique": 0,
319319
"width": null
320+
},
321+
{
322+
"_assign": null,
323+
"_comments": null,
324+
"_liked_by": null,
325+
"_user_tags": null,
326+
"allow_in_quick_entry": 0,
327+
"allow_on_submit": 0,
328+
"bold": 0,
329+
"collapsible": 0,
330+
"collapsible_depends_on": null,
331+
"columns": 0,
332+
"creation": "2021-04-28 22:44:11.730666",
333+
"default": null,
334+
"depends_on": null,
335+
"description": null,
336+
"docstatus": 0,
337+
"dt": "Purchase Receipt Item",
338+
"fetch_from": null,
339+
"fetch_if_empty": 0,
340+
"fieldname": "metrc_product_name",
341+
"fieldtype": "Data",
342+
"hidden": 0,
343+
"idx": 7,
344+
"ignore_user_permissions": 0,
345+
"ignore_xss_filter": 0,
346+
"in_global_search": 0,
347+
"in_list_view": 0,
348+
"in_standard_filter": 0,
349+
"insert_after": "item_name",
350+
"label": "METRC Product Name",
351+
"length": 0,
352+
"modified": "2021-04-28 22:44:11.730666",
353+
"modified_by": "Administrator",
354+
"name": "Purchase Receipt Item-metrc_product_name",
355+
"no_copy": 0,
356+
"options": null,
357+
"owner": "Administrator",
358+
"parent": null,
359+
"parentfield": null,
360+
"parenttype": null,
361+
"permlevel": 0,
362+
"precision": "",
363+
"print_hide": 0,
364+
"print_hide_if_no_value": 0,
365+
"print_width": null,
366+
"read_only": 0,
367+
"report_hide": 0,
368+
"reqd": 0,
369+
"search_index": 0,
370+
"translatable": 1,
371+
"unique": 0,
372+
"width": null
320373
}
321374
],
322375
"custom_perms": [],
323376
"doctype": "Purchase Receipt Item",
324-
"property_setters": [],
377+
"property_setters": [
378+
{
379+
"_assign": null,
380+
"_comments": null,
381+
"_liked_by": null,
382+
"_user_tags": null,
383+
"creation": "2021-04-13 07:49:15.610098",
384+
"default_value": null,
385+
"doc_type": "Purchase Receipt Item",
386+
"docstatus": 0,
387+
"doctype_or_field": "DocField",
388+
"field_name": "barcode",
389+
"idx": 0,
390+
"modified": "2021-04-13 07:49:15.610098",
391+
"modified_by": "Administrator",
392+
"name": "Purchase Receipt Item-barcode-hidden",
393+
"owner": "Administrator",
394+
"parent": null,
395+
"parentfield": null,
396+
"parenttype": null,
397+
"property": "hidden",
398+
"property_type": "Check",
399+
"value": "0"
400+
},
401+
{
402+
"_assign": null,
403+
"_comments": null,
404+
"_liked_by": null,
405+
"_user_tags": null,
406+
"creation": "2020-06-17 21:49:12.690134",
407+
"default_value": null,
408+
"doc_type": "Purchase Receipt Item",
409+
"docstatus": 0,
410+
"doctype_or_field": "DocField",
411+
"field_name": "amount",
412+
"idx": 0,
413+
"modified": "2020-06-17 21:49:12.690134",
414+
"modified_by": "Administrator",
415+
"name": "Purchase Receipt Item-amount-precision",
416+
"owner": "Administrator",
417+
"parent": null,
418+
"parentfield": null,
419+
"parenttype": null,
420+
"property": "precision",
421+
"property_type": "Select",
422+
"value": ""
423+
},
424+
{
425+
"_assign": null,
426+
"_comments": null,
427+
"_liked_by": null,
428+
"_user_tags": null,
429+
"creation": "2020-06-16 06:41:21.873069",
430+
"default_value": null,
431+
"doc_type": "Purchase Receipt Item",
432+
"docstatus": 0,
433+
"doctype_or_field": "DocField",
434+
"field_name": "rate",
435+
"idx": 0,
436+
"modified": "2020-06-16 06:41:21.873069",
437+
"modified_by": "Administrator",
438+
"name": "Purchase Receipt Item-rate-precision",
439+
"owner": "Administrator",
440+
"parent": null,
441+
"parentfield": null,
442+
"parenttype": null,
443+
"property": "precision",
444+
"property_type": "Select",
445+
"value": ""
446+
},
447+
{
448+
"_assign": null,
449+
"_comments": null,
450+
"_liked_by": null,
451+
"_user_tags": null,
452+
"creation": "2019-01-22 01:47:37.675837",
453+
"default_value": null,
454+
"doc_type": "Purchase Receipt Item",
455+
"docstatus": 0,
456+
"doctype_or_field": "DocType",
457+
"field_name": null,
458+
"idx": 0,
459+
"modified": "2019-01-22 01:47:37.675837",
460+
"modified_by": "Administrator",
461+
"name": "Purchase Receipt Item-read_only_onload",
462+
"owner": "Administrator",
463+
"parent": null,
464+
"parentfield": null,
465+
"parenttype": null,
466+
"property": "read_only_onload",
467+
"property_type": "Check",
468+
"value": null
469+
},
470+
{
471+
"_assign": null,
472+
"_comments": null,
473+
"_liked_by": null,
474+
"_user_tags": null,
475+
"creation": "2018-12-28 01:09:58.341633",
476+
"default_value": null,
477+
"doc_type": "Purchase Receipt Item",
478+
"docstatus": 0,
479+
"doctype_or_field": "DocField",
480+
"field_name": "include_exploded_items",
481+
"idx": 0,
482+
"modified": "2018-12-28 01:09:58.341633",
483+
"modified_by": "Administrator",
484+
"name": "Purchase Receipt Item-include_exploded_items-print_hide",
485+
"owner": "Administrator",
486+
"parent": null,
487+
"parentfield": null,
488+
"parenttype": null,
489+
"property": "print_hide",
490+
"property_type": "Check",
491+
"value": "1"
492+
},
493+
{
494+
"_assign": null,
495+
"_comments": null,
496+
"_liked_by": null,
497+
"_user_tags": null,
498+
"creation": "2018-12-28 01:09:58.309922",
499+
"default_value": null,
500+
"doc_type": "Purchase Receipt Item",
501+
"docstatus": 0,
502+
"doctype_or_field": "DocField",
503+
"field_name": "weight_per_unit",
504+
"idx": 0,
505+
"modified": "2018-12-28 01:09:58.309922",
506+
"modified_by": "Administrator",
507+
"name": "Purchase Receipt Item-weight_per_unit-print_hide",
508+
"owner": "Administrator",
509+
"parent": null,
510+
"parentfield": null,
511+
"parenttype": null,
512+
"property": "print_hide",
513+
"property_type": "Check",
514+
"value": "1"
515+
},
516+
{
517+
"_assign": null,
518+
"_comments": null,
519+
"_liked_by": null,
520+
"_user_tags": null,
521+
"creation": "2018-12-28 01:08:18.955108",
522+
"default_value": null,
523+
"doc_type": "Purchase Receipt Item",
524+
"docstatus": 0,
525+
"doctype_or_field": "DocField",
526+
"field_name": "purchase_order",
527+
"idx": 0,
528+
"modified": "2018-12-28 01:08:18.955108",
529+
"modified_by": "Administrator",
530+
"name": "Purchase Receipt Item-purchase_order-print_hide",
531+
"owner": "Administrator",
532+
"parent": null,
533+
"parentfield": null,
534+
"parenttype": null,
535+
"property": "print_hide",
536+
"property_type": "Check",
537+
"value": "0"
538+
}
539+
],
325540
"sync_on_migrate": 1
326541
}

bloomstack_core/bloomtrace/transfer.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ def create_purchase_receipt(transfer):
55
transfer = frappe.parse_json(transfer)
66

77
for item in transfer.get("items", []):
8-
item_exists = frappe.get_all("Item", filters={"metrc_item_name": item.pop("product_name")}, fields=["name", "item_name"])
9-
if item_exists:
8+
item_code = frappe.db.sql("""
9+
SELECT
10+
item_supp.parent
11+
FROM
12+
`tabItem Supplier` as item_supp,
13+
WHERE item_supp.supplier_part_number = %(supplier)s
14+
""", {"supplier": item.get("product_name")}, as_dict=1)
15+
if item_code:
16+
item_exists = frappe.get_all("Item", filters={"item_code": item_code}, fields=["name", "item_name"])
1017
item.update({
11-
"item_code": item_exists[0].name,
12-
"item_name": item_exists[0].item_name
18+
"item_code" : item_exists[0].name,
19+
"item_name" : item_exists[0].item_name,
20+
"metrc_product_name": item.get("product_name")
1321
})
1422

1523
doc = frappe.get_doc({"doctype": "Purchase Receipt"})

0 commit comments

Comments
 (0)