Skip to content

Conversation

@guewen
Copy link
Member

@guewen guewen commented Nov 13, 2020

Replaces #272

Previously, the "main" record, the one on which the job works, was stored in 3 fields: model_name, user_id and record_ids (and the support for any new field such as sudo or context would need a new field). The records of args and kwargs are serialized in JobSerialized fields.

This PR unifies the way they are stored: the "main" record is now stored in a JobSerialized field as well.
The support of the su flag (which means the record was sudo()-ed), is added in the second commit, which shows how we benefit from the refactor.

The original fields are kept:

  • model_name is stored for the UI (used in search or groupby)
  • user_id is stored for the same reason, but also has a inverse method that updates the serialized record
  • record_ids is kept only for backward compatibility, but could be removed in 14.0

Guewen Baconnier added 2 commits November 13, 2020 14:26
These fields contain the current model and record ids and user id the
job works on.
Storing them as separate fields does not allow to take benefits on the
"JobSerialized" field, which keeps the original user, and later the 'su'
flag. We could store the context there as well (or a cleaned one).

Use computed fields to keep the model_name, record_ids, user_id fields for
backward compatibility. The model_name should stay anyway for the
searches on the UI, and the user_id for the same reason + possibility to
edit the user.
Which means that the record the job is working on, or any record
argument of the job keeps the 'su' flag.
@guewen guewen mentioned this pull request Nov 13, 2020
Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

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

LG (just code review)

list: "[]",
tuple: "[]",
models.BaseModel: lambda env: json.dumps(
{"_type": "odoo_recordset", "model": "base", "ids": [], "uid": env.uid}
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we store record.context too?

Copy link
Member Author

Choose a reason for hiding this comment

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

This clearly opens this possibility, this is definitely where the context has to be stored. I mentioned it in the commit message :)
However, there are some questions about what should be allowed or not to store in the context (cf #121), also whether we should or not always store it (can take useless space?), so it should not be part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

created #283

@guewen
Copy link
Member Author

guewen commented Nov 18, 2020

/ocabot merge nobump

(version is changed in the PR already)

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 13.0-ocabot-merge-pr-281-by-guewen-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 11219f6 into OCA:13.0 Nov 18, 2020
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 644a4a5. Thanks a lot for contributing to OCA. ❤️

guewen pushed a commit to guewen/queue that referenced this pull request Dec 1, 2020
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
guewen pushed a commit to guewen/queue that referenced this pull request Dec 1, 2020
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
guewen pushed a commit to guewen/queue that referenced this pull request Dec 1, 2020
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
etobella pushed a commit to tegin/queue that referenced this pull request Apr 19, 2021
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
bizzappdev pushed a commit to BizzAppDev-Systems/queue that referenced this pull request Nov 23, 2023
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
bizzappdev pushed a commit to BizzAppDev-Systems/queue that referenced this pull request Nov 23, 2023
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
nguyenminhchien pushed a commit to nguyenminhchien/queue that referenced this pull request Nov 25, 2023
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 19, 2024
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
QuocDuong1306 pushed a commit to QuocDuong1306/queue that referenced this pull request Sep 24, 2024
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
thienvh332 pushed a commit to thienvh332/queue that referenced this pull request Oct 7, 2024
Following changes of OCA#281
The initial sudo() is lost when we call "with_env()" with a False su
flag. Ensure the read job.record keeps a su flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants