-
-
Notifications
You must be signed in to change notification settings - Fork 534
[13.0] Add storage of context in jobs recordsets #432
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
Conversation
aefd0b2 to
cd5df7e
Compare
cd5df7e to
9b0dbea
Compare
9b0dbea to
bfc52a3
Compare
It can still be activated by overriding a method.
florian-dacosta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
sbidoul
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fine with me.
|
/ocabot merge minor Any plan for v14? |
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
Congratulations, your PR was merged at b9d89ef. Thanks a lot for contributing to OCA. ❤️ |
|
Hi @guewen @simahawk @acsonefho , so going back to the original need (from PR #407 ):
How do you suggest to implement this? should we create a new module "base_import_async_lang" here on OCA to set language in the context? |
|
@OCA/connector-maintainers |
Maybe you can create a module who contains only this: Then ping Guewen and Simahawk to have review and feedback :) |
|
@acsonefho thanks a lot! |
|
Instead of adding a new module, you can make |
|
Hello, I've been trying to use this feature to send a context from the creation of the job to the actual job runtime itself but I feel like there's something missing. With this added it runs the jobs with the context that was passed, plus the ones added later for I just want to check if this is intentionally left out (for backwards compatibility I guess?) and is planned for 16.0 or it was an oversight, because I couldn't find any discussion on this part specifically in the various related PRs It can be worked around by searching the |
|
@simahawk how shall we proceed? |
|
@francesco-ooops Expanding on @acsonefho 's suggestion, I'd create a module that does only this: queue/queue_job/models/base.py Line 261 in c8b16ff
Since that will become the default in v16, it seems reasonable to have module that anticipates the default, which you can install if you are sure that all your jobs are compatible with that.
@hildickethan-S73 that makes sense (disclaimer: I've not tested myself). Would you mind doing a PR with the missing part? |
|
I totally agree with @acsonefho and @sbidoul proposal, it's like an opt-in to the behavior that will be the default in 16.0 |
|
@hildickethan-S73 ooch, that's indeed an oversight from my part 🤦. This line that initializes the record(s) from the Json in JobDecoder has to set the context: model = self.env(user=obj.get("uid"), su=obj.get("su"))[obj["model"]] (Sorry, I'm on my phone and can't manage to copy-paste the exact link in the GitHub app😓) |
Hi there, we developed a module to return the Are we missing something? |
sorry my fault ..working properly |
|
Alternative to #406.
Adapted from acsone#1 with tests.
This version has a breaking change in the sense that now the basic arguments such as tz, lang, etc in the context are kept, so may bring behavior changes in the existing jobs. In a way, this could be considered a bug so... to discuss (or consider this is the version we want for 16.0, and the list will be empty in earlier versions).
I would not keep all keys by default for several reasons :
prefetch_fields)This implementation may be simple and naive, but I do think it is enough, as people can customize the keys allowed in the context. Also, more smart solutions could easily lead to leaky abstractions, because jobs can have contexts in their
selfrecordset, but also inargsandkwargswhich potentially would all need different handling (hence a global handling works for each case).