Skip to content

Commit 7e7a843

Browse files
zingbizzteamdnplkndll
authored andcommitted
[19.0][MIG] dms: Migration to 19.0
1 parent 70c6ff4 commit 7e7a843

30 files changed

Lines changed: 289 additions & 180 deletions

dms/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Document Management System
2121
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
2222
:alt: License: LGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
24-
:target: https://github.com/OCA/dms/tree/18.0/dms
24+
:target: https://github.com/OCA/dms/tree/19.0/dms
2525
:alt: OCA/dms
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/dms-18-0/dms-18-0-dms
27+
:target: https://translation.odoo-community.org/projects/dms-19-0/dms-19-0-dms
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -184,7 +184,7 @@ Bug Tracker
184184
Bugs are tracked on `GitHub Issues <https://github.com/OCA/dms/issues>`_.
185185
In case of trouble, please check there if your issue has already been reported.
186186
If you spotted it first, help us to smash it by providing a detailed and welcomed
187-
`feedback <https://github.com/OCA/dms/issues/new?body=module:%20dms%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
187+
`feedback <https://github.com/OCA/dms/issues/new?body=module:%20dms%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
188188

189189
Do not contact contributors directly about support or help with technical issues.
190190

@@ -248,6 +248,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
248248
mission is to support the collaborative development of Odoo features and
249249
promote its widespread use.
250250

251-
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/18.0/dms>`_ project on GitHub.
251+
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/19.0/dms>`_ project on GitHub.
252252

253253
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

dms/__manifest__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Document Management System",
77
"summary": """Document Management System for Odoo""",
8-
"version": "18.0.1.0.8",
8+
"version": "19.0.1.0.0",
99
"category": "Document Management",
1010
"license": "LGPL-3",
1111
"website": "https://github.com/OCA/dms",
@@ -37,6 +37,7 @@
3737
"views/dms_access_groups_views.xml",
3838
"views/res_config_settings.xml",
3939
"views/menu.xml",
40+
"views/res_users.xml",
4041
# Wizard
4142
"wizards/wizard_dms_file_move_views.xml",
4243
"wizards/wizard_dms_share_views.xml",

dms/controllers/portal.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import base64
55
from typing import Optional # noqa # pylint: disable=unused-import
66

7-
from odoo import _, http
7+
from odoo import http
88
from odoo.http import content_disposition, request
99
from odoo.osv.expression import OR
1010

