Browse Source

compatibility with sale_commission

nj-12.0-partner_gogocarto_export_api
Giovanni 4 years ago
committed by default
parent
commit
2bf01588e3
  1. 8
      partner_default_sale_discount/models/sale_order.py
  2. 2
      partner_default_sale_discount/tests/test_partner_default_sale_discount.py

8
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

2
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', '{}'))
Loading…
Cancel
Save