salla-common-lib 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- salla_common_lib-0.0.1/PKG-INFO +43 -0
- salla_common_lib-0.0.1/README.md +34 -0
- salla_common_lib-0.0.1/pyproject.toml +56 -0
- salla_common_lib-0.0.1/salla_common_lib/__init__.py +1 -0
- salla_common_lib-0.0.1/salla_common_lib/config/__init__.py +0 -0
- salla_common_lib-0.0.1/salla_common_lib/event/field_manager.py +221 -0
- salla_common_lib-0.0.1/salla_common_lib/event/item.py +69 -0
- salla_common_lib-0.0.1/salla_common_lib/event/item_price.py +62 -0
- salla_common_lib-0.0.1/salla_common_lib/event/salla_order.py +204 -0
- salla_common_lib-0.0.1/salla_common_lib/event/unified_integration.py +347 -0
- salla_common_lib-0.0.1/salla_common_lib/event/validation_utils.py +186 -0
- salla_common_lib-0.0.1/salla_common_lib/hooks.py +244 -0
- salla_common_lib-0.0.1/salla_common_lib/modules.txt +1 -0
- salla_common_lib-0.0.1/salla_common_lib/patches.txt +6 -0
- salla_common_lib-0.0.1/salla_common_lib/public/.gitkeep +0 -0
- salla_common_lib-0.0.1/salla_common_lib/public/js/item.js +63 -0
- salla_common_lib-0.0.1/salla_common_lib/public/js/salla_order.js +16 -0
- salla_common_lib-0.0.1/salla_common_lib/public/js/salla_order_fulfilment.js +180 -0
- salla_common_lib-0.0.1/salla_common_lib/public/js/salla_shipment_method_mapping.js +23 -0
- salla_common_lib-0.0.1/salla_common_lib/salla_common_lib/__init__.py +0 -0
- salla_common_lib-0.0.1/salla_common_lib/templates/__init__.py +0 -0
- salla_common_lib-0.0.1/salla_common_lib/templates/pages/__init__.py +0 -0
- salla_common_lib-0.0.1/salla_common_lib/utils.py +160 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: salla_common_lib
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: App for salla common lib
|
|
5
|
+
Author-email: Golive-Solutions <info@golive-solutions.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
|
|
9
|
+
# Salla Common Lib
|
|
10
|
+
|
|
11
|
+
A Python library for common Salla functionality.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
You can install the package using pip:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install salla-common-lib
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Common utilities for Salla integration
|
|
24
|
+
- Template management
|
|
25
|
+
- Configuration handling
|
|
26
|
+
- Event management
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from salla_common_lib import utils
|
|
32
|
+
|
|
33
|
+
# Use the library functions as needed
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
This project is licensed under the MIT License.
|
|
39
|
+
|
|
40
|
+
## Contributing
|
|
41
|
+
|
|
42
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
43
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Salla Common Lib
|
|
2
|
+
|
|
3
|
+
A Python library for common Salla functionality.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install the package using pip:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install salla-common-lib
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Common utilities for Salla integration
|
|
16
|
+
- Template management
|
|
17
|
+
- Configuration handling
|
|
18
|
+
- Event management
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from salla_common_lib import utils
|
|
24
|
+
|
|
25
|
+
# Use the library functions as needed
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
This project is licensed under the MIT License.
|
|
31
|
+
|
|
32
|
+
## Contributing
|
|
33
|
+
|
|
34
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "salla_common_lib"
|
|
3
|
+
authors = [
|
|
4
|
+
{ name = "Golive-Solutions", email = "info@golive-solutions.com"}
|
|
5
|
+
]
|
|
6
|
+
description = "App for salla common lib"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
dynamic = ["version"]
|
|
10
|
+
dependencies = [
|
|
11
|
+
# "frappe~=15.0.0" # Installed and managed by bench.
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["flit_core >=3.4,<4"]
|
|
16
|
+
build-backend = "flit_core.buildapi"
|
|
17
|
+
|
|
18
|
+
# These dependencies are only installed when developer mode is enabled
|
|
19
|
+
[tool.bench.dev-dependencies]
|
|
20
|
+
# package_name = "~=1.1.0"
|
|
21
|
+
|
|
22
|
+
[tool.ruff]
|
|
23
|
+
line-length = 110
|
|
24
|
+
target-version = "py310"
|
|
25
|
+
|
|
26
|
+
[tool.ruff.lint]
|
|
27
|
+
select = [
|
|
28
|
+
"F",
|
|
29
|
+
"E",
|
|
30
|
+
"W",
|
|
31
|
+
"I",
|
|
32
|
+
"UP",
|
|
33
|
+
"B",
|
|
34
|
+
"RUF",
|
|
35
|
+
]
|
|
36
|
+
ignore = [
|
|
37
|
+
"B017", # assertRaises(Exception) - should be more specific
|
|
38
|
+
"B018", # useless expression, not assigned to anything
|
|
39
|
+
"B023", # function doesn't bind loop variable - will have last iteration's value
|
|
40
|
+
"B904", # raise inside except without from
|
|
41
|
+
"E101", # indentation contains mixed spaces and tabs
|
|
42
|
+
"E402", # module level import not at top of file
|
|
43
|
+
"E501", # line too long
|
|
44
|
+
"E741", # ambiguous variable name
|
|
45
|
+
"F401", # "unused" imports
|
|
46
|
+
"F403", # can't detect undefined names from * import
|
|
47
|
+
"F405", # can't detect undefined names from * import
|
|
48
|
+
"F722", # syntax error in forward type annotation
|
|
49
|
+
"W191", # indentation contains tabs
|
|
50
|
+
]
|
|
51
|
+
typing-modules = ["frappe.types.DF"]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.format]
|
|
54
|
+
quote-style = "double"
|
|
55
|
+
indent-style = "tab"
|
|
56
|
+
docstring-code-format = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
File without changes
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# field_manager.py
|
|
2
|
+
import frappe
|
|
3
|
+
from frappe import _
|
|
4
|
+
|
|
5
|
+
# Field configurations for each integration type
|
|
6
|
+
INTEGRATION_FIELDS = {
|
|
7
|
+
'pos_invoice': {
|
|
8
|
+
'Salla Order': [
|
|
9
|
+
{
|
|
10
|
+
'fieldname': 'custom_pos_invoice_name',
|
|
11
|
+
'label': 'POS Invoice Name',
|
|
12
|
+
'fieldtype': 'Link',
|
|
13
|
+
'options': 'POS Invoice',
|
|
14
|
+
'read_only': 1,
|
|
15
|
+
'insert_after': 'connections_tab'
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
'POS Invoice': [
|
|
19
|
+
{
|
|
20
|
+
'fieldname': 'custom_is_salla_item',
|
|
21
|
+
'label': 'Is Salla Item',
|
|
22
|
+
'fieldtype': 'Check',
|
|
23
|
+
'default': '0',
|
|
24
|
+
'insert_after': 'online_order'
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
'sales_invoice': {
|
|
29
|
+
'Salla Order': [
|
|
30
|
+
{
|
|
31
|
+
'fieldname': 'custom_sales_invoice_name',
|
|
32
|
+
'label': 'Sales Invoice Name',
|
|
33
|
+
'fieldtype': 'Link',
|
|
34
|
+
'options': 'Sales Invoice',
|
|
35
|
+
'read_only': 1,
|
|
36
|
+
'insert_after': 'connections_tab'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
'sales_order': {
|
|
41
|
+
'Salla Order': [
|
|
42
|
+
{
|
|
43
|
+
'fieldname': 'custom_sales_order_name',
|
|
44
|
+
'label': 'Sales Order Name',
|
|
45
|
+
'fieldtype': 'Link',
|
|
46
|
+
'options': 'Sales Order',
|
|
47
|
+
'read_only': 0,
|
|
48
|
+
'insert_after': 'connections_tab'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
'fieldname': 'custom_payment_entry_name',
|
|
52
|
+
'label': 'Payment Entry Name',
|
|
53
|
+
'fieldtype': 'Link',
|
|
54
|
+
'options': 'Payment Entry',
|
|
55
|
+
'read_only': 0,
|
|
56
|
+
'insert_after': 'custom_sales_order_name'
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
'Sales Order': [
|
|
60
|
+
{
|
|
61
|
+
'fieldname': 'custom_salla_order_name',
|
|
62
|
+
'label': 'Salla Order Name',
|
|
63
|
+
'fieldtype': 'Data',
|
|
64
|
+
'insert_after': 'order_type'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
'fieldname': 'custom_salla_order_custom_status',
|
|
68
|
+
'label': 'Salla Order Custom Status',
|
|
69
|
+
'fieldtype': 'Data',
|
|
70
|
+
'allow_on_submit': 1,
|
|
71
|
+
'insert_after': 'custom_salla_order_name'
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
'Payment Entry': [
|
|
75
|
+
{
|
|
76
|
+
'fieldname': 'custom_salla_order_name',
|
|
77
|
+
'label': 'Salla Order Name',
|
|
78
|
+
'fieldtype': 'Data',
|
|
79
|
+
'insert_after': 'mode_of_payment'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Core fields that are always present
|
|
86
|
+
CORE_FIELDS = {
|
|
87
|
+
'Salla Defaults': [
|
|
88
|
+
{
|
|
89
|
+
'fieldname': 'integration_type',
|
|
90
|
+
'label': 'Integration Type',
|
|
91
|
+
'fieldtype': 'Select',
|
|
92
|
+
'options': 'pos_invoice\nsales_invoice\nsales_order',
|
|
93
|
+
'default': 'pos_invoice',
|
|
94
|
+
'reqd': 1,
|
|
95
|
+
'insert_after': 'price_list'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
'fieldname': 'custom_warehouse',
|
|
99
|
+
'label': 'Warehouse',
|
|
100
|
+
'fieldtype': 'Link',
|
|
101
|
+
'options': 'Warehouse',
|
|
102
|
+
'depends_on': 'eval:doc.integration_type=="sales_order"',
|
|
103
|
+
'insert_after': 'custom_days_to_delivery_order'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
'fieldname': 'custom_days_to_delivery_order',
|
|
107
|
+
'label': 'Days To Delivery Order',
|
|
108
|
+
'fieldtype': 'Int',
|
|
109
|
+
'insert_after': 'price_list'
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
def manage_custom_fields(doc, method=None):
|
|
115
|
+
"""
|
|
116
|
+
Dynamically manage custom fields based on integration type
|
|
117
|
+
"""
|
|
118
|
+
if not doc.integration_type:
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
# Remove all integration-specific fields first
|
|
122
|
+
remove_all_integration_fields()
|
|
123
|
+
|
|
124
|
+
# Create core fields
|
|
125
|
+
create_core_fields()
|
|
126
|
+
|
|
127
|
+
# Create fields for selected integration type
|
|
128
|
+
create_integration_fields(doc.integration_type)
|
|
129
|
+
|
|
130
|
+
frappe.clear_cache()
|
|
131
|
+
|
|
132
|
+
def create_core_fields():
|
|
133
|
+
"""Create core fields that are always present"""
|
|
134
|
+
for doctype, fields in CORE_FIELDS.items():
|
|
135
|
+
for field_config in fields:
|
|
136
|
+
create_custom_field(doctype, field_config)
|
|
137
|
+
|
|
138
|
+
def create_integration_fields(integration_type):
|
|
139
|
+
"""Create fields for specific integration type"""
|
|
140
|
+
if integration_type not in INTEGRATION_FIELDS:
|
|
141
|
+
return
|
|
142
|
+
|
|
143
|
+
for doctype, fields in INTEGRATION_FIELDS[integration_type].items():
|
|
144
|
+
for field_config in fields:
|
|
145
|
+
create_custom_field(doctype, field_config)
|
|
146
|
+
|
|
147
|
+
def remove_all_integration_fields():
|
|
148
|
+
"""Remove all integration-specific custom fields"""
|
|
149
|
+
all_fields = []
|
|
150
|
+
|
|
151
|
+
for integration_type, doctypes in INTEGRATION_FIELDS.items():
|
|
152
|
+
for doctype, fields in doctypes.items():
|
|
153
|
+
for field_config in fields:
|
|
154
|
+
field_name = f"{doctype}-{field_config['fieldname']}"
|
|
155
|
+
all_fields.append(field_name)
|
|
156
|
+
|
|
157
|
+
# Delete existing custom fields
|
|
158
|
+
for field_name in all_fields:
|
|
159
|
+
if frappe.db.exists("Custom Field", field_name):
|
|
160
|
+
try:
|
|
161
|
+
frappe.delete_doc("Custom Field", field_name)
|
|
162
|
+
except Exception as e:
|
|
163
|
+
frappe.log_error(f"Error deleting custom field {field_name}: {str(e)}")
|
|
164
|
+
|
|
165
|
+
def create_custom_field(doctype, field_config):
|
|
166
|
+
"""Create a single custom field if it doesn't exist"""
|
|
167
|
+
field_name = f"{doctype}-{field_config['fieldname']}"
|
|
168
|
+
|
|
169
|
+
if frappe.db.exists("Custom Field", field_name):
|
|
170
|
+
return
|
|
171
|
+
|
|
172
|
+
try:
|
|
173
|
+
custom_field = frappe.get_doc({
|
|
174
|
+
"doctype": "Custom Field",
|
|
175
|
+
"dt": doctype,
|
|
176
|
+
"fieldname": field_config['fieldname'],
|
|
177
|
+
"label": field_config['label'],
|
|
178
|
+
"fieldtype": field_config['fieldtype'],
|
|
179
|
+
"options": field_config.get('options', ''),
|
|
180
|
+
"insert_after": field_config.get('insert_after', ''),
|
|
181
|
+
"read_only": field_config.get('read_only', 0),
|
|
182
|
+
"reqd": field_config.get('reqd', 0),
|
|
183
|
+
"default": field_config.get('default', ''),
|
|
184
|
+
"depends_on": field_config.get('depends_on', ''),
|
|
185
|
+
"description": field_config.get('description', '')
|
|
186
|
+
})
|
|
187
|
+
custom_field.insert()
|
|
188
|
+
|
|
189
|
+
except Exception as e:
|
|
190
|
+
frappe.log_error(f"Error creating custom field {field_name}: {str(e)}")
|
|
191
|
+
|
|
192
|
+
def get_integration_type():
|
|
193
|
+
"""Get current integration type from Salla Defaults"""
|
|
194
|
+
try:
|
|
195
|
+
salla_defaults = frappe.get_single("Salla Defaults")
|
|
196
|
+
return salla_defaults.get('integration_type', 'pos_invoice')
|
|
197
|
+
except:
|
|
198
|
+
return 'pos_invoice'
|
|
199
|
+
|
|
200
|
+
def setup_integration_fields():
|
|
201
|
+
"""Initial setup of integration fields (called during install)"""
|
|
202
|
+
integration_type = get_integration_type()
|
|
203
|
+
|
|
204
|
+
# Create core fields
|
|
205
|
+
create_core_fields()
|
|
206
|
+
|
|
207
|
+
# Create fields for current integration type
|
|
208
|
+
create_integration_fields(integration_type)
|
|
209
|
+
|
|
210
|
+
frappe.clear_cache()
|
|
211
|
+
|
|
212
|
+
# Utility function to check if field exists for current integration
|
|
213
|
+
def has_integration_field(doctype, fieldname):
|
|
214
|
+
"""Check if a field exists for current integration type"""
|
|
215
|
+
integration_type = get_integration_type()
|
|
216
|
+
|
|
217
|
+
if integration_type in INTEGRATION_FIELDS:
|
|
218
|
+
doctype_fields = INTEGRATION_FIELDS[integration_type].get(doctype, [])
|
|
219
|
+
return any(field['fieldname'] == fieldname for field in doctype_fields)
|
|
220
|
+
|
|
221
|
+
return False
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import frappe
|
|
2
|
+
from salla_common.utils import is_app_installed
|
|
3
|
+
|
|
4
|
+
def before_save(doc, method):
|
|
5
|
+
if is_app_installed("salla_connector"):
|
|
6
|
+
from salla_connector.salla_utils import Update_salla_online_qty, has_barcode, setup_variant_data, update_item_barcode
|
|
7
|
+
if doc.custom_update_pending_online_quantity and doc.custom_is_salla_item:
|
|
8
|
+
Update_salla_online_qty(doc)
|
|
9
|
+
doc.custom_update_pending_online_quantity = 0
|
|
10
|
+
update_item_barcode(doc)
|
|
11
|
+
handle_variant(doc, has_barcode, setup_variant_data)
|
|
12
|
+
|
|
13
|
+
if is_app_installed("salla_client"):
|
|
14
|
+
from salla_client.salla_utils import Update_salla_online_qty, has_barcode, setup_variant_data, update_item_barcode
|
|
15
|
+
if doc.custom_update_pending_online_quantity and doc.custom_is_salla_item:
|
|
16
|
+
Update_salla_online_qty(doc)
|
|
17
|
+
doc.custom_update_pending_online_quantity = 0
|
|
18
|
+
update_item_barcode(doc)
|
|
19
|
+
handle_variant(doc, has_barcode, setup_variant_data)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def handle_variant(doc, has_barcode, setup_variant_data):
|
|
23
|
+
if doc.variant_of and not has_barcode(doc):
|
|
24
|
+
parent = frappe.get_doc("Item", doc.variant_of)
|
|
25
|
+
send_to_salla = parent.custom_send_item_to_salla == 1
|
|
26
|
+
merchant_name = parent.custom_salla_item[0].merchant if send_to_salla else None
|
|
27
|
+
setup_variant_data(doc, send_to_salla, merchant_name)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def on_update(doc, method):
|
|
31
|
+
for row in doc.custom_salla_item:
|
|
32
|
+
print("ON UPDATE !!!!!")
|
|
33
|
+
barcode = frappe.get_doc(
|
|
34
|
+
"Item Barcode", {"parent": doc.name, "custom_is_salla_barcode": 1}
|
|
35
|
+
)
|
|
36
|
+
payload = {
|
|
37
|
+
"name": doc.name,
|
|
38
|
+
"item_name": doc.item_name,
|
|
39
|
+
"standard_rate": doc.standard_rate if doc.standard_rate else 0,
|
|
40
|
+
"custom_product_type": doc.custom_product_type,
|
|
41
|
+
"description": doc.description,
|
|
42
|
+
"custom_send_item_to_salla": doc.custom_send_item_to_salla,
|
|
43
|
+
"barcode": barcode.barcode,
|
|
44
|
+
"custom_product_image": doc.custom_product_image,
|
|
45
|
+
"variant_of": doc.variant_of,
|
|
46
|
+
"weight_per_unit": doc.weight_per_unit,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if doc.variant_of:
|
|
50
|
+
barcode = frappe.get_doc(
|
|
51
|
+
"Item Barcode", {"parent": doc.variant_of, "custom_is_salla_barcode": 1}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
payload.update({
|
|
55
|
+
"parent_barcode": barcode.barcode,
|
|
56
|
+
"custom_salla_variant_id": doc.custom_salla_variant_id,
|
|
57
|
+
"attributes": [row.as_dict() for row in doc.attributes]
|
|
58
|
+
})
|
|
59
|
+
## This should be optimized for bulk processing to reduce api calls
|
|
60
|
+
is_salla_connector_installed = is_app_installed("salla_connector")
|
|
61
|
+
if is_salla_connector_installed:
|
|
62
|
+
from salla_connector.salla_utils import create_or_update_salla_item
|
|
63
|
+
create_or_update_salla_item(payload, row.merchant)
|
|
64
|
+
|
|
65
|
+
is_salla_client_installed = is_app_installed("salla_client")
|
|
66
|
+
if is_salla_client_installed :
|
|
67
|
+
from salla_client.salla_utils import create_or_update_salla_item
|
|
68
|
+
if not doc.custom_is_synced:
|
|
69
|
+
create_or_update_salla_item(payload, row.merchant)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import frappe
|
|
2
|
+
import frappe.utils
|
|
3
|
+
import frappe.utils.logger
|
|
4
|
+
from salla_common.utils import is_app_installed
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def before_save(doc, method):
|
|
8
|
+
frappe.utils.logger.set_log_level("DEBUG")
|
|
9
|
+
logger = frappe.logger("update_price", allow_site=1)
|
|
10
|
+
|
|
11
|
+
logger.info(f'Item Price Doc Before Adding The Other Values: {doc.as_dict()}')
|
|
12
|
+
|
|
13
|
+
is_salla_item, variant_of, salla_variant_id = frappe.get_value(
|
|
14
|
+
"Item", doc.item_code, ["custom_is_salla_item", "variant_of", "custom_salla_variant_id"]
|
|
15
|
+
) or (None, None, None)
|
|
16
|
+
|
|
17
|
+
logger.info(f'The Fields I got From Item: {is_salla_item}, {variant_of}, {salla_variant_id}')
|
|
18
|
+
|
|
19
|
+
if is_salla_item:
|
|
20
|
+
barcode_list = frappe.get_all("Item Barcode", {"parent": doc.item_code, "custom_is_salla_barcode": 1})
|
|
21
|
+
if barcode_list and len(barcode_list) > 0:
|
|
22
|
+
barcode = frappe.get_doc("Item Barcode", barcode_list[0].name)
|
|
23
|
+
merchant_salla_setting_list = frappe.get_list(
|
|
24
|
+
"Salla Defaults", filters={"price_list": doc.price_list}, fields=["name"]
|
|
25
|
+
)
|
|
26
|
+
else:
|
|
27
|
+
logger.error(f'No Salla Barcode found for Item: {doc.item_code}')
|
|
28
|
+
return
|
|
29
|
+
for salla_setting in merchant_salla_setting_list:
|
|
30
|
+
payload = {
|
|
31
|
+
"selling": doc.selling,
|
|
32
|
+
"valid_from": doc.valid_from,
|
|
33
|
+
"price_list": doc.price_list,
|
|
34
|
+
"price_list_rate": doc.price_list_rate,
|
|
35
|
+
"item_code": doc.item_code,
|
|
36
|
+
"barcode": barcode.barcode,
|
|
37
|
+
"custom_is_salla_item": is_salla_item,
|
|
38
|
+
"variant_of": variant_of,
|
|
39
|
+
"custom_salla_variant_id": salla_variant_id,
|
|
40
|
+
"merchant": salla_setting.name
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
logger.info(f'Merchant is {salla_setting.name}')
|
|
44
|
+
logger.info(f'Payload being sent: {payload}')
|
|
45
|
+
|
|
46
|
+
if is_app_installed("salla_connector"):
|
|
47
|
+
try:
|
|
48
|
+
from salla_connector.salla_utils import update_salla_price
|
|
49
|
+
update_salla_price(payload)
|
|
50
|
+
except ImportError:
|
|
51
|
+
frappe.log_error("Failed to import from salla_connector")
|
|
52
|
+
|
|
53
|
+
if is_app_installed("salla_client"):
|
|
54
|
+
try:
|
|
55
|
+
from salla_client.salla_utils import update_salla_price
|
|
56
|
+
update_salla_price(payload)
|
|
57
|
+
logger.info(f"After sending to salla_client: {payload}")
|
|
58
|
+
except ImportError:
|
|
59
|
+
frappe.log_error("Failed to import from salla_client")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|