From 2bf01588e3ef1b3d16251048dd3a4aa055d57c3f Mon Sep 17 00:00:00 2001 From: Giovanni Date: Mon, 15 Feb 2021 22:33:16 +0100 Subject: [PATCH] compatibility with sale_commission --- partner_default_sale_discount/models/sale_order.py | 8 ++++---- .../tests/test_partner_default_sale_discount.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/partner_default_sale_discount/models/sale_order.py b/partner_default_sale_discount/models/sale_order.py index da168aabc..d0c5002f5 100644 --- a/partner_default_sale_discount/models/sale_order.py +++ b/partner_default_sale_discount/models/sale_order.py @@ -32,9 +32,9 @@ class SaleOrder(models.Model): # This should be handled in "string" mode, as the context can # contain a expression that can only be evaled on execution time # on the JS web client - context = xml_order_line[0].get('context', '{}').replace( - "{", "{'default_discount': default_sale_discount, ", 1 - ) - xml_order_line[0].set('context', context) + node_val = xml_order_line[0].get('context', '{}').strip()[1:-1] + elems = node_val.split(',') if node_val else [] + to_add = ["'default_discount': default_sale_discount"] + xml_order_line[0].set('context', '{' + ', '.join(elems + to_add) + '}') res['arch'] = etree.tostring(eview) return res diff --git a/partner_default_sale_discount/tests/test_partner_default_sale_discount.py b/partner_default_sale_discount/tests/test_partner_default_sale_discount.py index 8e07c2608..9b79c9154 100644 --- a/partner_default_sale_discount/tests/test_partner_default_sale_discount.py +++ b/partner_default_sale_discount/tests/test_partner_default_sale_discount.py @@ -13,5 +13,5 @@ class TestPartnerDefaultSaleDiscount(common.SavepointCase): xml_order_line = eview.xpath("//field[@name='order_line']") self.assertTrue(xml_order_line) self.assertIn( - "'default_discount': default_sale_discount,", + "'default_discount': default_sale_discount", xml_order_line[0].get('context', '{}'))