fix: restrict loyalty member status to active cards and programs
This commit is contained in:
parent
afc702cdf8
commit
815fba780b
@ -14,17 +14,21 @@ class ResPartner(models.Model):
|
||||
compute='_compute_is_loyalty_member',
|
||||
)
|
||||
|
||||
@api.depends('loyalty_card_ids')
|
||||
@api.depends('loyalty_card_ids.active', 'loyalty_card_ids.program_id.active')
|
||||
def _compute_is_loyalty_member(self):
|
||||
for partner in self:
|
||||
partner.is_loyalty_member = bool(partner.loyalty_card_ids)
|
||||
partner.is_loyalty_member = any(card.active and card.program_id.active for card in partner.loyalty_card_ids)
|
||||
|
||||
@api.model
|
||||
def _load_pos_data_domain(self, data, config):
|
||||
domain = super()._load_pos_data_domain(data, config)
|
||||
# Limit initial load of extra loyalty members to 30 to ensure fast POS startup (1-2 seconds)
|
||||
loyalty_members = self.search(
|
||||
[('is_company', '=', False), ('loyalty_card_ids', '!=', False)],
|
||||
[
|
||||
('is_company', '=', False),
|
||||
('loyalty_card_ids.active', '=', True),
|
||||
('loyalty_card_ids.program_id.active', '=', True),
|
||||
],
|
||||
limit=30,
|
||||
order='write_date desc'
|
||||
)
|
||||
@ -40,7 +44,11 @@ class ResPartner(models.Model):
|
||||
@api.model
|
||||
def get_new_partner(self, config_id, domain, offset):
|
||||
# Limit active searches strictly to individual customers who are loyalty members
|
||||
domain.extend([('is_company', '=', False), ('loyalty_card_ids', '!=', False)])
|
||||
domain.extend([
|
||||
('is_company', '=', False),
|
||||
('loyalty_card_ids.active', '=', True),
|
||||
('loyalty_card_ids.program_id.active', '=', True),
|
||||
])
|
||||
return super().get_new_partner(config_id, domain, offset)
|
||||
|
||||
@api.model_create_multi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user