changeset e87b2dcb5655 in modules/web_shop_vue_storefront:default
details: 
https://hg.tryton.org/modules/web_shop_vue_storefront?cmd=changeset&node=e87b2dcb5655
description:
        Support empty list price on product

        issue10244
        review350341002
diffstat:

 product.py |   8 +++++---
 sale.py    |  28 +++++++++++++++-------------
 web.py     |   3 ++-
 3 files changed, 22 insertions(+), 17 deletions(-)

diffs (69 lines):

diff -r 8330e903dc01 -r e87b2dcb5655 product.py
--- a/product.py        Thu Sep 02 23:16:10 2021 +0200
+++ b/product.py        Mon Sep 13 23:29:57 2021 +0200
@@ -61,9 +61,11 @@
             'url_path': '%s/%s' % (
                 self.vsf_identifier.id, slugify(self.name.lower())),
             'type_id': self.vsf_type_id,
-            'price': float(price),
-            'price_tax': float(tax),
-            'price_incl_tax': float(price + tax),
+            'price': float(price) if price is not None else None,
+            'price_tax': float(tax) if tax is not None else None,
+            'price_incl_tax': (
+                float(price + tax)
+                if price is not None and tax is not None else None),
             'status': status,
             'visibility': 4,
             'category_ids': [c.vsf_identifier.id for c in categories],
diff -r 8330e903dc01 -r e87b2dcb5655 sale.py
--- a/sale.py   Thu Sep 02 23:16:10 2021 +0200
+++ b/sale.py   Mon Sep 13 23:29:57 2021 +0200
@@ -118,19 +118,21 @@
         item = super().get_vsf()
         if self.carrier:
             cost = self.compute_shipment_cost()
-            cost_line = self.get_shipment_cost_line(cost)
-            taxes = Tax.compute(cost_line.taxes, cost, 1)
-            cost += sum(t['amount'] for t in taxes)
-            cost = float(self.currency.round(cost))
-            item['grand_total'] += cost
-            item['total_segments'].insert(1, {
-                    'code': 'shipping',
-                    'title': gettext('web_shop_vue_storefront.msg_shipping'),
-                    'value': cost,
-                    })
-            for segment in item['total_segments']:
-                if segment['code'] == 'grand_total':
-                    segment['value'] += cost
+            if cost is not None:
+                cost_line = self.get_shipment_cost_line(cost)
+                taxes = Tax.compute(cost_line.taxes, cost, 1)
+                cost += sum(t['amount'] for t in taxes)
+                cost = float(self.currency.round(cost))
+                item['grand_total'] += cost
+                item['total_segments'].insert(1, {
+                        'code': 'shipping',
+                        'title': gettext(
+                            'web_shop_vue_storefront.msg_shipping'),
+                        'value': cost,
+                        })
+                for segment in item['total_segments']:
+                    if segment['code'] == 'grand_total':
+                        segment['value'] += cost
         return item
 
     def set_vsf_shipping_methods(self, data):
diff -r 8330e903dc01 -r e87b2dcb5655 web.py
--- a/web.py    Thu Sep 02 23:16:10 2021 +0200
+++ b/web.py    Mon Sep 13 23:29:57 2021 +0200
@@ -164,7 +164,8 @@
             for template in templates:
                 template_products = template.get_vsf_products(shop)
                 price, tax = min(
-                    (prices[p.id], taxes[p.id]) for p in template_products)
+                    (prices[p.id], taxes[p.id]) for p in template_products
+                    if prices[p.id] is not None and taxes[p.id] is not None)
                 entity = template.get_vsf_entity(shop, price=price, tax=tax)
                 entity['configurable_children'] = [
                     product.get_vsf_entity(

Reply via email to