-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
[12.0] migrage base multi company + improve performance #123
Conversation
* Create new module to provide base multi company logic and mixin * Add deactivation by company mixin * Add company_id/ids handling * Add break after company is found Squashed commits: [854cc36] Increase test coverage [770bd71] Revert hook view create back to model init [40e803e] Fix apples and oranges [7a4dfb4] Use registry correctly [6e9f170] Switch company_id to computed & move company aliased view creation to post init hook [faa4fc9] Remove active functionality [fecfb59] Add explicit tests for active and inactive searches
* Revert "Revert hook view create back to model init" This reverts commit 770bd71. * [FIX] base_multi_company: Always create the view into a pre_init_hook to avoid error in log
Squashed commits: [4c17d04] auto_join company_ids
…ch domain on company_id/company_ids (+1 squashed commit) Squashed commits: [fe161fe] [ADD] setup.py
- Test if a company is set in inverse method (+1 squashed commit) Squashed commits: [d670f30] [FIX] fix init hooks as company_id is not stored anymore
* Add implementation instructions to ReadMe
[FIX] Fix issue based on the computation of company_id for multi_company_abstract models [FIX] Fix issue based on the computation of company_id for multi_company_abstract models [FIX] Fix issue based on the computation of company_id for multi_company_abstract models [FIX] Bad branch version pushed before [FIX] Bad branch version pushed before [FIX] manifest Fix flake Flake8 on OCA tests
… are bound to some company
Currently translated at 88.9% (8 of 9 strings) Translation: multi-company-10.0/multi-company-10.0-base_multi_company Translate-URL: https://translation.odoo-community.org/projects/multi-company-10-0/multi-company-10-0-base_multi_company/pt/
Odoo now checks if the user who creates the transient model is the same that is accessing its data, so we need to create it with the same user.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
* Abstract model shouldn't have default for `company_ids`. It will be got by default `company_id` value. * Record rule based on `company_id` makes the evaluation slower. Switch to `company_ids` field. * Add `@api.depends` to `company_id` computation for proper refresh. * Fix tests that were not correct but luckily previously suceeded. Now that other code has been removed, they have been uncovered.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
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.
please use the fragment readme
@tbaden There is no "Implementation" section and I don't really see a suitable section in the readme files for this part. Any idea? |
Put it inside usage section with |
@pedrobaeza Thanks for the hint, I'll do that |
@tbaden Readme has been split. |
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 👍
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
This PR has the |
return | ||
rule.write({ | ||
'active': True, | ||
'domain_force': ( |
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.
@florian-dacosta I am doing #136 which has error from this rule writing. In partner_multi_company, it will error when I create a new company which also create res.partner.
Can you change to following, because normally we need to have term "or company_id = False" to avoid that error.
'domain_force': ( | |
'domain_force': ( | |
"['|', '|', ('company_ids', 'in', user.company_id.ids)," | |
" ('visible_for_all_companies', '=', True), ('company_id', '=', False)]" | |
), | |
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.
I think now that a better technique is to duplicate the rule, and deactivate the old one, and on uninstall, delete the new one, and activate the old.
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.
Allow me to confirm my understanding,
The domain_force in this base_multi_company should stay like this, and the changes per mentioned goes to partner_multi_company, correct?
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.
Also, this one can be merged soon to fix dependency? :)
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.
@pedrobaeza I think the problem is not the modification of the rule, but the value in domain_force that raise an error when it should not, in a specific case.
It is True that it could be cleaner to do it this way (activate/deactivate) but it won't change this particular problem.
@kittiu I checked a little, I am not sure why it fails exactly, and only in this particular case.
It seems the visible_for_all_companies
field is computed too late...
Anyway, I don't think that changing the domain for all models/modules is the good solution.
Indeed, the changes have been made to improve the poor performance of this rule, and adding ('company_id', '=', False)
once again revert the performance improvments.
So the domain could eventually be changed in partner_multi_company, to fix this very particular problem, but it will have an impact on performance.
Another ideal which could be implemented in this base module is to add a default value True to visible_for_all_companies
field.
This way, the record rule won't fail during creation if visible_for_all_companies
is not computed yet.
And if it is computed, it will get the right value...
@pedrobaeza any comment about this?
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.
@florian-dacosta as you mentioned about default=True, I try add 2 lines in your abstract class, and it works fine.
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.
@kittiu Actually the second line is not necessary.
I made the change
fc8ab72
to
2be4f5a
Compare
Test are failing, but it seems it is not because of this module. |
@florian-dacosta I also can't find the exact problem. But I found that, if we run test_multi_company_abstract, we will get this error,
|
Well I was wrong, the failing was really because of this module. |
@florian-dacosta thanks for the fix. Now it works, and also works with partner_multi_company too #136 |
@kittiu |
@florian-dacosta how to approve, I don't have rights :p |
@kittiu Of course you have! |
@pedrobaeza Could you merge this? |
/ocabot merge |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 2ff8a10. Thanks a lot for contributing to OCA. ❤️ |
@pedrobaeza @florian-dacosta |
This is not a fix, but a migration PR. Anyway, you can do a PR with anything you consider for improving the module. |
@pedrobaeza |
Standard migration + improve performance applying idea proposed by @sbidoul in #109
@Cedric-Pigeon