details: https://code.tryton.org/tryton/commit/9f701f47d677
branch: default
user: Cédric Krier <[email protected]>
date: Thu Aug 14 14:31:32 2025 +0200
description:
Add admin URL to Shopify identifiers
Closes #14160 #14164
diffstat:
modules/web_shop_shopify/CHANGELOG | 1 +
modules/web_shop_shopify/common.py | 20 +++++++++-
modules/web_shop_shopify/message.xml | 3 +
modules/web_shop_shopify/party.xml | 12 ++++++
modules/web_shop_shopify/sale.py | 1 +
modules/web_shop_shopify/sale.xml | 12 ++++++
modules/web_shop_shopify/tryton.cfg | 2 +
modules/web_shop_shopify/view/party_form.xml | 8 ++++
modules/web_shop_shopify/view/product_template_form.xml | 2 +
modules/web_shop_shopify/view/sale_form.xml | 10 +++++
modules/web_shop_shopify/view/shop_shopify_identifier_form.xml | 2 +
modules/web_shop_shopify/view/shop_shopify_identifier_list.xml | 5 +-
modules/web_shop_shopify/web.py | 14 +++++++
13 files changed, 89 insertions(+), 3 deletions(-)
diffs (217 lines):
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/CHANGELOG
--- a/modules/web_shop_shopify/CHANGELOG Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/CHANGELOG Thu Aug 14 14:31:32 2025 +0200
@@ -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 -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/common.py
--- a/modules/web_shop_shopify/common.py Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/common.py Thu Aug 14 14:31:32 2025 +0200
@@ -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 @@
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 @@
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 @@
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 -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/message.xml
--- a/modules/web_shop_shopify/message.xml Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/message.xml Thu Aug 14 14:31:32 2025 +0200
@@ -9,6 +9,9 @@
<record model="ir.message" id="msg_shopify_identifier">
<field name="text">Shopify Identifier</field>
</record>
+ <record model="ir.message" id="msg_shopify_url">
+ <field name="text">Shopify URL</field>
+ </record>
<record model="ir.message" id="msg_identifier_record_web_shop_unique">
<field name="text">The record cannot have more than one Shopify
identifier per web shop.</field>
</record>
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/party.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web_shop_shopify/party.xml Thu Aug 14 14:31:32 2025 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+ <data>
+ <record model="ir.ui.view" id="party_view_form">
+ <field name="model">party.party</field>
+ <field name="inherit" ref="party.party_view_form"/>
+ <field name="name">party_form</field>
+ </record>
+ </data>
+</tryton>
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/sale.py
--- a/modules/web_shop_shopify/sale.py Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/sale.py Thu Aug 14 14:31:32 2025 +0200
@@ -154,6 +154,7 @@
"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 -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/sale.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web_shop_shopify/sale.xml Thu Aug 14 14:31:32 2025 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+ <data>
+ <record model="ir.ui.view" id="sale_view_form">
+ <field name="model">sale.sale</field>
+ <field name="inherit" ref="sale.sale_view_form"/>
+ <field name="name">sale_form</field>
+ </record>
+ </data>
+</tryton>
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/tryton.cfg
--- a/modules/web_shop_shopify/tryton.cfg Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/tryton.cfg Thu Aug 14 14:31:32 2025 +0200
@@ -27,7 +27,9 @@
xml:
ir.xml
product.xml
+ party.xml
web.xml
+ sale.xml
stock.xml
carrier.xml
message.xml
diff -r 88f32d9e0426 -r 9f701f47d677
modules/web_shop_shopify/view/party_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web_shop_shopify/view/party_form.xml Thu Aug 14 14:31:32
2025 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath expr="//field[@name='identifiers']" position="after">
+ <field name="shopify_identifiers" colspan="4"/>
+ </xpath>
+</data>
diff -r 88f32d9e0426 -r 9f701f47d677
modules/web_shop_shopify/view/product_template_form.xml
--- a/modules/web_shop_shopify/view/product_template_form.xml Tue Aug 12
15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/view/product_template_form.xml Thu Aug 14
14:31:32 2025 +0200
@@ -11,5 +11,7 @@
<label name="shopify_handle"/>
<field name="shopify_handle"/>
<newline/>
+
+ <field name="shopify_identifiers" colspan="4"/>
</xpath>
</data>
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/view/sale_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web_shop_shopify/view/sale_form.xml Thu Aug 14 14:31:32
2025 +0200
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath expr="//field[@name='web_id']" position="after">
+ <newline/>
+ <label name="shopify_url"/>
+ <field name="shopify_url" widget="url" colspan="3"/>
+ </xpath>
+</data>
diff -r 88f32d9e0426 -r 9f701f47d677
modules/web_shop_shopify/view/shop_shopify_identifier_form.xml
--- a/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml Tue Aug
12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/view/shop_shopify_identifier_form.xml Thu Aug
14 14:31:32 2025 +0200
@@ -10,6 +10,8 @@
<label name="shopify_identifier"/>
<field name="shopify_identifier" width="20"/>
+ <label name="shopify_url"/>
+ <field name="shopify_url" widget="url"/>
<label name="to_update"/>
<field name="to_update"/>
</form>
diff -r 88f32d9e0426 -r 9f701f47d677
modules/web_shop_shopify/view/shop_shopify_identifier_list.xml
--- a/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml Tue Aug
12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/view/shop_shopify_identifier_list.xml Thu Aug
14 14:31:32 2025 +0200
@@ -4,7 +4,8 @@
<tree>
<field name="web_shop" expand="1"/>
<field name="record" expand="1"/>
- <field name="shopify_identifier" expand="2"/>
- <field name="to_update"/>
+ <field name="shopify_identifier" expand="2" optional="0"/>
+ <field name="shopify_url" widget="url"/>
+ <field name="to_update" optional="1"/>
<button name="set_to_update" tree_invisible="1"/>
</tree>
diff -r 88f32d9e0426 -r 9f701f47d677 modules/web_shop_shopify/web.py
--- a/modules/web_shop_shopify/web.py Tue Aug 12 15:32:34 2025 +0200
+++ b/modules/web_shop_shopify/web.py Thu Aug 14 14:31:32 2025 +0200
@@ -970,6 +970,20 @@
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'