Skip to Content
मेन्यू
This question has been flagged
1 Reply
1446 Views

I make some user option and I want to read it from POS screen in version 18 

this is my code 


class PosSession(models.Model):
    _inherit = 'pos.session'
    def _load_pos_data(self, data):
        res = super(PosSession, self)._load_pos_data(data)
        res['hide_product_information'] = self.env.user.hide_product_information
        return res

and I want to read it from JavaScript level from the product screen 
with this code 

patch(ProductScreen.prototype, {

    async onProductInfoClick(product) {

        // here

    }

}) 


how can I do this 



Avatar
Discard
Author

thanks it's working

Best Answer

Hello Ahmed,


Hope you're doing well.


To make the 'hide_product_information' field accessible on the Product screen, you can use the following approach:


class ResUsers(models.Model): 

    _inherit = 'res.users' 


    hide_product_information = fields.Boolean() 


    @api.model 

    def _load_pos_data_fields(self, config_id): 

        res = super()._load_pos_data_fields(config_id) 

        res += ['hide_product_information'] 

        return res 


After restarting the server, you can access the 'hide_product_information' field using:

this.pos.config.current_user_id.hide_product_information


Let me know if you need further clarification!


Thanks & Regards,

Baldev Bharvadiya

Avatar
Discard
Related Posts Replies Views Activity
1
मार्च 24
5484
1
जुल॰ 23
2686
1
दिस॰ 22
3656
12
सित॰ 21
25577
1
मई 17
4213