Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][ADD] pos_loyalty_card_fixed_expiration_date: New module pos_loyalty_card_fixed_expiration_date #1287

Conversation

BernatObrador
Copy link

This module introduces the ability to set a fixed expiration date for gift cards.

Follow these steps to configure and use the module:

  1. Navigate to Point of Sale -> Products -> Gift Cards & eWallet.
  2. Create a new record and set the Program Type to Gift Card.
  3. Specify the Duration Days.
  4. Generate gift cards without setting an expiration date.
    • The generated gift cards will automatically have an expiration date set to today's date + Duration Days.
  5. If you manually set an expiration date, the system will use this specified date instead.

cc https://github.com/APSL 165899

@miquelalzanillas @lbarry-apsl @mpascuall @peluko00 @javierobcn @ppyczko please review

@BernatObrador BernatObrador force-pushed the 17.0-add-pos_loyalty_card_fixed_expiration_date branch from e6a951e to 845b497 Compare January 17, 2025 10:13
Copy link

@peluko00 peluko00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Code review and tested in runboat

Copy link

@mpascuall mpascuall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested in runboat and reviewed code

Copy link

@ppyczko ppyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@BernatObrador BernatObrador force-pushed the 17.0-add-pos_loyalty_card_fixed_expiration_date branch from 845b497 to 9e2ce75 Compare February 5, 2025 07:09
@BernatObrador
Copy link
Author

Hi @ivantodorovich, could you review please. Thanks!

# If the expiration date is not set, we set it to
# the current date + the fixed duration
if vals_list:
if not vals_list[0].get("expiration_date", False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right.

vals_list here can be a list containing completely different values. You shouldn't rely only on the first one, for all the records.

Instead you can do something like this:

for record, vals in zip(res, vals_list):
    ...

This works because create will return the records on the same order than the provided values that created them.


But moreover, I wonder if it wouldn't be a better idea to simply make the expiration_date a computed field with store=True, readonly=False, precompute=True, and @api.depends('program_id'), instead of overriding create.

Copy link
Contributor

@ivantodorovich ivantodorovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fail to see the real dependency on Point of Sale.
It looks like a generic loyalty module, that should be proposed in https://github.com/OCA/sale-promotion instead (without the pos_sale dependency)

@BernatObrador
Copy link
Author

@ivantodorovich Totally agree with your changes! Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants