Commit 636db232 authored by Jérome Perrin's avatar Jérome Perrin

since 27673, price from supply line only applies if the price currency from the

supply line is the same as the price currency from the context. Update tests
that where not respecting this, and add new test to prove new behaviour.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27711 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 29eb91a5
...@@ -687,16 +687,11 @@ class TestResource(ERP5TypeTestCase): ...@@ -687,16 +687,11 @@ class TestResource(ERP5TypeTestCase):
# Create product # Create product
product_module = self.portal.getDefaultModule(self.product_portal_type) product_module = self.portal.getDefaultModule(self.product_portal_type)
supply_module = self.portal.getDefaultModule(self.sale_supply_portal_type) supply_module = self.portal.getDefaultModule(self.sale_supply_portal_type)
currency_module = self.portal.getDefaultModule("Currency")
currency = currency_module.newContent(
portal_type="Currency",
title='A great currency')
# Create generic supply # Create generic supply
self.logMessage("Creating generic fake supply ...", tab=1) self.logMessage("Creating generic fake supply ...", tab=1)
generic_supply = supply_module.newContent( generic_supply = supply_module.newContent(
portal_type=self.sale_supply_portal_type, portal_type=self.sale_supply_portal_type,
title='FakeGenericSupply', title='FakeGenericSupply',)
price_currency_value=currency)
# Create empty supply line # Create empty supply line
supply_line = generic_supply.newContent( supply_line = generic_supply.newContent(
portal_type=self.sale_supply_line_portal_type) portal_type=self.sale_supply_line_portal_type)
...@@ -718,7 +713,6 @@ class TestResource(ERP5TypeTestCase): ...@@ -718,7 +713,6 @@ class TestResource(ERP5TypeTestCase):
supply = supply_module.newContent( supply = supply_module.newContent(
portal_type=self.sale_supply_portal_type, portal_type=self.sale_supply_portal_type,
title='FakeSupply%s' % i, title='FakeSupply%s' % i,
price_currency_value=currency,
destination_section_value=node) destination_section_value=node)
self.logMessage("Creating fake supply line %s..." % i, tab=1) self.logMessage("Creating fake supply line %s..." % i, tab=1)
supply_line = supply.newContent( supply_line = supply.newContent(
...@@ -769,16 +763,11 @@ class TestResource(ERP5TypeTestCase): ...@@ -769,16 +763,11 @@ class TestResource(ERP5TypeTestCase):
# Create product # Create product
product_module = self.portal.getDefaultModule(self.product_portal_type) product_module = self.portal.getDefaultModule(self.product_portal_type)
supply_module = self.portal.getDefaultModule(self.sale_supply_portal_type) supply_module = self.portal.getDefaultModule(self.sale_supply_portal_type)
currency_module = self.portal.getDefaultModule("Currency")
currency = currency_module.newContent(
portal_type="Currency",
title='A great currency')
# Create generic supply # Create generic supply
self.logMessage("Creating generic fake supply ...", tab=1) self.logMessage("Creating generic fake supply ...", tab=1)
generic_supply = supply_module.newContent( generic_supply = supply_module.newContent(
portal_type=self.sale_supply_portal_type, portal_type=self.sale_supply_portal_type,
title='FakeGenericSupply', title='FakeGenericSupply',)
price_currency_value=currency)
# Create empty supply line # Create empty supply line
supply_line = generic_supply.newContent( supply_line = generic_supply.newContent(
portal_type=self.sale_supply_line_portal_type) portal_type=self.sale_supply_line_portal_type)
...@@ -802,7 +791,6 @@ class TestResource(ERP5TypeTestCase): ...@@ -802,7 +791,6 @@ class TestResource(ERP5TypeTestCase):
supply = supply_module.newContent( supply = supply_module.newContent(
portal_type=self.sale_supply_portal_type, portal_type=self.sale_supply_portal_type,
title='FakeSupply%s' % i, title='FakeSupply%s' % i,
price_currency_value=currency,
destination_section_value=node) destination_section_value=node)
if 0: if 0:
...@@ -891,10 +879,7 @@ class TestResource(ERP5TypeTestCase): ...@@ -891,10 +879,7 @@ class TestResource(ERP5TypeTestCase):
currency_module = self.getCurrencyModule() currency_module = self.getCurrencyModule()
sale_order_module = self.portal.getDefaultModule("Sale Order") sale_order_module = self.portal.getDefaultModule("Sale Order")
purchase_order_module = self.portal.getDefaultModule("Purchase Order") purchase_order_module = self.portal.getDefaultModule("Purchase Order")
# Create currency and product # Create product
currency = currency_module.newContent(
portal_type="Currency",
title='A great currency')
product = product_module.newContent( product = product_module.newContent(
portal_type=self.product_portal_type, portal_type=self.product_portal_type,
title="yet another product") title="yet another product")
...@@ -987,6 +972,40 @@ class TestResource(ERP5TypeTestCase): ...@@ -987,6 +972,40 @@ class TestResource(ERP5TypeTestCase):
self.assertEquals(1, sale_order_line.getPrice()) self.assertEquals(1, sale_order_line.getPrice())
self.assertEquals(5000, sale_order_line.getTotalPrice()) self.assertEquals(5000, sale_order_line.getTotalPrice())
def testGetPriceWithPriceCurrency(self):
currency_module = self.portal.getDefaultModule("Currency")
currency = currency_module.newContent(
portal_type="Currency",
title='A great currency')
other_currency = currency_module.newContent(
portal_type="Currency",
title='Another currency')
resource = self.portal.getDefaultModule(self.product_portal_type)\
.newContent(portal_type=self.product_portal_type)
resource.setDefaultQuantityUnitValue(self.quantity_unit_kilo)
supply_line = resource.newContent(
portal_type=self.sale_supply_line_portal_type)
supply_line.setBasePrice(1000)
supply_line.setPriceCurrencyValue(currency)
transaction.commit()
self.tic()
sale_order = self.portal.getDefaultModule("Sale Order").newContent(
portal_type='Sale Order',
price_currency_value=other_currency)
sale_order_line = sale_order.newContent(
resource_value=resource,
quantity=5)
# order and supply lines uses different currency, price does not apply
self.assertEquals(None, sale_order_line.getPrice())
# set the same currency
sale_order.setPriceCurrencyValue(currency)
# price applies
self.assertEquals(1000, sale_order_line.getPrice())
self.assertEquals(5000, sale_order_line.getTotalPrice())
def testQuantityPrecision(self): def testQuantityPrecision(self):
"""test how to define quantity precision on resources. """test how to define quantity precision on resources.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment