when adding purchase order line, propose products supplied by the current purchase order partner first

Registered by Raphaël Valyi - http://www.akretion.com

The supplier info lines addition in OpenERP trunk was very smart enhancement and I should say that we did almost exactly that for a customer and then I just discovered the feature was added while thinking about publishing some module...

So now that we may know which are the suppliers of a given product, then why not use it to help entering purchase order lines: indeed: whenever you filled those supplier infos lines in the products, then in a new PO, once you selected a supplier it's likely you'll buy him a product he is the supplier of, so why not present first so products in the popup? We could also possibly use a special color for them.
Isn't it easy to add this feature?

Blueprint information

Status:
Started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
Discussion
Series goal:
None
Implementation:
Good progress
Milestone target:
None
Started by
Raphaël Valyi - http://www.akretion.com

Related branches

Sprints

Whiteboard

I have did some work on this blueprint. can you apply this patch in product/product.py ?

=== modified file 'product/product.py'
--- product/product.py 2009-07-27 09:10:20 +0000
+++ product/product.py 2009-08-11 13:30:30 +0000
@@ -544,6 +544,26 @@
         else:
             return super(product_product, self).copy(cr, uid, id, default=default,
                     context=context)
+
+ def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
+ res = super(product_product, self).read(cr, user, ids, fields=fields, context=context, load=load)
+ result = []
+ TODO = []
+ supplier_product = []
+ if context.get('partner_id',False):
+ cr.execute("select product_id from product_supplierinfo where name='%s'" %(context.get('partner_id',False)))
+ supplierinfo = cr.fetchall()
+ for supplierinfo_product in supplierinfo:
+ if supplierinfo_product[0] in ids:
+ supplier_product.append(supplierinfo_product[0])
+ for product in res:
+ if product['id'] in supplier_product:
+ result.append(product)
+ else:
+ TODO.append(product)
+ res = result + TODO
+ return res
+
 product_product()

 class product_packaging(osv.osv):

note from Raphaël Valyi:
-> Hello, I promise to check this as soon as possible, this is great news indeed.

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.