コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1384 ビュー

In Odoo  16, I'm trying to control the list of available products in POS by a custom field I've added to product.product model. The custom field is a boolean field called 'has_cretan_product'

I'm inheriting pos.session in my custom model (I've already added point_of_sale in the dependencies of the manifest.py file of my custom model) and then I extend the _loader_params_product_product function as follows:

from odoo import models, fields, api
from odoo.osv.expression import AND
classPosSessionInherit(models.Model):
    _inherit="pos.session"
    def_loader_params_product_product(self):
        result = super()._loader_params_product_product()
        result['search_params']['fields'].extend(['has_cretan_product'])       
        domain=result['search_params']['domain']       
​ result['search_params']['domain']=AND([[('has_cretan_product','=',True)],domain])
        print (f"result[search params] is {result['search_params']}")
        return result   


In code above the print command returns:
result[search params] is {'domain': ['&', ('has_cretan_product', '=', True), '&', '&', ('sale_ok', '=', True), ('available_in_pos', '=', True), '|', ('company_id', '=', 2), ('company_id', '=', False)], 'fields': ['display_name', 'lst_price', 'standard_price', 'categ_id', 'pos_categ_id', 'taxes_id', 'barcode', 'default_code', 'to_weight', 'uom_id', 'description_sale', 'description', 'product_tmpl_id', 'tracking', 'write_date', 'available_in_pos', 'attribute_line_ids', 'active', 'has_cretan_product'], 'order': 'sequence,default_code,name'}

which is the domain I want.

Still, when POS screen loads all products are displayed in the list, event those with has_cretan_product field equal to False.


Why aren't they omitted? What am I doing wrong?




アバター
破棄
最善の回答

I've same problem with domain in _loader_params_product_product. Anyone solved? Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 22
2407
1
10月 22
5197
1
7月 22
1911
2
7月 22
19301
0
3月 19
2912