Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

Search products by supplier code

By
Andrea Cometa
on 6/27/13, 4:55 AM 3,567 views

Is there a way to filter products, by product_code from supplierinfo?

4

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 8/12/14, 8:28 AM

Hi,

If the requirement is only to search products with 'Supplier Product Code', then there is no need for creating any functional field. Create a related field and Include this field in Search View.

'product_code' : fields.related('seller_ids', 'product_code',  string='Supplier Product Code', type='char', size=64)

0
David Verove
On 2/10/16, 11:48 AM

Use module following module from Akretion : 

https://www.odoo.com/apps/modules/7.0/product_search_supplier_code/

0
Branimir
On 8/1/13, 5:59 AM

I started working on that. So far I found out how to add the field showing the Supplier Code of the default Supplier but have issues making it searchable.

In /product/product.py change the function _calc_seller adding field:

'seller_product_code': main_supplier and main_supplier.product_code or False

then in the class product_product add field:

'seller_product_code': fields.function( _calc_seller, type='string',string='Supplier Reference Code',multi="seller_info"),

You can easily make it visible in the tree view. just add:

<field name="seller_product_code" string="Supplier Refference"/>

in product_product_tree_view in /product/product_view.xml

Now to search in this field is more complicated cause it is a calculated field: fields.function( _calc_seller,... Either it has to be stored (I couldn't make it work), or to provide _fnct_search (how do you do that?) Or maybe it doesn't need to be function field since the Supplier Code is already in stored in the database, but it uses function to get the code of the default supplier (the one with the most priority).

Can someone can help with this?

The correct code would be: 'seller_product_code': fields.function( _calc_seller, type='char',string='Supplier Reference Code',multi="seller_info",store=True)

Branimir
on 11/13/13, 5:23 AM
0
User198605
On 7/28/14, 6:56 AM

Hi @Branimir, I am also looking for the same kind of feature.  User shall be able to search products by "Supplier Product code".  

I tried your above solution.  But did not work for me.  Please help me if I need to do any thing more.

I am getting following error:

ProgrammingError: column product_product.seller_product_code does not exist LINE 1:   ...ct."default_code",product_product."name_template",product_pr...

I could not find place to comment.  So I am putting in answer block.  Sorry.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/27/13, 4:55 AM
Seen: 3567 times
Last updated: 2/14/16, 12:40 PM