Skip to content

Commit

Permalink
Merge pull request #222 from frappe/develop
Browse files Browse the repository at this point in the history
chore: release
  • Loading branch information
ankush authored Dec 14, 2022
2 parents 0863b4e + 1cbdf6b commit 7162cea
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 19 deletions.
13 changes: 6 additions & 7 deletions .github/helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ bench init --skip-assets --frappe-path ~/frappe --python "$(which python)" frapp
mkdir ~/frappe-bench/sites/test_site
cp -r "${GITHUB_WORKSPACE}/.github/helper/site_config.json" ~/frappe-bench/sites/test_site/

mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL character_set_server = 'utf8mb4'"
mysql --host 127.0.0.1 --port 3306 -u root -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL character_set_server = 'utf8mb4'"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "SET GLOBAL collation_server = 'utf8mb4_unicode_ci'"

mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
mysql --host 127.0.0.1 --port 3306 -u root -e "CREATE DATABASE test_frappe"
mysql --host 127.0.0.1 --port 3306 -u root -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE USER 'test_frappe'@'localhost' IDENTIFIED BY 'test_frappe'"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "CREATE DATABASE test_frappe"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "GRANT ALL PRIVILEGES ON \`test_frappe\`.* TO 'test_frappe'@'localhost'"

mysql --host 127.0.0.1 --port 3306 -u root -e "UPDATE mysql.user SET Password=PASSWORD('travis') WHERE User='root'"
mysql --host 127.0.0.1 --port 3306 -u root -e "FLUSH PRIVILEGES"
mysql --host 127.0.0.1 --port 3306 -u root -proot -e "FLUSH PRIVILEGES"

cd ~/frappe-bench || exit

Expand Down
4 changes: 2 additions & 2 deletions .github/helper/site_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"mail_password": "test",
"admin_password": "admin",
"root_login": "root",
"root_password": "travis",
"root_password": "root",
"host_name": "http://test_site:8000",
"install_apps": ["erpnext"],
"install_apps": ["payments", "erpnext"],
"throttle_user_limit": 100
}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:

services:
mysql:
image: mariadb:10.3
image: mariadb:10.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: YES
MARIADB_ROOT_PASSWORD: 'root'
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ repos:
- id: isort
exclude: ".*setup.py$"

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: [flake8-isort]
Expand Down
1 change: 1 addition & 0 deletions ecommerce_integrations/shopify/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
SUPPLIER_ID_FIELD = "shopify_supplier_id"
ADDRESS_ID_FIELD = "shopify_address_id"
ORDER_ITEM_DISCOUNT_FIELD = "shopify_item_discount"
ITEM_SELLING_RATE_FIELD = "shopify_selling_rate"

# ERPNext already defines the default UOMs from Shopify but names are different
WEIGHT_TO_ERPNEXT_UOM_MAP = {"kg": "Kg", "g": "Gram", "oz": "Ounce", "lb": "Pound"}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ADDRESS_ID_FIELD,
CUSTOMER_ID_FIELD,
FULLFILLMENT_ID_FIELD,
ITEM_SELLING_RATE_FIELD,
ORDER_ID_FIELD,
ORDER_ITEM_DISCOUNT_FIELD,
ORDER_NUMBER_FIELD,
Expand Down Expand Up @@ -113,6 +114,14 @@ def get_integration_to_erpnext_wh_mapping(self) -> Dict[IntegrationWarehouse, ER

def setup_custom_fields():
custom_fields = {
"Item": [
dict(
fieldname=ITEM_SELLING_RATE_FIELD,
label="Shopify Selling Rate",
fieldtype="Currency",
insert_after="standard_rate",
)
],
"Customer": [
dict(
fieldname=CUSTOMER_ID_FIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ADDRESS_ID_FIELD,
CUSTOMER_ID_FIELD,
FULLFILLMENT_ID_FIELD,
ITEM_SELLING_RATE_FIELD,
ORDER_ID_FIELD,
ORDER_ITEM_DISCOUNT_FIELD,
ORDER_NUMBER_FIELD,
Expand Down Expand Up @@ -40,6 +41,7 @@ def test_custom_field_creation(self):
ADDRESS_ID_FIELD,
CUSTOMER_ID_FIELD,
FULLFILLMENT_ID_FIELD,
ITEM_SELLING_RATE_FIELD,
ORDER_ID_FIELD,
ORDER_NUMBER_FIELD,
ORDER_STATUS_FIELD,
Expand Down
19 changes: 13 additions & 6 deletions ecommerce_integrations/shopify/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ecommerce_integrations.ecommerce_integrations.doctype.ecommerce_item import ecommerce_item
from ecommerce_integrations.shopify.connection import temp_shopify_session
from ecommerce_integrations.shopify.constants import (
ITEM_SELLING_RATE_FIELD,
MODULE_NAME,
SETTING_DOCTYPE,
SHOPIFY_VARIANTS_ATTR_LIST,
Expand Down Expand Up @@ -375,13 +376,17 @@ def upload_erpnext_item(doc, method=None):
update_default_variant_properties(
product,
sku=template_item.item_code,
price=template_item.standard_rate,
price=template_item.get(ITEM_SELLING_RATE_FIELD),
is_stock_item=template_item.is_stock_item,
)
if item.variant_of:
product.options = []
product.variants = []
variant_attributes = {"title": template_item.item_name}
variant_attributes = {
"title": template_item.item_name,
"sku": item.item_code,
"price": item.get(ITEM_SELLING_RATE_FIELD),
}
max_index_range = min(3, len(template_item.attributes))
for i in range(0, max_index_range):
attr = template_item.attributes[i]
Expand Down Expand Up @@ -422,10 +427,12 @@ def upload_erpnext_item(doc, method=None):
product = Product.find(product_id)
if product:
map_erpnext_item_to_shopify(shopify_product=product, erpnext_item=template_item)
update_default_variant_properties(product, is_stock_item=template_item.is_stock_item)

variant_attributes = {}
if item.variant_of:
if not item.variant_of:
update_default_variant_properties(
product, is_stock_item=template_item.is_stock_item, price=item.get(ITEM_SELLING_RATE_FIELD)
)
else:
variant_attributes = {"sku": item.item_code, "price": item.get(ITEM_SELLING_RATE_FIELD)}
product.options = []
max_index_range = min(3, len(template_item.attributes))
for i in range(0, max_index_range):
Expand Down

0 comments on commit 7162cea

Please sign in to comment.