@@ -235,14 +235,16 @@ def _searchbar_data(self, filterby, sortby):
235235
sortby
236236
:rtype: tuple[str, dict, dict, str, str]
237237
"""
238-
searchbar_sortings = {"name": {"label": _("Name"), "order": "name asc"}}
238+
searchbar_sortings = {
239+
"name": {"label": self.env._("Name"), "order": "name asc"}
240+
}
239241
# default sortby
240242
if not sortby:
241243
sortby = "name"
242244
sort_order = searchbar_sortings[sortby]["order"]
243245
# search
244246
searchbar_inputs = {
245-
"name": {"input": "name", "label": _("Name")},
247+
"name": {"input": "name", "label": self.env._("Name")},
246248
}
247249
if not filterby:
248250
filterby = "name"

dms/data/onboarding_data.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,14 @@
5959
<field name="sequence">3</field>
6060
</record>
6161

62-
<!-- File Onboarding Panel -->
6362
<record id="onboarding_onboarding_dms_file" model="onboarding.onboarding">
6463
<field name="name">File Onboarding</field>
6564
<field
6665
name="step_ids"
6766
eval="[
68-
Command.link(ref('dms.onboarding_step_document_storage')),
69-
Command.link(ref('dms.onboarding_step_create_directory')),
70-
Command.link(ref('dms.onboarding_step_upload_file'))
67+
(4, ref('dms.onboarding_step_document_storage')),
68+
(4, ref('dms.onboarding_step_create_directory')),
69+
(4, ref('dms.onboarding_step_upload_file'))
7170
]"
7271
/>
7372
<field name="route_name">document_onboarding_file</field>

dms/demo/res_users.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<odoo noupdate="1">
99
<record id="base.user_demo" model="res.users">
10-
<field eval="[(4, ref('dms.group_dms_user'))]" name="groups_id" />
10+
<field eval="[(4, ref('dms.group_dms_user'))]" name="group_ids" />
1111
</record>
1212
</odoo>

dms/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
from . import ir_attachment
2222
from . import ir_binary
2323
from . import mail_thread
24+
from . import res_users

dms/models/access_groups.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2024 Timothée Vannier - Subteno (https://www.subteno.com).
44
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
55

6-
from odoo import _, api, fields, models
6+
from odoo import api, fields, models
77
from odoo.exceptions import ValidationError
88

99

@@ -47,7 +47,7 @@ class DmsAccessGroups(models.Model):
4747
string="Directories",
4848
column1="gid",
4949
column2="aid",
50-
auto_join=True,
50+
bypass_search_access=True,
5151
readonly=True,
5252
)
5353
complete_directory_ids = fields.Many2many(
@@ -56,7 +56,7 @@ class DmsAccessGroups(models.Model):
5656
column1="gid",
5757
column2="aid",
5858
string="Complete directories",
59-
auto_join=True,
59+
bypass_search_access=True,
6060
readonly=True,
6161
)
6262
count_users = fields.Integer(compute="_compute_users", store=True)
@@ -94,7 +94,7 @@ class DmsAccessGroups(models.Model):
9494
column2="uid",
9595
string="Group Users",
9696
compute="_compute_users",
97-
auto_join=True,
97+
bypass_search_access=True,
9898
store=True,
9999
recursive=True,
100100
)
@@ -104,9 +104,10 @@ def _compute_count_directories(self):
104104
for record in self:
105105
record.count_directories = len(record.directory_ids)
106106

107-
_sql_constraints = [
108-
("name_uniq", "unique (name)", "The name of the group must be unique!")
109-
]
107+
_name_uniq = models.Constraint(
108+
"unique (name)",
109+
"The name of the group must be unique!",
110+
)
110111

111112
@api.depends(
112113
"parent_group_id.perm_inclusive_create",
@@ -143,13 +144,13 @@ def default_get(self, fields_list):
143144
"parent_group_id",
144145
"parent_group_id.users",
145146
"group_ids",
146-
"group_ids.users",
147+
"group_ids.user_ids",
147148
"explicit_user_ids",
148149
)
149150
def _compute_users(self):
150151
for record in self:
151152
users = (
152-
record.group_ids.users
153+
record.group_ids.user_ids
153154
| record.explicit_user_ids
154155
| record.parent_group_id.users
155156
)
@@ -158,7 +159,7 @@ def _compute_users(self):
158159
def copy_data(self, default=None):
159160
vals_list = super().copy_data(default)
160161
for group, vals in zip(self, vals_list, strict=False):
161-
vals["name"] = _("%s (copy)") % group.name
162+
vals["name"] = self.env._("%s (copy)", group.name)
162163
return vals_list
163164

164165
@api.constrains("parent_path")
@@ -169,9 +170,9 @@ def _check_parent_recursiveness(self):
169170
for one in self.filtered("parent_group_id"):
170171
if str(one.id) in one.parent_path.split("/"):
171172
raise ValidationError(
172-
_("Parent group '%(parent)s' is child of '%(current)s'.")
173-
% {
174-
"parent": one.parent_group_id.display_name,
175-
"current": one.display_name,
176-
}
173+
self.env._(
174+
"Parent group '%(parent)s' is child of '%(current)s'.",
175+
parent=one.parent_group_id.display_name,
176+
current=one.display_name,
177+
)
177178
)

dms/models/directory.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from collections import defaultdict
1313
from typing import Literal # noqa # pylint: disable=unused-import
1414

15-
from odoo import _, api, fields, models, tools
15+
from odoo import api, fields, models, tools
1616
from odoo.exceptions import UserError, ValidationError
1717
from odoo.osv.expression import AND, OR
1818
from odoo.tools import consteq, human_size
@@ -60,7 +60,7 @@ class DmsDirectory(models.Model):
6060
comodel_name="dms.storage",
6161
string="Storage",
6262
ondelete="restrict",
63-
auto_join=True,
63+
bypass_search_access=True,
6464
store=True,
6565
)
6666
parent_id = fields.Many2one(
@@ -116,7 +116,7 @@ def _default_parent_id(self):
116116
comodel_name="dms.directory",
117117
inverse_name="parent_id",
118118
string="Subdirectories",
119-
auto_join=False,
119+
bypass_search_access=False,
120120
copy=True,
121121
)
122122

@@ -153,7 +153,7 @@ def _default_parent_id(self):
153153
comodel_name="dms.file",
154154
inverse_name="directory_id",
155155
string="Files",
156-
auto_join=False,
156+
bypass_search_access=False,
157157
copy=True,
158158
)
159159

@@ -412,14 +412,16 @@ def _compute_count_directories(self):
412412
for record in self:
413413
directories = len(record.child_directory_ids)
414414
record.count_directories = directories
415-
record.count_directories_title = _("%s Subdirectories") % directories
415+
record.count_directories_title = self.env._(
416+
"%s Subdirectories", directories
417+
)
416418

417419
@api.depends("file_ids")
418420
def _compute_count_files(self):
419421
for record in self:
420422
files = len(record.file_ids)
421423
record.count_files = files
422-
record.count_files_title = _("%s Files") % files
424+
record.count_files_title = self.env._("%s Files", files)
423425

424426
@api.depends("child_directory_ids", "file_ids")
425427
def _compute_count_elements(self):
@@ -528,7 +530,9 @@ def _onchange_model_id(self):
528530
@api.constrains("parent_id")
529531
def _check_directory_recursion(self):
530532
if self._has_cycle():
531-
raise ValidationError(_("Error! You cannot create recursive directories."))
533+
raise ValidationError(
534+
self.env._("Error! You cannot create recursive directories.")
535+
)
532536
return True
533537

534538
@api.constrains("storage_id", "model_id")
@@ -538,34 +542,40 @@ def _check_storage_id_attachment_model_id(self):
538542
):
539543
if not record.model_id:
540544
raise ValidationError(
541-
_("A directory has to have model in attachment storage.")
545+
self.env._("A directory has to have model in attachment storage.")
542546
)
543547
if not record.is_root_directory and not record.res_id:
544548
raise ValidationError(
545-
_("This directory needs to be associated to a record.")
549+
self.env._("This directory needs to be associated to a record.")
546550
)
547551

548552
@api.constrains("is_root_directory", "storage_id")
549553
def _check_directory_storage(self):
550554
for record in self:
551555
if record.is_root_directory and not record.storage_id:
552-
raise ValidationError(_("A root directory has to have a storage."))
556+
raise ValidationError(
557+
self.env._("A root directory has to have a storage.")
558+
)
553559

554560
@api.constrains("is_root_directory", "parent_id")
555561
def _check_directory_parent(self):
556562
for record in self:
557563
if record.is_root_directory and record.parent_id:
558564
raise ValidationError(
559-
_("A directory can't be a root and have a parent directory.")
565+
self.env._(
566+
"A directory can't be a root and have a parent directory."
567+
)
560568
)
561569
if not record.is_root_directory and not record.parent_id:
562-
raise ValidationError(_("A directory has to have a parent directory."))
570+
raise ValidationError(
571+
self.env._("A directory has to have a parent directory.")
572+
)
563573

564574
@api.constrains("name")
565575
def _check_name(self):
566576
for record in self:
567577
if self.env.context.get("check_name", True) and not check_name(record.name):
568-
raise ValidationError(_("The directory name is invalid."))
578+
raise ValidationError(self.env._("The directory name is invalid."))
569579
if record.is_root_directory:
570580
children = record.sudo().storage_id.root_directory_ids
571581
else:
@@ -576,7 +586,7 @@ def _check_name(self):
576586
and child != record
577587
):
578588
raise ValidationError(
579-
_("A directory with the same name already exists.")
589+
self.env._("A directory with the same name already exists.")
580590
)
581591

582592
# Create, Update, Delete
@@ -626,7 +636,7 @@ def message_new(self, msg_dict, custom_values=None):
626636
return parent_directory
627637
names = parent_directory.child_directory_ids.mapped("name")
628638
slug = self.env["ir.http"]._slug
629-
subject = slug(msg_dict.get("subject", _("Alias-Mail-Extraction")))
639+
subject = slug(msg_dict.get("subject", self.env._("Alias-Mail-Extraction")))
630640
defaults = dict(
631641
{"name": unique_name(subject, names, escape_suffix=True)}, **custom_values
632642
)
@@ -678,13 +688,15 @@ def write(self, vals):
678688
if new_parent_id:
679689
if old_storage_id != self.browse(new_parent_id).storage_id.id:
680690
raise UserError(
681-
_(
691+
self.env._(
682692
"It is not possible to change to a parent "
683693
"with other storage."
684694
)
685695
)
686696
elif old_storage_id != new_storage_id:
687-
raise UserError(_("It is not possible to change the storage."))
697+
raise UserError(
698+
self.env._("It is not possible to change the storage.")
699+
)
688700
# Groups part
689701
if any(key in vals for key in ["group_ids", "inherit_group_ids"]):
690702
res = super().write(vals)

dms/models/dms_category.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import logging
77

8-
from odoo import _, api, fields, models
8+
from odoo import api, fields, models
99
from odoo.exceptions import ValidationError
1010

1111
_logger = logging.getLogger(__name__)
@@ -63,9 +63,10 @@ class DMSCategory(models.Model):
6363
count_directories = fields.Integer(compute="_compute_count_directories")
6464
count_files = fields.Integer(compute="_compute_count_files")
6565

66-
_sql_constraints = [
67-
("name_uniq", "unique (name)", "Category name already exists!"),
68-
]
66+
_name_uniq = models.Constraint(
67+
"unique (name)",
68+
"Category name already exists!",
69+
)
6970

7071
@api.depends("name", "parent_id.complete_name")
7172
def _compute_complete_name(self):
@@ -100,5 +101,7 @@ def _compute_count_files(self):
100101
@api.constrains("parent_id")
101102
def _check_category_recursion(self):
102103
if self._has_cycle():
103-
raise ValidationError(_("Error! You cannot create recursive categories."))
104+
raise ValidationError(
105+
self.env._("Error! You cannot create recursive categories.")
106+
)
104107
return True

0 commit comments

Comments
 (0)