Skip to content

[18.0][MIG] website_sale_affiliate migration from 16.0 to 18.0 - #1228

Open
jans23 wants to merge 7 commits into
OCA:18.0from
Nitrokey:18.0-mig-website_sale_affiliate
Open

[18.0][MIG] website_sale_affiliate migration from 16.0 to 18.0#1228
jans23 wants to merge 7 commits into
OCA:18.0from
Nitrokey:18.0-mig-website_sale_affiliate

Conversation

@jans23

@jans23 jans23 commented May 29, 2026

Copy link
Copy Markdown

No description provided.

@OCA-git-bot OCA-git-bot added series:18.0 mod:website_sale_affiliate Module website_sale_affiliate labels May 29, 2026
@jans23
jans23 force-pushed the 18.0-mig-website_sale_affiliate branch from 08325cd to 1f5d6ec Compare May 29, 2026 19:40
@jans23

jans23 commented May 29, 2026

Copy link
Copy Markdown
Author

@fcayre please review.

@jans23

jans23 commented May 29, 2026

Copy link
Copy Markdown
Author

@pilarvargas-tecnativa could you review this please?

@jans23
jans23 force-pushed the 18.0-mig-website_sale_affiliate branch from fe0825f to 3c41315 Compare May 29, 2026 21:40

@pilarvargas-tecnativa pilarvargas-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello,
Thank you for your contribution. Please check the commit history as it is incomplete.
Regards!

@KDRdev
KDRdev force-pushed the 18.0-mig-website_sale_affiliate branch from 26aed71 to cb183c3 Compare June 2, 2026 11:19
@KDRdev

KDRdev commented Jun 2, 2026

Copy link
Copy Markdown

Hello, Thank you for your contribution. Please check the commit history as it is incomplete. Regards!

@pilarvargas-tecnativa thank you for the review. Could you please check if the current PR version has been prepared as expected? Thanks!

@jans23

jans23 commented Jun 2, 2026

Copy link
Copy Markdown
Author

@pilarvargas-tecnativa Updated accordingly. Please check.

Comment thread website_sale_affiliate/models/sale_affiliate.py
"valid_hours": 24,
"valid_sales": 1,
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change doesn't make any difference either

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caused by pre-commit, which is recommended during module migration according to OCA

@KDRdev KDRdev Jun 12, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Moved to a separate commit from migration commit.

Comment thread website_sale_affiliate/tests/test_sale_affiliate.py
Comment thread website_sale_affiliate/controllers/main.py Outdated
Comment thread website_sale_affiliate/controllers/main.py Outdated
affiliate = request.env["sale.affiliate"].sudo().find_from_kwargs(**kwargs)
if not affiliate:
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is best to avoid leaving spaces between lines of code

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this case I'd argue that this change can stay since we're separating different logical blocks (line 16 is a return statement).

Comment thread website_sale_affiliate/controllers/main.py Outdated
Comment thread website_sale_affiliate/controllers/main.py Outdated
@KDRdev
KDRdev force-pushed the 18.0-mig-website_sale_affiliate branch from cb183c3 to e357fc7 Compare June 10, 2026 15:40
@KDRdev

KDRdev commented Jun 10, 2026

Copy link
Copy Markdown

@pilarvargas-tecnativa I've replied to your comments, could you please have a look. Thank you!

@KDRdev
KDRdev force-pushed the 18.0-mig-website_sale_affiliate branch from e357fc7 to c2c9f95 Compare June 11, 2026 13:47
hughesbm and others added 6 commits June 11, 2026 15:51
* [ADD] website_sale_affiliate: Create module
* Add sale.affiliate and sale.affiliate.request models
* Override WebsiteSale controller shop method to store affiliate
  id & key kwargs of shop urls in session
* Override sale order create method to store affiliate request
* Add affiliate and request views, links in Sales/Affiliates
* Add affiliate_request_id to sale.order form view
* Add request sequence record, make default for new affiliates
* Add access rights to sales users/managers
* Add tests
* Add readme instructions

* [IMP] website_sale_affiliate: Make requested changes
* Update readme
* Add controller override to catch product urls
* Remove redundant return None
* Replace if statements with try/except when appropriate
* Change api decorator on sale.affiliate.find_from_session method
  from model -> model_cr_context
* Add check to avoid unnecessary db search in find_from_session if
  no affiliate_id
