details: https://code.tryton.org/tryton/commit/c1bb5150cfaf
branch: default
user: Cédric Krier <[email protected]>
date: Mon Aug 25 13:37:31 2025 +0200
description:
Support taxes from Shopify shipping product
Closes #14192
diffstat:
modules/web_shop_shopify/CHANGELOG | 1 +
modules/web_shop_shopify/sale.py | 25 ++++++++++-
modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst | 2 +
3 files changed, 25 insertions(+), 3 deletions(-)
diffs (67 lines):
diff -r 4c8bb51f47ab -r c1bb5150cfaf modules/web_shop_shopify/CHANGELOG
--- a/modules/web_shop_shopify/CHANGELOG Sat Aug 23 20:29:51 2025 +0200
+++ b/modules/web_shop_shopify/CHANGELOG Mon Aug 25 13:37:31 2025 +0200
@@ -1,3 +1,4 @@
+* Support taxes from shipping product
* Add routes to open Shopify objects
* Add support for credit refunds
diff -r 4c8bb51f47ab -r c1bb5150cfaf modules/web_shop_shopify/sale.py
--- a/modules/web_shop_shopify/sale.py Sat Aug 23 20:29:51 2025 +0200
+++ b/modules/web_shop_shopify/sale.py Mon Aug 25 13:37:31 2025 +0200
@@ -420,16 +420,30 @@
@classmethod
def get_from_shopify_shipping(cls, sale, shipping_line, line=None):
+ pool = Pool()
+ Tax = pool.get('account.tax')
+
if not line:
line = cls(type='line')
line.sale = sale
+ line.product = None
+ line._set_shopify_shipping_product(sale, shipping_line)
setattr_changed(line, 'quantity', 1)
- setattr_changed(
- line, 'unit_price',
- round_price(Decimal(shipping_line.discounted_price)))
+ if line.product:
+ if line._changed_values():
+ line.on_change_product()
+ else:
+ setattr_changed(line, 'taxes', ())
+ unit_price = Decimal(shipping_line.discounted_price)
+ unit_price = round_price(Tax.reverse_compute(
+ unit_price, line.taxes, sale.sale_date))
+ setattr_changed(line, 'unit_price', unit_price)
setattr_changed(line, 'description', shipping_line.title)
return line
+ def _set_shopify_shipping_product(self, sale, shipping_line):
+ pass
+
def _get_invoice_line_quantity(self):
quantity = super()._get_invoice_line_quantity()
if self.sale.web_shop and self.sale.web_shop.type == 'shopify':
@@ -496,4 +510,9 @@
setattr_changed(line, 'shipment_cost', Decimal(shipping_line.price))
return line
+ def _set_shopify_shipping_product(self, sale, shipping_line):
+ super()._set_shopify_shipping_product(sale, shipping_line)
+ if sale.carrier:
+ setattr_changed(self, 'product', sale.carrier.carrier_product)
+
# TODO: refund as return sale
diff -r 4c8bb51f47ab -r c1bb5150cfaf
modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst
--- a/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst Sat Aug
23 20:29:51 2025 +0200
+++ b/modules/web_shop_shopify/tests/scenario_web_shop_shopify.rst Mon Aug
25 13:37:31 2025 +0200
@@ -499,6 +499,8 @@
4
>>> sorted([l.unit_price for l in sale.lines])
[Decimal('4.0000'), Decimal('8.5727'), Decimal('8.5727'),
Decimal('42.9309')]
+ >>> any(l.product == carrier_product for l in sale.lines)
+ True
>>> sale.total_amount
Decimal('258.98')
>>> len(sale.payments)