diff --git a/magento.xml b/magento.xml index 65117fb..5bb8539 100644 --- a/magento.xml +++ b/magento.xml @@ -323,9 +323,9 @@ - diff --git a/magento_.py b/magento_.py index 0a366a3..a07b118 100644 --- a/magento_.py +++ b/magento_.py @@ -310,9 +310,9 @@ class WebsiteStore(osv.Model): 'magento.instance.website', 'Website', required=True, readonly=True, ), - shop=fields.many2one( - 'sale.shop', 'Sales Shop', - help="Imported sales for this store will go into this shop", + pricelist=fields.many2one( + 'product.pricelist', 'Product Pricelist', + help="Imported sales for this store will use the pricelist", ), instance=fields.related( 'website', 'instance', type='many2one', @@ -399,12 +399,12 @@ def export_tier_prices_to_magento( # we donr have a product on tier, so we use the current # product in loop for computing the price for this tier price = pricelist_obj.price_get( - cursor, user, [store.shop.pricelist_id.id], + cursor, user, [store.pricelist.id], magento_product.product.id, tier.quantity, context={ 'uom': store.website.default_product_uom.id } - )[store.shop.pricelist_id.id] + )[store.pricelist.id] price_data.append({ 'qty': tier.quantity, @@ -453,11 +453,11 @@ class WebsiteStoreView(osv.Model): company=fields.related( 'store', 'company', type='many2one', relation='res.company', string='Company', readonly=True - ), - shop=fields.related( - 'store', 'shop', type='many2one', relation='sale.shop', - string='Sales Shop', readonly=True, - ), + ), + pricelist=fields.related( + 'store', 'pricelist', type='many2one', relation='product.pricelist', + string='Product Pricelist', readonly=True, + ), last_shipment_export_time=fields.datetime('Last Shipment Export Time'), export_tracking_information=fields.boolean( 'Export tracking information', help='Checking this will make sure' diff --git a/partner.py b/partner.py index bd7f4e1..e1bbfff 100644 --- a/partner.py +++ b/partner.py @@ -221,8 +221,12 @@ def find_or_create_address_as_partner_using_magento_data( :param parent: Parent partner for this address partner. :param context: Application context. :return: Browse record of address created/found + """ + """ for address in parent.child_ids + [parent]: + """ + for address in parent.child_ids: if self.match_address_with_magento_data( cursor, user, address, address_data ): diff --git a/product.py b/product.py index 0b2782e..bd9f5e0 100644 --- a/product.py +++ b/product.py @@ -650,11 +650,11 @@ def get_price(self, cursor, user, ids, name, _, context): cursor, user, context['magento_store'], context=context ) res[tier.id] = pricelist_obj.price_get( - cursor, user, [store.shop.pricelist_id.id], tier.product.id, + cursor, user, [store.pricelist.id], tier.product.id, tier.quantity, context={ 'uom': store.website.default_product_uom.id } - )[store.shop.pricelist_id.id] + )[store.pricelist.id] return res _columns = dict( diff --git a/sale.py b/sale.py index f19552a..893b4a7 100644 --- a/sale.py +++ b/sale.py @@ -304,19 +304,19 @@ def create_using_magento_data(self, cursor, user, order_data, context): store_view = store_view_obj.browse( cursor, user, context['magento_store_view'], context ) - if not store_view.shop: + if not store_view.pricelist: raise osv.except_osv( _('Not Found!'), _( - 'Magento Store %s should have a shop configured.' + 'Magento Store %s should have a pricelist configured.' % store_view.store.name ) ) - if not store_view.shop.pricelist_id: + if not store_view.pricelist: raise osv.except_osv( _('Not Found!'), _( - 'Shop on store %s does not have a pricelist!' + 'Store %s does not have a pricelist!' % store_view.store.name ) ) @@ -353,10 +353,9 @@ def create_using_magento_data(self, cursor, user, order_data, context): sale_data = { 'name': instance.order_prefix + order_data['increment_id'], - 'shop_id': store_view.shop.id, 'date_order': order_data['created_at'].split()[0], 'partner_id': partner.id, - 'pricelist_id': store_view.shop.pricelist_id.id, + 'pricelist_id': store_view.pricelist.id, 'currency_id': currency.id, 'partner_invoice_id': partner_invoice_address.id, 'partner_shipping_id': partner_shipping_address.id, diff --git a/tests/test_base.py b/tests/test_base.py index 23a11ce..9da9568 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -56,7 +56,7 @@ def setup_defaults(self, txn): website_obj = POOL.get('magento.instance.website') store_obj = POOL.get('magento.website.store') store_view_obj = POOL.get('magento.store.store_view') - shop_obj = POOL.get('sale.shop') + pricelist_obj = POOL.get('product.pricelist') uom_obj = POOL.get('product.uom') # Create two instances @@ -98,13 +98,13 @@ def setup_defaults(self, txn): 'default_product_uom': self.uom_id, }) - shop = shop_obj.search(txn.cursor, txn.user, [], context=txn.context) + pricelist = pricelist_obj.search(txn.cursor, txn.user, [], context=txn.context) self.store_id = store_obj.create( txn.cursor, txn.user, { 'name': 'Store1', 'website': self.website_id1, - 'shop': shop[0], + 'pricelist': pricelist[0], }, context=txn.context ) diff --git a/tests/test_product.py b/tests/test_product.py index ac4e8f3..78d6753 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -600,7 +600,7 @@ def test_0090_tier_prices(self): pricelist_item_obj.create(txn.cursor, txn.user, { 'name': 'Test line', - 'price_version_id': store.shop.pricelist_id.version_id[0].id, + 'price_version_id': store.pricelist.version_id[0].id, 'product_id': product.id, 'min_quantity': 10, 'base': 1,