diff --git a/modules/web_shop_shopify/CHANGELOG b/modules/web_shop_shopify/CHANGELOG
index f700c038c2..e7c75c5f04 100644
--- a/modules/web_shop_shopify/CHANGELOG
+++ b/modules/web_shop_shopify/CHANGELOG
@@ -1,3 +1,4 @@
+* Add admin URL to identifiers
* Set compare-at price using non-sale price
* Add support for product kit
* Add carrier selection
diff --git a/modules/web_shop_shopify/common.py b/modules/web_shop_shopify/common.py
index 2b139da89a..c8d29e3de1 100644
--- a/modules/web_shop_shopify/common.py
+++ b/modules/web_shop_shopify/common.py
@@ -1,8 +1,11 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
+from urllib.parse import urljoin
+
from trytond.i18n import lazy_gettext
from trytond.model import fields
from trytond.pool import Pool
+from trytond.pyson import Eval
def id2gid(resouce, id):
@@ -28,6 +31,12 @@ class IdentifierMixin:
lazy_gettext('web_shop_shopify.msg_shopify_identifier')),
'get_shopify_identifier', setter='set_shopify_identifier',
searcher='search_shopify_identifier')
+ shopify_url = fields.Function(fields.Char(
+ lazy_gettext('web_shop_shopify.msg_shopify_url'),
+ states={
+ 'invisible': ~Eval('shopify_url'),
+ }),
+ 'get_shopify_url')
def get_shopify_identifier(self, name):
if self.shopify_identifier_signed is not None:
@@ -54,6 +63,14 @@ class IdentifierMixin:
value = int(value) - (1 << 63)
return [('shopify_identifier_signed', operator, value)]
+ def get_shopify_url(self, name):
+ if (getattr(self, 'shopify_resource', None)
+ and getattr(self, 'web_shop', None)
+ and self.shopify_identifier_char):
+ return urljoin(
+ self.web_shop.shopify_url + '/admin/',
+ f'{self.shopify_resource}/{self.shopify_identifier_char}')
+
@classmethod
def copy(cls, records, default=None):
if default is None:
@@ -100,7 +117,8 @@ class IdentifiersMixin(IdentifiersUpdateMixin):
shopify_identifiers = fields.One2Many(
'web.shop.shopify_identifier', 'record',
- lazy_gettext('web_shop_shopify.msg_shopify_identifiers'))
+ lazy_gettext('web_shop_shopify.msg_shopify_identifiers'),
+ readonly=True)
def get_shopify_identifier(self, web_shop):
for record in self.shopify_identifiers:
diff --git a/modules/web_shop_shopify/message.xml b/modules/web_shop_shopify/message.xml
index 68101df71c..8467a1fae2 100644
--- a/modules/web_shop_shopify/message.xml
+++ b/modules/web_shop_shopify/message.xml
@@ -9,6 +9,9 @@ this repository contains the full copyright notices and license terms. -->
Shopify Identifier
+
+ Shopify URL
+
The record cannot have more than one Shopify identifier per web shop.
diff --git a/modules/web_shop_shopify/party.xml b/modules/web_shop_shopify/party.xml
new file mode 100644
index 0000000000..e5c6732c93
--- /dev/null
+++ b/modules/web_shop_shopify/party.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ party.party
+
+ party_form
+
+
+
diff --git a/modules/web_shop_shopify/sale.py b/modules/web_shop_shopify/sale.py
index 7b2e7be96e..ddf94981c4 100644
--- a/modules/web_shop_shopify/sale.py
+++ b/modules/web_shop_shopify/sale.py
@@ -154,6 +154,7 @@ class Sale(IdentifierMixin, metaclass=PoolMeta):
"Shopify Tax Adjustment",
currency='currency', digits='currency', readonly=True)
shopify_status_url = fields.Char("Shopify Status URL", readonly=True)
+ shopify_resource = 'orders'
@classmethod
def __setup__(cls):
diff --git a/modules/web_shop_shopify/sale.xml b/modules/web_shop_shopify/sale.xml
new file mode 100644
index 0000000000..f06ff244bb
--- /dev/null
+++ b/modules/web_shop_shopify/sale.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ sale.sale
+
+ sale_form
+
+
+
diff --git a/modules/web_shop_shopify/tryton.cfg b/modules/web_shop_shopify/tryton.cfg
index b4e84c6de8..3419d49143 100644
--- a/modules/web_shop_shopify/tryton.cfg
+++ b/modules/web_shop_shopify/tryton.cfg
@@ -27,7 +27,9 @@ extras_depend:
xml:
ir.xml
product.xml
+ party.xml
web.xml
+ sale.xml
stock.xml
carrier.xml
message.xml
diff --git a/modules/web_shop_shopify/view/party_form.xml b/modules/web_shop_shopify/view/party_form.xml
new file mode 100644
index 0000000000..af264199d7
--- /dev/null
+++ b/modules/web_shop_shopify/view/party_form.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
diff --git a/modules/web_shop_shopify/view/product_template_form.xml b/modules/web_shop_shopify/view/product_template_form.xml
index d137d6073d..422b3cdd21 100644
--- a/modules/web_shop_shopify/view/product_template_form.xml
+++ b/modules/web_shop_shopify/view/product_template_form.xml
@@ -11,5 +11,7 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/modules/web_shop_shopify/view/sale_form.xml b/modules/web_shop_shopify/view/sale_form.xml
new file mode 100644
index 0000000000..dfe6c949c0
--- /dev/null
+++ b/modules/web_shop_shopify/view/sale_form.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
diff --git a/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml b/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml
index ac94d40885..2895f6336b 100644
--- a/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml
+++ b/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml
@@ -10,6 +10,8 @@ this repository contains the full copyright notices and license terms. -->
+
+
diff --git a/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml b/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml
index 6715aef2f8..ceab948353 100644
--- a/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml
+++ b/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml
@@ -4,7 +4,8 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
+
diff --git a/modules/web_shop_shopify/web.py b/modules/web_shop_shopify/web.py
index 184263245c..68350ce1fd 100644
--- a/modules/web_shop_shopify/web.py
+++ b/modules/web_shop_shopify/web.py
@@ -970,6 +970,20 @@ class ShopShopifyIdentifier(IdentifierMixin, ModelSQL, ModelView):
def set_to_update(cls, identifiers):
cls.write(identifiers, {'to_update': True})
+ @property
+ def shopify_resource(self):
+ if self.record.__name__ == 'product.product':
+ product_identifier = self.record.template.get_shopify_identifier(
+ self.web_shop)
+ resource = f'products/{product_identifier}/variants'
+ else:
+ resource = {
+ 'party.party': 'customers',
+ 'product.category': 'collections',
+ 'product.template': 'products',
+ }.get(self.record.__name__)
+ return resource
+
class Shop_Warehouse(ModelView, metaclass=PoolMeta):
__name__ = 'web.shop-stock.location'