Skip to content

Commit da1a743

Browse files
committed
Merge branch 'staging' into production
2 parents 8399ae7 + 6b2f9c9 commit da1a743

File tree

20 files changed

+374
-357
lines changed

20 files changed

+374
-357
lines changed

bloomstack_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4-
__version__ = '2.0.13'
4+
__version__ = '2.1.0'

bloomstack_core/bloomtrace/utils.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (c) 2021, Bloomstack Inc. and contributors
3+
# For license information, please see license.txt
4+
15
import frappe
26
from frappe.frappeclient import FrappeClient, AuthError
37

@@ -20,14 +24,29 @@ def get_bloomtrace_client():
2024
return client
2125

2226

23-
def make_integration_request(doctype, docname):
24-
if frappe.conf.enable_bloomtrace:
25-
integration_request = frappe.new_doc("Integration Request")
26-
integration_request.update({
27-
"integration_type": "Remote",
28-
"integration_request_service": "BloomTrace",
29-
"status": "Queued",
30-
"reference_doctype": doctype,
31-
"reference_docname": docname
32-
})
33-
integration_request.save(ignore_permissions=True)
27+
def make_integration_request(doctype, docname, endpoint):
28+
settings = frappe.get_cached_doc("Compliance Settings")
29+
if not (frappe.conf.enable_bloomtrace and settings.is_compliance_enabled) or \
30+
frappe.db.exists("Integration Request", {"reference_doctype": doctype, "reference_docname": docname, "endpoint": endpoint}):
31+
return
32+
33+
doc = frappe.get_doc(doctype, docname)
34+
company = settings.get("company", {"company": doc.company}) and settings.get("company", {"company": doc.company})[0]
35+
fieldname = "push_{0}".format(frappe.scrub(endpoint))
36+
37+
if not company or not company.get(fieldname):
38+
return
39+
40+
integration_request = frappe.get_doc({
41+
"doctype": "Integration Request",
42+
"integration_type": "Remote",
43+
"integration_request_service": "BloomTrace",
44+
"status": "Queued",
45+
"reference_doctype": doctype,
46+
"reference_docname": docname,
47+
"endpoint": endpoint
48+
}).save(ignore_permissions=True)
49+
50+
51+
def create_integration_request(doc, method):
52+
make_integration_request(doc.doctype, doc.name)

bloomstack_core/compliance/item.py

Lines changed: 0 additions & 91 deletions
This file was deleted.

bloomstack_core/compliance/package.py

Lines changed: 0 additions & 174 deletions
This file was deleted.
Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import frappe
12
from bloomstack_core.bloomtrace import get_bloomtrace_client
23
from frappe.utils import get_host_name
34

@@ -11,16 +12,37 @@ def sync_bloomtrace(compliance_settings, method):
1112
return
1213

1314
site_url = get_host_name()
14-
frappe_client.update({
15-
"doctype": "Bloomstack Site",
16-
"name": site_url
17-
})
1815

19-
for company in compliance_settings.company:
16+
try:
2017
frappe_client.update({
21-
"doctype": "Bloomstack Company",
22-
"name": company.company,
23-
"metrc_push_data": company.push_data,
24-
"metrc_pull_data": company.pull_data,
25-
"pull_incoming_transfer": company.pull_incoming_transfer
18+
"doctype": "Bloomstack Site",
19+
"name": site_url,
20+
"metrc_user_key": compliance_settings.get_password("metrc_user_key")
2621
})
22+
except Exception as e:
23+
frappe.log_error(e)
24+
25+
for company in compliance_settings.company:
26+
try:
27+
frappe_client.update({
28+
"doctype": "Bloomstack Company",
29+
"name": company.company,
30+
"push_item": company.push_item,
31+
"pull_item": company.pull_item,
32+
"push_package_tag": company.push_package_tag,
33+
"pull_package_tag": company.pull_package_tag,
34+
"pull_transfer": company.pull_transfer,
35+
"push_transfer": company.push_transfer,
36+
"pull_plant": company.pull_plant,
37+
"push_plant": company.push_plant,
38+
"pull_plant_batch": company.pull_plant_batch,
39+
"push_plant_batch": company.push_plant_batch,
40+
"pull_strain": company.pull_strain,
41+
"push_strain": company.push_strain,
42+
"pull_harvest": company.pull_harvest,
43+
"push_harvest": company.push_harvest,
44+
"pull_package": company.pull_package,
45+
"push_package": company.push_package
46+
})
47+
except Exception as e:
48+
frappe.log_error(e)

0 commit comments

Comments
 (0)