Skip to content

Commit c6e45c3

Browse files
committed
Merge branch 'staging' into production
2 parents 0349b9d + 3ee8fa8 commit c6e45c3

File tree

11 files changed

+60
-180
lines changed

11 files changed

+60
-180
lines changed

.github/semantic.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Always validate the PR title AND all the commits
2+
titleAndCommits: true
3+
4+
# Allow use of Merge commits (eg on github: "Merge branch 'master' into feature/ride-unicorns")
5+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
6+
allowMergeCommits: true
7+
8+
# Allow use of Revert commits (eg on github: "Revert "feat: ride unicorns"")
9+
# this is only relevant when using commitsOnly: true (or titleAndCommits: true)
10+
allowRevertCommits: true
11+
12+
# For allowed PR types: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json
13+
# Tool Reference: https://github.com/zeke/semantic-pull-requests

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.2'
4+
__version__ = '2.0.3'

bloomstack_core/bloomstack_core/custom/sales_invoice.json

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -195,29 +195,6 @@
195195
"property_type": "Check",
196196
"value": "0"
197197
},
198-
{
199-
"_assign": null,
200-
"_comments": null,
201-
"_liked_by": null,
202-
"_user_tags": null,
203-
"creation": "2018-11-28 05:10:48.191961",
204-
"default_value": null,
205-
"doc_type": "Sales Invoice",
206-
"docstatus": 0,
207-
"doctype_or_field": "DocField",
208-
"field_name": "naming_series",
209-
"idx": 0,
210-
"modified": "2018-11-28 05:10:48.191961",
211-
"modified_by": "Administrator",
212-
"name": "Sales Invoice-naming_series-options",
213-
"owner": "Administrator",
214-
"parent": null,
215-
"parentfield": null,
216-
"parenttype": null,
217-
"property": "options",
218-
"property_type": "Text",
219-
"value": "ACC-SINV-.YYYY.-"
220-
},
221198
{
222199
"_assign": null,
223200
"_comments": null,
@@ -265,5 +242,5 @@
265242
"value": "0"
266243
}
267244
],
268-
"sync_on_migrate": 1
245+
"sync_on_migrate": 0
269246
}

