-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
[16.0][FIX] document_page_tag: Use api.model_create_multi #491
Conversation
64a8591
to
4f09857
Compare
d83332f
to
6abb713
Compare
@api.model_create_multi | ||
def create(self, vals_list): | ||
"""Be nice when trying to create duplicates""" | ||
existing = self.search([("name", "=ilike", vals["name"])], limit=1) | ||
if existing: | ||
return existing | ||
return super().create(vals) | ||
for vals in vals_list: | ||
existing = self.search([("name", "=ilike", vals["name"])], limit=1) | ||
if existing: | ||
return existing | ||
return super().create(vals_list) |
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.
Issue: When trying to create two tags at the same time, one that exists and one that doesn't, we return the one tag that does exist and don't create the one that doesn't.
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.
Changes included to handle tag creation with one exist and not exist at the same time
6abb713
to
e6c793d
Compare
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.
Code Review: generally seems good. The only issue I have is with the variable names in the test (not your fault, they were already done like this).
We might consider converting them to snake_case format
e6c793d
to
8a82c39
Compare
watch out for the pre-commit error at line 68 in |
Using decorator api.model_create_multi for create method in document_page_tag model
8a82c39
to
9d749c8
Compare
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.
Code review: LGTM
This PR has the |
/ocabot merge patch |
On my way to merge this fine PR! |
Congratulations, your PR was merged at 6bece12. Thanks a lot for contributing to OCA. ❤️ |
Using decorator api.model_create_multi for create method in document_page_tag model in order to avoid below warning:
WARNING devel odoo.api.create: The model odoo.addons.document_page_tag.models.document_page_tag is not overriding the create method in batch