It is currently Sat Feb 11, 2012 12:20 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Search/filter by Supplier in Product Purchase Order
PostPosted: Sat Feb 07, 2009 5:05 pm 
Offline

Joined: Sat Feb 07, 2009 4:58 pm
Posts: 6
How can I limit available selection of Products in the list of products while creating a Purchase Order only to these products that are supplied by selected Supplier?

Currently when I'm creating a Purchase Order I fill all the basic details including the Supplier, then add products. On the pop-up screen I can click on the magnifying glass which opens another pop-up with Products.
Currently there's no way to limit that selection to specified supplier which could lead to ordering products from supplier that doesn't supply them as the system doesn't verify that.

I'm a python programmer, but quite new to OpenERP, so any pointers on where I could tweak this behaviour, or perhaps if that's a matter of configuration even better.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2009 12:57 am 
Offline
Site Admin

Joined: Tue Feb 08, 2005 9:48 am
Posts: 2118
Location: Grand-Rosiere, Belgium
Search, in the technical documentation for:
* domain (to apply on the product_id of the purchae order line)
* name_search (to apply on the supplier list on product form)

By using both, it should do the trick.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 6:47 pm 
Offline

Joined: Fri Dec 08, 2006 3:46 pm
Posts: 175
Location: Caracas, Venezuela
Quote:
By using both, it should do the trick

I don't know about the second but maybe this can help you

Quote:
* domain (to apply on the product_id of the purchae order line)

Code:
                  <field name="order_line" widget="one2many_list" colspan="4" nolabel="1" >
                     <form string="Purchase Order Line">
...
                              <field name="product_id" colspan="4"
                                 on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order)"                              

                                 context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id"
                              domain="[('seller_ids','=',parent.partner_id)]"/>
...
                     </form>                     



Regards,

_________________
Javier Duran
Venezuela


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 8:02 pm 
Offline

Joined: Sat Feb 07, 2009 4:58 pm
Posts: 6
Thanks for pointing me to the domain attribute but unfortunately

domain="[('seller_ids','=',parent.partner_id)]"

doesn't work.
I've also tried:

domain="[(parent.partner_id,'IN','seller_ids')]"

and it doesn't work either. Any ideas?

As far as I understand this the domain attribute placed on the product_id field in Purchase Order Lines should filter available items in next window which is the Products list.

Edit:
Just realized that the domain requires 'field name', 'operator', 'value' so I've tested domain="[('seller_ids', 'IN',parent.partner_id)]" but this also doesn't work


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 11:37 pm 
Offline

Joined: Fri Dec 08, 2006 3:46 pm
Posts: 175
Location: Caracas, Venezuela
Quote:
doesn't work

Are you sure, because it work for me. Did you update the server?


Regards,

_________________
Javier Duran
Venezuela


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 12:19 am 
Offline
Site Admin

Joined: Tue Feb 08, 2005 9:48 am
Posts: 2118
Location: Grand-Rosiere, Belgium
> domain="[('seller_ids','=',parent.partner_id)]"

It would be a good idea to package this in a module and push on lunachpad for others people that need this (and also to avoid changing the base distribution for not having problems in future releases).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 1:00 am 
Offline

Joined: Sat Feb 07, 2009 4:58 pm
Posts: 6
javier - what I tried was just edit the purchase.order.line.form from Administration->Custom->Interface->View

Code:
<?xml version="1.0"?>

<form string="Purchase Order Line">
<notebook>
<page string="Order Line">
<field colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" name="product_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order)" domain="[('seller_ids', '=', parent.partner_id)]" />
<field name="product_qty"/>

<field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order)"/>
<field colspan="4" name="name"/>
<field name="date_planned"/>
<field name="price_unit"/>

<field name="account_analytic_id"/>
<field name="price_subtotal" readonly="1"/>
<field colspan="4" domain="[('parent_id','=',False)]" name="taxes_id"/>
</page>
<page string="Notes">
<field colspan="4" name="notes" nolabel="1"/>
</page>
</notebook>
</form>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 9:36 am 
Offline
Site Admin

Joined: Tue Feb 08, 2005 9:48 am
Posts: 2118
Location: Grand-Rosiere, Belgium
Hello,

This is not a good solution, you should do a clean module. Otherwise, at next migration, your view will be replaced by the new one.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 12:10 pm 
Offline

Joined: Sat Feb 07, 2009 4:58 pm
Posts: 6
I know, but I'm just experimenting with the test database and demo data and this is the quickest way to check things out.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 5:23 pm 
Offline

Joined: Fri Dec 08, 2006 3:46 pm
Posts: 175
Location: Caracas, Venezuela
Quote:
It would be a good idea to package this in a module and push on lunachpad...

I would try to do it and I would like to do the second part too, so i going to do some research about it. Any help will be welcome :)

Regards,

_________________
Javier Duran
Venezuela


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 29, 2009 8:20 am 
Offline

Joined: Wed Jan 28, 2009 12:58 pm
Posts: 158
Location: Spain
Hello,

We couldn't make this work, and we don't know exactly why. It only shows only one of the products from the list of the selected supplier. Is it at last available as a new module in Launchpad?

Best regards and thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 04, 2009 2:24 pm 
Offline

Joined: Mon May 04, 2009 2:19 pm
Posts: 10
Hello,

I'm trying to filter the products by supplier with the domain, but doesn't work for me, openerp returns this error
Code:
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 231, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/usr/lib/python2.5/site-packages/openerp-server/netsvc.py", line 74, in __call__
    return getattr(self, method)(*params)
  File "/usr/lib/python2.5/site-packages/openerp-server/service/web_services.py", line 496, in execute
    res = service.execute(db, uid, object, method, *args)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 59, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 119, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/osv.py", line 111, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/usr/lib/python2.5/site-packages/openerp-server/addons/product/product.py", line 499, in name_search
    ids = self.search(cr, user, [('default_code','=',name)]+ args, limit=limit, context=context)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/orm.py", line 2593, in search
    (qu1, qu2, tables) = self._where_calc(cr, user, args, context=context)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/orm.py", line 2574, in _where_calc
    e.parse(cr, user, self, context)
  File "/usr/lib/python2.5/site-packages/openerp-server/osv/expression.py", line 151, in parse
    ids2 = list(right)
TypeError: 'int' object is not iterable


could anybody help me?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 04, 2009 3:24 pm 
Offline

Joined: Sat Nov 17, 2007 12:35 am
Posts: 265
Location: Madeira, PT
Quote:
could anybody help me?

maybe if you put here your code ...


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 04, 2009 4:06 pm 
Offline

Joined: Mon May 04, 2009 2:19 pm
Posts: 10
Hello,

I modified the code of the purchase.order.form by adding a domain in product_id field.

Here is my domain code.

Code:

  domain="[('seller_ids','=',parent.partner_id)]"


(edit): I try this in 4.2 version of server and works but, in server version 5.0.0.3 it doesn't (it returns the error that I've posted before) and that's the version we are using, How I can make that works in version 5?.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 05, 2009 12:46 pm 
Offline

Joined: Thu Feb 19, 2009 2:33 pm
Posts: 9
Hello,
I can solve this problem :
Quote:
TypeError: 'int' object is not iterable


If you write :
Code:
domain="[('seller_ids','in',[parent.partner_id, 0])]"

you are transforming "partner_id" in a list, and the problem is solve.

But you won't get anything because "seller_ids" is the "id" of the table "product_suplierinfo", and you need to get is the field "name" of the table "product_suplierinfo" which you can compare with partner_id..

_________________
Salu2.

Fdo : LEO


http://www.ting.es


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP