pos_ui_optimization/models/res_partner.py

20 lines
870 B
Python

# -*- coding: utf-8 -*-
from odoo import models, api
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.model
def _load_pos_data_domain(self, data, config):
# Set context flag to force loyalty member loading limit to 0
self_with_context = self.with_context(pos_load_loyalty_limit_zero=True)
return super(ResPartner, self_with_context)._load_pos_data_domain(data, config)
@api.model
def search(self, args, offset=0, limit=None, order=None):
# Intercept the search for extra loyalty members when loading POS data
# and return an empty recordset to change the loaded/cached members count to 0
if self.env.context.get('pos_load_loyalty_limit_zero') and limit == 30:
return self.browse()
return super(ResPartner, self).search(args, offset=offset, limit=limit, order=order)