-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
[10.0][IMP] barcodes_generator_abstract: Add automated generator #77
[10.0][IMP] barcodes_generator_abstract: Add automated generator #77
Conversation
15dfe72
to
8812509
Compare
* Add an option to allow for automatic generation of barcode when a record of mixin model is created
8812509
to
e7fb1cf
Compare
Rebased now that dependency is merged, this is ready for review! |
👍 great improvment ! Thanks. |
)) | ||
should_clear = True | ||
if should_clear: | ||
self.clear_caches() |
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.
Why don't you clear this on create/write when vals contains 'generate_automate' value?
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.
Hmmmm yeah that would work too, although then we'd be splitting the logic into two spots & it would need to be a conjoined if - because this is also clearing cache if generate_model
is changed too.
I could remove the somewhat ghetto should_clear
as if len(self)
instead though, which would remove two lines and be the same level of efficiency.
I do somewhat take reservation to a mutating operation in a constraint though, so it might still be best to bite the bullet and move into the two spots. Any additional thoughts?
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.
For keeping the same logic, just create a new method that is called from both write/create methods. I still miss the wanted @onwrite decorator: odoo/odoo#11042
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.
Oh wow I love this @onwrite
idea. It also reminded me that I needed to create the API lib from OCA/server-tools#615. I think I'll try to tackle that this weekend.
Also, yeah cool a helper method seems almost excessive, but it is better than code duplication. It's also better than a mutation in a constraint, even if the mutation is just a cache deletion.
* Move cache clearing into create/write & centralize method based on keys in vals
This is dependent on the migration PR:
I'd like the two reviewed independently though to allow for easier back port. Relevant commit 02d2303
Still need to test more & add actual tests, so consider this a PoC.
cc @legalsylvain