feat: synchronize active status for loyalty subscriptions and refine card validation logic in POS
This commit is contained in:
parent
075d5055a7
commit
d5a406e566
@ -33,5 +33,5 @@ class LoyaltyCard(models.Model):
|
||||
@api.model
|
||||
def _load_pos_data_fields(self, config):
|
||||
fields_list = super()._load_pos_data_fields(config)
|
||||
fields_list.extend(['subscription_start_date', 'subscription_end_date', 'subscription_usage_count'])
|
||||
fields_list.extend(['subscription_start_date', 'subscription_end_date', 'subscription_usage_count', 'active'])
|
||||
return fields_list
|
||||
|
||||
@ -44,8 +44,13 @@ class LoyaltyProgram(models.Model):
|
||||
|
||||
def write(self, vals):
|
||||
if vals.get('program_type') == 'subscription' or (not vals.get('program_type') and any(p.program_type == 'subscription' for p in self)):
|
||||
vals['manual_membership'] = True
|
||||
vals['trigger'] = 'auto'
|
||||
vals['applies_on'] = 'both'
|
||||
vals['portal_visible'] = True
|
||||
if any(not p.manual_membership for p in self):
|
||||
vals['manual_membership'] = True
|
||||
if any(p.trigger != 'auto' for p in self):
|
||||
vals['trigger'] = 'auto'
|
||||
if any(p.applies_on != 'both' for p in self):
|
||||
vals['applies_on'] = 'both'
|
||||
if any(not p.portal_visible for p in self):
|
||||
vals['portal_visible'] = True
|
||||
return super().write(vals)
|
||||
|
||||
|
||||
@ -38,7 +38,11 @@ patch(PosOrder.prototype, {
|
||||
return cardPartnerId === partner.id && cardProgramId === program.id;
|
||||
});
|
||||
|
||||
if (!card || !card.active) {
|
||||
if (!card) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (card.id < 0 || !card.active) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user