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

[14.0][FW] ddmrp: multiple ports from 15.0 #300

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ddmrp/models/stock_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ def action_view_future_adu(self):
@api.model
def cron_ddmrp_adu(self, automatic=False):
"""calculate ADU for each DDMRP buffer. Called by cronjob."""
auto_commit = not getattr(threading.currentThread(), "testing", False)
auto_commit = not getattr(threading.current_thread(), "testing", False)
Copy link
Contributor

Choose a reason for hiding this comment

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

In v14 I can see multiple usages of threading.current_thread(). Are you sure this is a needed backport?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed, probably not.
I checked on Python 3.7 / 3.8 / 3.9, and both are equivalent:

Python 3.7.3 (default, Oct 31 2022, 14:04:00) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> threading.currentThread == threading.current_thread
True
Python 3.8.10 (default, May 26 2023, 14:05:08) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> threading.currentThread == threading.current_thread
True
Python 3.9.5 (default, Nov 23 2021, 15:27:38) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> threading.current_thread == threading.currentThread
True

So I guess it's safe to backport it as it's supported on old Python versions (especially the 3.7 which is the one recommended by Odoo I think for v14? I don't remember).
If you prefer to not backport it you tell me!

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, thanks for double checking! I think we can merge as is.

_logger.info("Start cron_ddmrp_adu.")
buffer_ids = self.search([]).ids
i = 0
Expand Down Expand Up @@ -1982,7 +1982,7 @@ def cron_actions(self, only_nfp=False):
def cron_ddmrp(self, automatic=False):
"""Calculate key DDMRP parameters for each buffer.
Called by cronjob."""
auto_commit = not getattr(threading.currentThread(), "testing", False)
auto_commit = not getattr(threading.current_thread(), "testing", False)
_logger.info("Start cron_ddmrp.")
buffer_ids = self.search([]).ids
i = 0
Expand Down
2 changes: 1 addition & 1 deletion ddmrp_warning/models/stock_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

@api.model
def cron_generate_ddmrp_warnings(self, automatic=False):
auto_commit = not getattr(threading.currentThread(), "testing", False)
auto_commit = not getattr(threading.current_thread(), "testing", False)

Check warning on line 48 in ddmrp_warning/models/stock_buffer.py

View check run for this annotation

Codecov / codecov/patch

ddmrp_warning/models/stock_buffer.py#L48

Added line #L48 was not covered by tests
buffer_ids = self.search([]).ids
i = 0
j = len(buffer_ids)
Expand Down