[19.0][MIG]base_multi_company#889
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.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: multi-company-12.0/multi-company-12.0-base_multi_company Translate-URL: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-base_multi_company/
Currently translated at 70.0% (7 of 10 strings) Translation: multi-company-12.0/multi-company-12.0-base_multi_company Translate-URL: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-base_multi_company/zh_CN/
[IMP]IMP Code. [FIX] [IMP]
57201c2 to
11bb692
Compare
|
This PR has the |
|
@OCA-git-bot remind the maintainers to merge this Pr pls. cc @weinni2000 |
|
@Vandan-Pandeji-SerpentCS I made a PR to your branch, could you check? Vandan-Pandeji-SerpentCS#2 |
|
@Vandan-Pandeji-SerpentCS could you add the missing commits since the PR was opened? Thank you. @moduon MT-14423 |
|
@Vandan-Pandeji-SerpentCS could you please check the PR that @astirpe commented you and apply the missing commits? Those comments are quite old. Otherwise, we’ll have to superseed the PR. Thank you. |
@EmilioPascual Done. Could you please check now? |
There are still some commits missing from 18.0 such as 1de1ecc, 35e45c0 or bb502d6 |
Okay, I'll add it. |
b61759a to
7d357a5
Compare
7d357a5 to
0fd2a47
Compare
|
@EmilioPascual |
| if company_id in sudo_record.company_ids.ids: | ||
| record.company_id = company_id | ||
| else: | ||
| record.company_id = sudo_record.company_ids[:1].id |
There was a problem hiding this comment.
Testing this module in a complete instance we're having some issues with this compute in certain cases when a NewId enters from an onchange or something like that...
It causes this error:
File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_partner.py", line 477, in _compute_same_vat_partner_id
partner.same_vat_partner_id = should_check_vat and not partner.parent_id and Partner.search(domain, limit=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.ProgrammingError: can't adapt type 'NewId'
This code is more resilient as we tested locally:
| if company_id in sudo_record.company_ids.ids: | |
| record.company_id = company_id | |
| else: | |
| record.company_id = sudo_record.company_ids[:1].id | |
| company_ids = sudo_record.company_ids._origin.ids or sudo_record.company_ids.ids | |
| if company_id in company_ids: | |
| record.company_id = company_id | |
| else: | |
| company = sudo_record.company_ids[:1] | |
| if company and isinstance(company.id, models.NewId): | |
| record.company_id = company._origin.id or False | |
| else: | |
| record.company_id = company.id |
There was a problem hiding this comment.
@chienandalu could you review #1009?
I think I've fixed it
No description provided.