Odoo Help


How to make Function Field with Store parameter?

on 7/30/13, 6:27 AM 5,094 views

I'm trying to add a searchable field to product.product with the Supplier Reference Code. There is a function already provided to get the default Supplier, so I just had to add the 'seller_product_code' field:

    def _calc_seller(self, cr, uid, ids, fields, arg, context=None):
    result = {}
    for product in self.browse(cr, uid, ids, context=context):
        main_supplier = self._get_main_product_supplier(cr, uid, product, context=context)
        result[product.id] = {
            'seller_info_id': main_supplier and main_supplier.id or False,
            'seller_delay': main_supplier.delay if main_supplier else 1,
            'seller_qty': main_supplier and main_supplier.qty or 0.0,
            'seller_id': main_supplier and main_supplier.name.id or False,
            'seller_product_code': main_supplier and main_supplier.product_code or False
    return result

Then I added this in product.product:

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

Until here everything is OK, but now to be able to search it it has to be stored as I understand (or needs fnct_search). I tried putting it as:



store={'product.supplierinfo': (lambda self, cr, uid, ids, c={}: ids,['product_code'],10)}

But it gives me Error:

AttributeError: 'module' object has no attribute 'string'

What is wrong? How can I make it stored so I can search it, or how the fnct_search must look like?


Hello Branimir,

You have provided wrong data-type as "String" which is not supported/provided by odoo, you should either use "Char" or "Text". It should be like type="char" or type="text", in your definition of fields.function.


About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/30/13, 6:27 AM
Seen: 5094 times
Last updated: 3/16/15, 8:10 AM