콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
10010 화면

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=True

or:

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.

Regards

아바타
취소
관련 게시물 답글 화면 활동
0
3월 23
4706
1
7월 25
442
Search a message 해결 완료
1
2월 25
1224
0
9월 23
2171
2
6월 23
3958