-
-
Notifications
You must be signed in to change notification settings - Fork 532
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][mig] default_multi_user: Migration to 16.0 #619
Closed
Closed
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bfa7f25
[11.0][ADD] default_multi_user
LoisRForgeFlow d541b0c
[UPD] Update default_multi_user.pot
oca-travis fcd2845
[12.0][MIG] default_multi_user
LoisRForgeFlow a0ad4cb
[UPD] Update default_multi_user.pot
oca-travis 0a76c4e
[IMP] default_multi_user: black, isort, prettier
LoisRForgeFlow f31273b
[13.0][MIG] default_multi_user
LoisRForgeFlow 2700c99
[UPD] Update default_multi_user.pot
oca-travis bf48746
[UPD] README.rst
OCA-git-bot d9a2375
[13.0][FIX] default_multi_user: multi company issue
LoisRForgeFlow cad2f4f
default_multi_user 13.0.1.0.1
OCA-git-bot 30a968b
[IMP] default_multi_user: black, isort, prettier
schhatbar-initos 099856e
[14.0][MIG]default_multi_user
schhatbar-initos 4184ce5
[UPD] Update default_multi_user.pot
oca-travis edcb417
[UPD] README.rst
OCA-git-bot 47485c8
Added translation using Weblate (Spanish)
anasuarez1 d3d3aad
Translated using Weblate (Spanish)
anasuarez1 86e5de4
Added translation using Weblate (Portuguese)
pedrocs-exo 38548d7
Translated using Weblate (Portuguese)
pedrocs-exo 88e05da
[MIG] default_multi_user: Migration to 15.0
mariadforgeflow 61a68c7
[UPD] Update default_multi_user.pot
b506a29
[UPD] README.rst
OCA-git-bot 0b2f8e9
[IMP] default_multi_user: pre-commit stuff
dsolanki-initos d46fd94
[MIG] default_multi_user: Migration to 16.0
dsolanki-initos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
================== | ||
Default Multi User | ||
================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github | ||
:target: https://github.com/OCA/server-ux/tree/16.0/default_multi_user | ||
:alt: OCA/server-ux | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/server-ux-15-0/server-ux-15-0-default_multi_user | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/250/15.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Allows to share user-defined defaults among several users. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
To share a default among several users you need to: | ||
|
||
#. Go to *Settings > Technical > Actions > User-defined Defaults*. | ||
#. Edit a default and fill the field *Available for users* and *Available for | ||
Groups* with the desired users and/or groups. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20default_multi_user%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Lois Rilo <lois.rilo@forgeflow.com> | ||
* Sunanda Chhatbar <sunanda.chhatbar@initos.com> | ||
* Dhara Solanki <dhara.solanki@initos.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px | ||
:target: https://github.com/LoisRForgeFlow | ||
:alt: LoisRForgeFlow | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-LoisRForgeFlow| | ||
|
||
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/16.0/default_multi_user>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from .hooks import post_load_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Default Multi User", | ||
"summary": "Allows to share user-defined defaults among several users.", | ||
"version": "16.0.1.0.0", | ||
"development_status": "Beta", | ||
"maintainers": ["LoisRForgeFlow"], | ||
"category": "Tools", | ||
"website": "https://github.com/OCA/server-ux", | ||
"author": "ForgeFlow, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": ["base"], | ||
"data": ["views/ir_default_view.xml"], | ||
"post_load": "post_load_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import json | ||
|
||
from odoo import api, tools | ||
|
||
from odoo.addons.base.models.ir_default import IrDefault | ||
|
||
|
||
def post_load_hook(): | ||
@api.model | ||
@tools.ormcache("self.env.uid", "model_name", "condition") | ||
def new_get_model_defaults(self, model_name, condition=False): | ||
if not hasattr(self, "_get_model_defaults_query_and_params"): | ||
return self.get_model_defaults_original(model_name, condition=condition) | ||
cr = self.env.cr | ||
# START OF CHANGES | ||
query, params = self._get_model_defaults_query_and_params(model_name, condition) | ||
# END OF CHANGES | ||
cr.execute(query, params) | ||
result = {} | ||
for row in cr.fetchall(): | ||
# keep the highest priority default for each field | ||
if row[0] not in result: | ||
result[row[0]] = json.loads(row[1]) | ||
return result | ||
|
||
if not hasattr(IrDefault, "get_model_defaults_original"): | ||
IrDefault.get_model_defaults_original = IrDefault.get_model_defaults | ||
|
||
IrDefault._patch_method("get_model_defaults", new_get_model_defaults) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * default_multi_user | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__group_ids | ||
msgid "Available for Groups" | ||
msgstr "" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__manual_user_ids | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_tree | ||
msgid "Available for Users" | ||
msgstr "" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model,name:default_multi_user.model_ir_default | ||
msgid "Default Values" | ||
msgstr "" | ||
|
||
#. module: default_multi_user | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_form | ||
msgid "Owner" | ||
msgstr "" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__user_ids | ||
msgid "Users" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * default_multi_user | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2021-03-16 11:46+0000\n" | ||
"Last-Translator: Ana Suárez <ana.suarez@qubiq.es>\n" | ||
"Language-Team: none\n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.3.2\n" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__group_ids | ||
msgid "Available for Groups" | ||
msgstr "Disponible para Grupos" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__manual_user_ids | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_tree | ||
msgid "Available for Users" | ||
msgstr "Disponible para Usuarios" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model,name:default_multi_user.model_ir_default | ||
msgid "Default Values" | ||
msgstr "Valores por defecto" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación el" | ||
|
||
#. module: default_multi_user | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_form | ||
msgid "Owner" | ||
msgstr "Propietario" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__user_ids | ||
msgid "Users" | ||
msgstr "Usuarios" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * default_multi_user | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2021-07-02 22:51+0000\n" | ||
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n" | ||
"Language-Team: none\n" | ||
"Language: pt\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n > 1;\n" | ||
"X-Generator: Weblate 4.3.2\n" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__group_ids | ||
msgid "Available for Groups" | ||
msgstr "Disponível para Grupos" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__manual_user_ids | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_tree | ||
msgid "Available for Users" | ||
msgstr "Disponível para Utilizadores" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model,name:default_multi_user.model_ir_default | ||
msgid "Default Values" | ||
msgstr "Valore Pré-definidos" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__display_name | ||
msgid "Display Name" | ||
msgstr "Nome a Exibir" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última Modificação em" | ||
|
||
#. module: default_multi_user | ||
#: model_terms:ir.ui.view,arch_db:default_multi_user.ir_default_view_form | ||
msgid "Owner" | ||
msgstr "Proprietário" | ||
|
||
#. module: default_multi_user | ||
#: model:ir.model.fields,field_description:default_multi_user.field_ir_default__user_ids | ||
msgid "Users" | ||
msgstr "Utilizadores" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import ir_default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class IrDefaultgard(models.Model): | ||
_inherit = "ir.default" | ||
|
||
user_ids = fields.Many2many( | ||
comodel_name="res.users", | ||
string="Users", | ||
relation="ir_default_res_users_rel", | ||
column1="ir_default_id", | ||
column2="res_users_id", | ||
compute="_compute_user_ids", | ||
store=True, | ||
) | ||
manual_user_ids = fields.Many2many( | ||
comodel_name="res.users", | ||
string="Available for Users", | ||
relation="ir_default_res_users_manual_rel", | ||
) | ||
group_ids = fields.Many2many( | ||
comodel_name="res.groups", | ||
string="Available for Groups", | ||
) | ||
|
||
@api.constrains("manual_user_ids", "group_ids") | ||
def _compute_user_ids(self): | ||
for rec in self: | ||
rec.user_ids = rec.manual_user_ids + rec.group_ids.users | ||
|
||
@api.model | ||
def _get_model_defaults_query_and_params(self, model_name, condition): | ||
query = """ | ||
SELECT f.name, d.json_value FROM ir_default d | ||
JOIN ir_model_fields f ON d.field_id=f.id | ||
JOIN res_users u ON u.id=%s | ||
LEFT JOIN ir_default_res_users_rel m | ||
ON m.ir_default_id = d.id | ||
WHERE f.model=%s | ||
AND ((d.user_id IS NULL AND m.res_users_id IS NULL) | ||
OR d.user_id=u.id OR m.res_users_id = u.id) | ||
AND (d.company_id IS NULL OR d.company_id=%s) | ||
AND {} | ||
ORDER BY d.user_id, m.res_users_id, d.company_id, d.id | ||
""" | ||
params = [self.env.uid, model_name, self.env.company.id or None] | ||
if condition: | ||
query = query.format("d.condition=%s") | ||
params.append(condition) | ||
else: | ||
query = query.format("d.condition IS NULL") | ||
return query, params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
To share a default among several users you need to: | ||
|
||
#. Go to *Settings > Technical > Actions > User-defined Defaults*. | ||
#. Edit a default and fill the field *Available for users* and *Available for | ||
Groups* with the desired users and/or groups. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Lois Rilo <lois.rilo@forgeflow.com> | ||
* Sunanda Chhatbar <sunanda.chhatbar@initos.com> | ||
* Dhara Solanki <dhara.solanki@initos.com> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allows to share user-defined defaults among several users. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As fare as I know are migrations without any code change not enough to put you on the contributor 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.
Please @dsolanki-initos could you review this PR?