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

[15.0][IMP+FIX] dms: Improve performance + Avoid non-existing record access error #350

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

victoralmau
Copy link
Member

@victoralmau victoralmau commented Jul 22, 2024

Improve performance + Avoid non-existing record access error

Changes done:

  • Improve _dms_operations() method to do nothing if the model is not one of those used in dms.storage.
  • Avoid access error with .browse() if we access a non-existing record (for example, deleted by database).

Please @pedrobaeza and @chienandalu can you review it?

@Tecnativa TT50231

Sorry, something went wrong.

@pedrobaeza pedrobaeza added this to the 15.0 milestone Jul 26, 2024
@victoralmau victoralmau force-pushed the 15.0-fix-dms-TT50231 branch from 890c821 to 1fbf2a5 Compare August 6, 2024 07:29
"""
# Apply sudo to prevent ir.rule from being applied.
storages = self.env["dms.storage"].sudo().search([("model_ids", "!=", False)])
dms_models = storages.mapped("model_ids.model")
Copy link
Member

Choose a reason for hiding this comment

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

If we continue this way, this must be cached and invalidate when changes. But I don't ge why res_model and res_id, which is a core mechanism, is filled for the DMS, and we may need to avoid it and use other fields.

… error

Changes done:
- Improve _dms_operations() method to do nothing if the model is not one of
those used in dms.storage.
- Avoid access error with .browse() if we access a non-existing record (for
example, deleted by database).

TT50231
@victoralmau victoralmau force-pushed the 15.0-fix-dms-TT50231 branch from 1fbf2a5 to bdbd0ae Compare August 9, 2024 13:29
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-350-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d78cf29 into OCA:15.0 Aug 12, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

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

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.

None yet

3 participants