bloomstack_core/bloomstack_core/custom/user.json

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,5 @@
11
{
2-
"custom_fields": [
3-
{
4-
"_assign": null,
5-
"_comments": null,
6-
"_liked_by": null,
7-
"_user_tags": null,
8-
"allow_in_quick_entry": 0,
9-
"allow_on_submit": 0,
10-
"bold": 0,
11-
"collapsible": 0,
12-
"collapsible_depends_on": null,
13-
"columns": 0,
14-
"creation": "2020-05-31 03:05:56.425375",
15-
"default": null,
16-
"depends_on": null,
17-
"description": null,
18-
"docstatus": 0,
19-
"dt": "User",
20-
"fetch_from": null,
21-
"fetch_if_empty": 0,
22-
"fieldname": "column_break_2",
23-
"fieldtype": "Column Break",
24-
"hidden": 0,
25-
"idx": 3,
26-
"ignore_user_permissions": 0,
27-
"ignore_xss_filter": 0,
28-
"in_global_search": 0,
29-
"in_list_view": 0,
30-
"in_standard_filter": 0,
31-
"insert_after": "enabled",
32-
"label": null,
33-
"length": 0,
34-
"modified": "2020-05-31 03:05:56.425375",
35-
"modified_by": "Administrator",
36-
"name": "User-column_break_2",
37-
"no_copy": 0,
38-
"options": null,
39-
"owner": "Administrator",
40-
"parent": null,
41-
"parentfield": null,
42-
"parenttype": null,
43-
"permlevel": 0,
44-
"precision": "",
45-
"print_hide": 0,
46-
"print_hide_if_no_value": 0,
47-
"print_width": null,
48-
"read_only": 0,
49-
"report_hide": 0,
50-
"reqd": 0,
51-
"search_index": 0,
52-
"translatable": 0,
53-
"unique": 0,
54-
"width": null
55-
},
56-
{
57-
"_assign": null,
58-
"_comments": null,
59-
"_liked_by": null,
60-
"_user_tags": null,
61-
"allow_in_quick_entry": 0,
62-
"allow_on_submit": 0,
63-
"bold": 0,
64-
"collapsible": 0,
65-
"collapsible_depends_on": null,
66-
"columns": 0,
67-
"creation": "2020-06-01 07:22:11.957505",
68-
"default": null,
69-
"depends_on": "works_with_bloomstack",
70-
"description": null,
71-
"docstatus": 0,
72-
"dt": "User",
73-
"fetch_from": null,
74-
"fetch_if_empty": 0,
75-
"fieldname": "works_with_bloomstack",
76-
"fieldtype": "Check",
77-
"hidden": 0,
78-
"idx": 4,
79-
"ignore_user_permissions": 0,
80-
"ignore_xss_filter": 0,
81-
"in_global_search": 0,
82-
"in_list_view": 0,
83-
"in_standard_filter": 0,
84-
"insert_after": "column_break_2",
85-
"label": "Works with Bloomstack",
86-
"length": 0,
87-
"modified": "2020-06-01 07:22:11.957505",
88-
"modified_by": "Administrator",
89-
"name": "User-works_with_bloomstack",
90-
"no_copy": 0,
91-
"options": null,
92-
"owner": "Administrator",
93-
"parent": null,
94-
"parentfield": null,
95-
"parenttype": null,
96-
"permlevel": 0,
97-
"precision": "",
98-
"print_hide": 0,
99-
"print_hide_if_no_value": 0,
100-
"print_width": null,
101-
"read_only": 1,
102-
"report_hide": 0,
103-
"reqd": 0,
104-
"search_index": 0,
105-
"translatable": 0,
106-
"unique": 0,
107-
"width": null
108-
}
109-
],
2+
"custom_fields": [],
1103
"custom_perms": [],
1114
"doctype": "User",
1125
"property_setters": [

bloomstack_core/bloomstack_core/page/track_and_trace/track_and_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def search(text, start=0, limit=10):
1212
SELECT * FROM (
1313
SELECT 'Serial No' as doctype, name as docname, serial_no as searchfield FROM `tabSerial No`
1414
UNION
15-
SELECT 'Batch' as doctype, name as docname, concat(batch_id, '.', package_tag) as searchfield FROM `tabBatch`
15+
SELECT 'Batch' as doctype, name as docname, batch_id as searchfield FROM `tabBatch`
1616
UNION
1717
SELECT parenttype as doctype, parent as docname, package_tag as searchfield FROM `tabStock Entry Detail`
1818
) q

bloomstack_core/hook_events/item.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ def autoname(item, method=None):
2828
return
2929

3030
# Get abbreviations
31-
company_abbr = get_company_default(get_default_company(), "abbr")
32-
brand_abbr = get_abbr(item.brand, max_length=len(company_abbr))
33-
brand_abbr = brand_abbr if company_abbr != brand_abbr else None
3431
item_group_abbr = get_abbr(item.item_group)
3532
item_name_abbr = get_abbr(item.item_name, 3)
36-
37-
params = list(filter(None, [company_abbr, brand_abbr, item_group_abbr, item_name_abbr]))
38-
item_code = "-".join(params)
33+
default_company = get_default_company()
34+
35+
if default_company:
36+
company_abbr = get_company_default(default_company, "abbr")
37+
brand_abbr = get_abbr(item.brand, max_length=len(company_abbr))
38+
brand_abbr = brand_abbr if company_abbr != brand_abbr else None
39+
params = list(filter(None, [company_abbr, brand_abbr, item_group_abbr, item_name_abbr]))
40+
item_code = "-".join(params)
41+
else:
42+
brand_abbr = get_abbr(item.brand)
43+
params = list(filter(None, [brand_abbr, item_group_abbr, item_name_abbr]))
44+
item_code = "-".join(params)
3945

4046
# Get count
4147
count = len(frappe.get_all("Item", filters={"name": ["like", "%{}%".format(item_code)]}))

bloomstack_core/hook_events/user.py

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,11 @@
77
from frappe.utils import cstr, get_host_name
88

99

10-
def set_works_with_bloomstack_false(user, method):
11-
user.works_with_bloomstack = False
12-
13-
14-
def validate_if_bloomstack_user(user, method):
15-
# compare local and db values
16-
if user.works_with_bloomstack and not user.enabled and frappe.db.get_value("User", user.name, 'enabled'):
17-
frappe.throw("Please contact support to disable Bloomstack Users.")
18-
19-
2010
def update_bloomtrace_user(user, method):
21-
if frappe.get_conf().developer_mode or frappe.get_conf().disable_user_sync or user.is_new():
11+
if frappe.get_conf().developer_mode or frappe.get_conf().disable_user_sync:
2212
return
2313

24-
if user.user_type == "System User" and user.name not in ["Administrator", "Guest"] and not user.works_with_bloomstack:
14+
if user.user_type == "System User" and user.name not in ["Administrator", "Guest"]:
2515
make_integration_request(user.doctype, user.name)
2616

2717

@@ -44,38 +34,21 @@ def execute_bloomtrace_integration_request():
4434
integration_request = frappe.get_doc("Integration Request", request.name)
4535
user = frappe.get_doc("User", integration_request.reference_docname)
4636
try:
47-
bloomstack_site_user = frappe_client.get_doc("Bloomstack Site User", fields=['name', 'works_with_bloomstack'], filters={
48-
"bloomstack_site": site_url,
49-
"email": user.email
50-
})
51-
if not bloomstack_site_user:
52-
bloomstack_site_user = insert_bloomstack_site_user(user, site_url, frappe_client)
53-
elif not bloomstack_site_user[0].get('works_with_bloomstack'):
54-
doc_name = bloomstack_site_user[0].get('name')
55-
bloomstack_site_user = update_bloomstack_site_user(user, doc_name, site_url, frappe_client)
56-
frappe.db.set_value("User", user.name, "works_with_bloomstack", bloomstack_site_user[0].get('works_with_bloomstack'))
37+
insert_bloomstack_site_user(user, site_url, frappe_client)
38+
5739
integration_request.error = ""
5840
integration_request.status = "Completed"
59-
integration_request.save(ignore_permissions=True)
6041
except Exception as e:
6142
integration_request.error = cstr(e)
6243
integration_request.status = "Failed"
63-
integration_request.save(ignore_permissions=True)
44+
45+
integration_request.save(ignore_permissions=True)
6446

6547

6648
def insert_bloomstack_site_user(user, site_url, frappe_client):
6749
bloomstack_site_user = make_bloomstack_site_user(user, site_url)
6850
return frappe_client.insert(bloomstack_site_user)
6951

70-
71-
def update_bloomstack_site_user(user, doc_name, site_url, frappe_client):
72-
bloomstack_site_user = make_bloomstack_site_user(user, site_url)
73-
bloomstack_site_user.update({
74-
"name": doc_name
75-
})
76-
return frappe_client.update(bloomstack_site_user)
77-
78-
7952
def make_bloomstack_site_user(user, site_url):
8053
bloomstack_site_user = {
8154
"doctype": "Bloomstack Site User",
@@ -85,4 +58,4 @@ def make_bloomstack_site_user(user, site_url):
8558
"email": user.email,
8659
"bloomstack_site": site_url
8760
}
88-
return bloomstack_site_user
61+
return bloomstack_site_user

bloomstack_core/hooks.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,6 @@
230230
"before_update_after_submit": "bloomstack_core.hook_events.sales_invoice.set_invoice_status"
231231
},
232232
"User": {
233-
"validate": [
234-
"bloomstack_core.hook_events.user.validate_if_bloomstack_user",
235-
"bloomstack_core.hook_events.user.update_bloomtrace_user"
236-
],
237-
"before_insert": "bloomstack_core.hook_events.user.set_works_with_bloomstack_false",
238233
"after_insert": "bloomstack_core.hook_events.user.update_bloomtrace_user"
239234
},
240235
("Sales Order", "Delivery Note"): {
@@ -267,7 +262,6 @@
267262

268263
scheduler_events = {
269264
"all": [
270-
"bloomstack_core.hook_events.user.execute_bloomtrace_integration_request",
271265
"bloomstack_core.compliance.item.execute_bloomtrace_integration_request",
272266
"bloomstack_core.hook_events.package_tag.execute_bloomtrace_integration_request",
273267
"bloomstack_core.hook_events.delivery_note.execute_bloomtrace_integration_request",
@@ -278,6 +272,9 @@
278272
"bloomstack_core.compliance.package.execute_bloomtrace_integration_request_for_delivery_note",
279273
"bloomstack_core.hook_events.plant_additive_log.execute_bloomtrace_integration_request"
280274
],
275+
"hourly": [
276+
"bloomstack_core.hook_events.user.execute_bloomtrace_integration_request"
277+
],
281278
"daily": [
282279
"bloomstack_core.hook_events.sales_order.create_sales_invoice_against_contract"
283280
],

bloomstack_core/patches.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ bloomstack_core.patches.v0_0_1.update_overdue_sales_orders
1111
bloomstack_core.patches.v0_0_1.set_item_group_in_batch
1212
bloomstack_core.patches.v0_0_1.set_task_name_in_timesheet
1313
bloomstack_core.patches.v0_0_1.move_compliance_item_to_item
14+
bloomstack_core.patches.v0_0_1.remove_bloomstack_user_integration
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import frappe
2+
3+
def execute():
4+
frappe.delete_doc_if_exists("Custom Field", "User-column_break_2")
5+
frappe.delete_doc_if_exists("Custom Field", "User-works_with_bloomstack")
6+
7+
frappe.db.sql("DELETE FROM `tabActivity Log` where user='Administrator'")
8+
frappe.db.sql("DELETE FROM `tabIntegration Request` where reference_doctype='User'")

0 commit comments

Comments
 (0)