# -*- coding: utf-8 -*-
from openerp.tests.common import TransactionCase


class TestWebsiteSeoUrlProduct(TransactionCase):
    post_install = True

    def setUp(self):
        super(TestWebsiteSeoUrlProduct, self).setUp()
        cr, uid = self.cr, self.uid
        self.ir_model_data = self.registry('ir.model.data')
        self.usb_adapter_id = self.ir_model_data.get_object_reference(cr, uid, 'product', 'product_product_48')[1]
        self.datacard_id = self.ir_model_data.get_object_reference(cr, uid, 'product', 'product_product_46')[1]

    def test_10_seo_url_checking(self):
        cr, uid, context = self.cr, self.uid, {}
        SEO_URL_VALUE = 'some-seo-url'

        # should be no duplicated SEO URLs
        self.registry('product.product').write(cr, uid, [self.usb_adapter_id, self.datacard_id], {'seo_url': SEO_URL_VALUE}, context=context)
        self.assertEqual(1, self.registry('product.product').search_count(cr, uid, [('seo_url', '=', SEO_URL_VALUE)], context=context))

@@ -229,183 +229,45 @@
     
-cr, uid = self.cr, self.uid%0A        self.ir_model_data = self.registry('ir.model.data')%0A        self.usb_adapter_id = self.ir_model_data.get_object_reference(cr, uid, 
+self.product1 = self.env.ref(
 'product
 ', '
@@ -254,36 +254,33 @@
 env.ref('product
-', '
+.
 product_product_
@@ -283,15 +283,11 @@
 uct_
-48')%5B1%5D
+1')
 %0A   
@@ -300,79 +300,40 @@
 elf.
-datacard_id = self.ir_model_data.get_object_reference(cr, uid, 
+product2 = self.env.ref(
 'product
 ', '
@@ -328,20 +328,17 @@
 'product
-', '
+.
 product_
@@ -349,15 +349,11 @@
 uct_
-46')%5B1%5D
+2')
 %0A%0A  
@@ -394,57 +394,8 @@
 f):%0A
-        cr, uid, context = self.cr, self.uid, %7B%7D%0A
     
@@ -485,140 +485,108 @@
     
-self.registry('product.product').write(cr, uid, %5Bself.usb_adapter_id, self.datacard_id%5D, %7B'seo_url': SEO_URL_VALUE%7D, context=context
+vals = %7B'seo_url': SEO_URL_VALUE%7D%0A        self.product1.write(vals)%0A        self.product2.write(vals
 )%0A  
@@ -620,17 +620,12 @@
 elf.
-registry(
+env%5B
 'pro
@@ -637,17 +637,17 @@
 product'
-)
+%5D
 .search_
@@ -656,17 +656,8 @@
 unt(
-cr, uid, 
 %5B('s
@@ -689,24 +689,7 @@
 UE)%5D
-, context=context
 ))%0A

update tests