* Fix tests
* Add new tests

* [IMP] website_sale_affiliate: Make requested changes
* Un-nest try/except statements for readability
* Rename kwargs: ref, key -> aff_ref, aff_key
* Improve request search speed for large recordsets
* Document similarly-named methods for clarity
* Tweak tests as needed
* Add additional test
* Add roadmap to readme

* [REM] website_sale_affiliate: Remove affiliate request IP-matching

* [IMP] website_sale_affiliate: Change affiliate request creation
* Create affiliate requests regardless of whether a sale occurs
* Add basic conversion/sales stats to affiliate model and views
* Update tests
* Add demo data
* Clean up views
* Remove line used for debugging
* Add field string for clarity

* [FIX] website_sale_affiliate: Fix compatibility issues, tests
* Fix controller method overrides to avoid conflicts
* Match assertAlmostEqual decimal places to amount used in fields
* Remove/replace tests with unneeded url_open calls
* Rename files, variables for clarity
* Clean up demo/test data

* [IMP] website_sale_affiliate: Clarify affiliate request name
* Add help to name field on affiliate request model
* Handle the case of no web session, which will raise a `RuntimeError('object unbound')` when attempting to access it. This happens during XML record creations, but likely other places such as in the shell
@KDRdev
KDRdev force-pushed the 18.0-mig-website_sale_affiliate branch 5 times, most recently from 1e2c380 to 7e7ae03 Compare June 12, 2026 09:10
@KDRdev

KDRdev commented Jun 12, 2026

Copy link
Copy Markdown

@pilarvargas-tecnativa I've made changes as per your suggestions, could you please have another look? Thanks!

@KDRdev

KDRdev commented Jun 24, 2026

Copy link
Copy Markdown

@pilarvargas-tecnativa just a friendly reminder for you. Thanks!

)

@api.model
@api.model_create_multi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this change to @api.model_create_multi really needed for the migration?

As it is now, the method is decorated as multi-create but still receives vals as a single dict and processes order as a single record. So it looks half-adapted and could be misleading or problematic if several records are created at once.

If there is no specific need to support multi-create here, I think it would be cleaner to keep the previous @api.model signature for the migration.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I fixed this.

except KeyError:
pass
except KeyError as err:
_logger.debug(err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any reason to log this exception?

Previously, the absence of aff_ref was silently ignored, which seems to be the expected and common case. I'm wondering whether this debug log adds any value, or if it would be better to keep the previous behavior.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I fixed this.

except (AttributeError, ValueError):
pass
except (AttributeError, ValueError) as err:
_logger.debug("Could not store affiliate info: %s", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question here: is there any specific reason for adding this log?

Since this is a migration, I'd prefer to avoid introducing new logging unless it addresses a known issue or provides information that is actually useful in production.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I fixed this.

@jans23
jans23 force-pushed the 18.0-mig-website_sale_affiliate branch from 7e7ae03 to bf5a716 Compare July 7, 2026 09:23
@jans23

jans23 commented Jul 7, 2026

Copy link
Copy Markdown
Author

@pilarvargas-tecnativa Thank you very much for the review. I just addressed it in the code.

@jans23
jans23 force-pushed the 18.0-mig-website_sale_affiliate branch 3 times, most recently from b3a6958 to 77951fd Compare July 7, 2026 10:32
@jans23

jans23 commented Jul 24, 2026

Copy link
Copy Markdown
Author

@pedrobaeza this got two reviews and it could be merged I think.

@pedrobaeza

Copy link
Copy Markdown
Member

But there aren't approvals.

@jans23

jans23 commented Aug 9, 2026

Copy link
Copy Markdown
Author

@pilarvargas-tecnativa All your comments are addressed. Please have another look.

@pilarvargas-tecnativa

Copy link
Copy Markdown
Contributor

@pilarvargas-tecnativa All your comments are addressed. Please have another look.

You don’t need a separate commit to migrate the module as a FIX for the migration, simply include the changes in the migration commit

@jans23
jans23 force-pushed the 18.0-mig-website_sale_affiliate branch from 77951fd to f254502 Compare August 10, 2026 08:22
@jans23

jans23 commented Aug 10, 2026

Copy link
Copy Markdown
Author

@pilarvargas-tecnativa Squased as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:website_sale_affiliate Module website_sale_affiliate series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants