[IMP] website_sale: improve data to be multi currency, multi pricelist and fix tests according to new data
This commit is contained in:
@@ -197,5 +197,12 @@ parameter) will see those record just disappear.
|
||||
<field eval="'product.pricelist,'+str(ref('list0'))" name="value"/>
|
||||
</record>
|
||||
|
||||
<record forcecreate="True" id="property_product_pricelist_demo" model="ir.property">
|
||||
<field name="name">property_product_pricelist</field>
|
||||
<field name="fields_id" search="[('model','=','res.partner'),('name','=','property_product_pricelist')]"/>
|
||||
<field eval="'product.pricelist,'+str(ref('list0'))" name="value"/>
|
||||
<field eval="'res.partner,'+str(ref('base.partner_demo'))" name="res_id"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -747,39 +747,41 @@ Weight: 31 grams</field>
|
||||
</record>
|
||||
<record id="item_benelux" model="product.pricelist.item">
|
||||
<field name="pricelist_id" ref="list_benelux"/>
|
||||
<field name="compute_price">formula</field>
|
||||
<field name="compute_price">percentage</field>
|
||||
<field name="base">list_price</field>
|
||||
<field name="price_discount">10</field>
|
||||
<field name="percent_price">10</field>
|
||||
<field name="sequence">10</field>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="list_europe" model="product.pricelist">
|
||||
<field name="name">Europe Pricelist</field>
|
||||
<field name="selectable" eval="True" />
|
||||
<field name="website_id" ref="website.default_website" />
|
||||
<field name="country_group_ids" eval="[(6,0,[ref('base.europe')])]" />
|
||||
<field name="sequence">3</field>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
</record>
|
||||
<record id="item_europe" model="product.pricelist.item">
|
||||
<field name="pricelist_id" ref="list_europe"/>
|
||||
<field name="compute_price">formula</field>
|
||||
<field name="base">list_price</field>
|
||||
<field name="price_discount">10</field>
|
||||
<field name="sequence">10</field>
|
||||
</record>
|
||||
|
||||
<record id="list_us" model="product.pricelist">
|
||||
<field name="name">US/CA Pricelist</field>
|
||||
<field name="selectable" eval="True" />
|
||||
<field name="website_id" ref="website.default_website" />
|
||||
<field name="country_group_ids" eval="[(6,0,[ref('country_group_us_ca')])]" />
|
||||
<field name="name">US/CA Pricelist</field>
|
||||
<field name="selectable" eval="True" />
|
||||
<field name="website_id" ref="website.default_website" />
|
||||
<field name="country_group_ids" eval="[(6,0,[ref('country_group_us_ca')])]" />
|
||||
<field name="sequence">3</field>
|
||||
<field name="currency_id" ref="base.USD"/>
|
||||
</record>
|
||||
<record id="item_us" model="product.pricelist.item">
|
||||
<field name="pricelist_id" ref="list_us"/>
|
||||
<field name="compute_price">formula</field>
|
||||
<field name="base">list_price</field>
|
||||
<field name="price_discount">10</field>
|
||||
<field name="sequence">10</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -12,6 +12,7 @@ class TestWebsitePriceList(TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWebsitePriceList, self).setUp()
|
||||
self.env.user.partner_id.country_id = False # Remove country to avoid property pricelist computed.
|
||||
self.website = self.env['website'].browse(1)
|
||||
self.website.pricelist_id = self.ref('product.list0')
|
||||
self.patcher = patch('odoo.addons.website_sale.models.sale_order.Website.get_pricelist_available', wraps=self._get_pricelist_available)
|
||||
@@ -40,7 +41,8 @@ class TestWebsitePriceList(TransactionCase):
|
||||
}
|
||||
for country, result in country_list.items():
|
||||
pls = self.get_pl(show, current_pl, country)
|
||||
self.assertEquals(len(pls), result)
|
||||
self.assertEquals(len(pls), result, 'Test failed for %s (%s [%s] vs %s)'
|
||||
% (country, len(pls), pls.mapped('name'), result))
|
||||
|
||||
def test_get_pricelist_available_not_show(self):
|
||||
show = False
|
||||
@@ -56,7 +58,8 @@ class TestWebsitePriceList(TransactionCase):
|
||||
|
||||
for country, result in country_list.items():
|
||||
pls = self.get_pl(show, current_pl, country)
|
||||
self.assertEquals(len(pls), result)
|
||||
self.assertEquals(len(pls), result, 'Test failed for %s (%s [%s] vs %s)'
|
||||
% (country, len(pls), pls.mapped('name'), result))
|
||||
|
||||
def test_get_pricelist_available_promocode(self):
|
||||
christmas_pl = self.ref('website_sale.list_christmas')
|
||||
@@ -79,9 +82,26 @@ class TestWebsitePriceList(TransactionCase):
|
||||
# mock patch method could not pass env context
|
||||
available = self.website.is_pricelist_available(christmas_pl)
|
||||
if result:
|
||||
self.assertTrue(available)
|
||||
self.assertTrue(available, 'AssertTrue failed for %s' % country)
|
||||
else:
|
||||
self.assertFalse(available)
|
||||
self.assertFalse(available, 'AssertFalse failed for %s' % country)
|
||||
|
||||
def test_get_pricelist_available_show_with_auto_property(self):
|
||||
show = True
|
||||
self.env.user.partner_id.country_id = self.env.ref('base.us') # Add US pricelist auto
|
||||
current_pl = False
|
||||
|
||||
country_list = {
|
||||
False: 4, # Benelux, Europe, US, USA
|
||||
'BE': 3, # Benelux, Europe, USA
|
||||
'IT': 2, # Europe, USA
|
||||
'US': 1, # US
|
||||
'AF': 1 # USA
|
||||
}
|
||||
for country, result in country_list.items():
|
||||
pls = self.get_pl(show, current_pl, country)
|
||||
self.assertEquals(len(pls), result, 'Test failed for %s (%s [%s] vs %s)'
|
||||
% (country, len(pls), pls.mapped('name'), result))
|
||||
|
||||
def tearDown(self):
|
||||
self.patcher.stop()
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<t t-if="(compute_currency(product.lst_price) - product.website_price ) > 0.1 and website.get_current_pricelist().discount_policy=='without_discount'">
|
||||
<del class="text-danger mr8" style="white-space: nowrap;" t-esc="compute_currency(product.website_public_price)" t-options="{'widget': 'monetary', 'display_currency': website.get_current_pricelist().currency_id, 'from_currency': website.currency_id}" />
|
||||
</t>
|
||||
|
||||
<span t-esc="product.website_price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}" />
|
||||
<span itemprop="price" style="display:none;" t-esc="product.price" />
|
||||
<span itemprop="priceCurrency" style="display:none;" t-esc="website.currency_id.name" />
|
||||
|
||||
@@ -139,7 +139,6 @@
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem action="product_public_category_action" id="menu_product_public_category" parent="sale.prod_config_main" sequence="2" />
|
||||
|
||||
<record id="website_sale_pricelist_form_view" model="ir.ui.view">
|
||||
<field name="name">website_sale.pricelist.form</field>
|
||||
|
||||
Reference in New Issue
Block a user