diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 3257f0a5694..83ce42034df 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -289,9 +289,15 @@ class procurement_order(osv.osv): return False partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement. + if not partner: + cr.execute('update procurement_order set message=%s where id=%s', + (_('No default supplier defined for this product'), procurement.id)) + return False + if user.company_id and user.company_id.partner_id: if partner.id == user.company_id.partner_id.id: return False + address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery'] if not address_id: cr.execute('update procurement_order set message=%s where id=%s', diff --git a/addons/product/product.py b/addons/product/product.py index 6bee68c2ba6..f82e5791fd7 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -250,7 +250,9 @@ class product_template(osv.osv): result[product.id] = {field:False} result[product.id]['seller_delay'] = 1 if product.seller_ids: - partner_list = sorted([(partner_id.sequence, partner_id) for partner_id in product.seller_ids if partner_id and partner_id.sequence]) + partner_list = sorted([(partner_id.sequence, partner_id) + for partner_id in product.seller_ids + if partner_id and isinstance(partner_id.sequence, (int, long))]) main_supplier = partner_list and partner_list[0] and partner_list[0][1] or False result[product.id]['seller_delay'] = main_supplier and main_supplier.delay or 1 result[product.id]['seller_qty'] = main_supplier and main_supplier.qty or 0.0