Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
1383 Weergaven

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?




Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
nov. 22
2401
1
okt. 22
5197
1
jul. 22
1911
2
jul. 22
19295
0
mrt. 19
2912