Skip to content

Commit

Permalink
[MIG] dms_field: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoca13 committed Jun 10, 2024
1 parent 5a7fe35 commit a6ca55c
Show file tree
Hide file tree
Showing 42 changed files with 2,267 additions and 2,520 deletions.
12 changes: 6 additions & 6 deletions dms_field/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DMS Field
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:923426d186000e2da1d7e32f4ba6b770234a94e4f930f56fdbece369f3729153
!! source digest: sha256:ed7854681f73bbc617938529c1da77fcf81cba2bf46a8ae9387d8f20b360a53b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ DMS Field
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
:target: https://github.com/OCA/dms/tree/15.0/dms_field
:target: https://github.com/OCA/dms/tree/16.0/dms_field
:alt: OCA/dms
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/dms-15-0/dms-15-0-dms_field
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms_field
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/dms&target_branch=16.0
:alt: Try me on Runboat

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

Expand Down Expand Up @@ -101,6 +101,6 @@ 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.

This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/15.0/dms_field>`_ project on GitHub.
This module is part of the `OCA/dms <https://github.com/OCA/dms/tree/16.0/dms_field>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
13 changes: 8 additions & 5 deletions dms_field/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "DMS Field",
"summary": """
Create DMS View and allow to use them inside a record""",
"version": "15.0.1.2.1",
"version": "16.0.1.0.0",
"license": "LGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/dms",
Expand All @@ -19,11 +19,14 @@
],
"assets": {
"web.assets_backend": [
"dms_field/static/src/js/**/*",
"dms_field/static/src/scss/**/*",
"dms_field/static/src/**/*",
("remove", "dms_field/static/src/views/fields/x2many/x2many_field.xml"),
(
"after",
"/web/static/src/views/fields/x2many/x2many_field.xml",
"dms_field/static/src/views/fields/x2many/x2many_field.xml",
),
],
"web.assets_qweb": ["dms_field/static/src/xml/**/*"],
},
"qweb": ["static/src/xml/*.xml"],
"demo": ["demo/partner_dms.xml"],
}
2 changes: 1 addition & 1 deletion dms_field/demo/partner_dms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
string="DMS"
attrs="{'invisible': [('id', '=', False)]}"
>
<field name="dms_directory_ids" mode="dms_tree" />
<field name="dms_directory_ids" mode="dms_list" />
</page>
</notebook>
</field>
Expand Down
323 changes: 104 additions & 219 deletions dms_field/i18n/dms_field.pot

Large diffs are not rendered by default.

452 changes: 216 additions & 236 deletions dms_field/i18n/es.po

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dms_field/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from . import dms_field_mixin
from . import ir_actions_act_window_view
from . import ir_ui_view
from . import dms_storage
from . import dms_directory
from . import dms_field_template
from . import base
from . import res_partner
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from odoo import api, fields, models


class Base(models.AbstractModel):
_inherit = "base"
class DMSFieldMixin(models.AbstractModel):
_name = "dms.field.mixin"
_description = "Mixin to use DMS Field"

dms_directory_ids = fields.One2many(
"dms.directory",
Expand Down
26 changes: 19 additions & 7 deletions dms_field/models/dms_field_template.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError, ValidationError


class DmsFieldTemplate(models.Model):
_name = "dms.field.template"
_inherit = "dms.field.mixin"
_description = "Dms Field Template"

name = fields.Char(required=True)
Expand Down Expand Up @@ -72,7 +73,7 @@ def create_dms_directory(self):
"group_ids": record.group_ids.ids,
}
)
template = self._get_template_from_model(res_model)
template = self._get_template_from_model(res_model).sudo()
if not template:
raise ValidationError(_("There is no template linked to this model"))

Check warning on line 78 in dms_field/models/dms_field_template.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/dms_field_template.py#L78

Added line #L78 was not covered by tests
total_directories = directory_model.search_count(
Expand All @@ -86,13 +87,13 @@ def create_dms_directory(self):
raise ValidationError(_("There is already a linked directory created."))
# Create root directory + files
dms_directory_ids = template.dms_directory_ids
directory = directory_model.create(
new_directory = directory_model.create(
template._prepare_directory_vals(dms_directory_ids, record)
)
self._copy_files_from_directory(dms_directory_ids, directory)
self._copy_files_from_directory(dms_directory_ids, new_directory)
# Create child directories
self._create_child_directories(directory, dms_directory_ids)
return directory
self._create_child_directories(new_directory, dms_directory_ids)
return new_directory

def _copy_files_from_directory(self, directory, new_directory):
for file in directory.file_ids:
Expand All @@ -101,9 +102,10 @@ def _copy_files_from_directory(self, directory, new_directory):
def _set_groups_from_directory(self, directory, record):
groups = self.env["dms.access.group"]
for group in directory.group_ids:
group_name = _("Autogenerate group from %(model)s (%(name)s)") % {
group_name = _("Autogenerate group from %(model)s (%(name)s) #%(id)s") % {
"model": record._description,
"name": record.display_name,
"id": record.id,
}
new_group = group.copy({"name": group_name, "directory_ids": False})
# Apply sudo() because the user may not have permissions to access
Expand Down Expand Up @@ -146,3 +148,13 @@ def _prepare_directory_vals(self, directory, record):
"name": directory_name,
"group_ids": [(4, group.id) for group in groups],
}

@api.constrains("model_id")
def _check_model_id(self):
for template in self:
if self.env["dms.field.template"].search(
[("model_id", "=", template.model_id.id), ("id", "!=", template.id)]
):
raise UserError(

Check warning on line 158 in dms_field/models/dms_field_template.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/dms_field_template.py#L158

Added line #L158 was not covered by tests
_("There is already a template created for this model.")
)
2 changes: 1 addition & 1 deletion dms_field/models/ir_actions_act_window_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class IrActionsActWindowView(models.Model):
_inherit = "ir.actions.act_window.view"

view_mode = fields.Selection(
selection_add=[("dms_tree", "DMS Tree")], ondelete={"dms_tree": "cascade"}
selection_add=[("dms_list", "DMS Tree")], ondelete={"dms_list": "cascade"}
)
31 changes: 29 additions & 2 deletions dms_field/models/ir_ui_view.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
# Copyright 2020 Creu Blanca
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models
from odoo import _, fields, models

from odoo.addons.base.models.ir_ui_view import NameManager


class IrUiView(models.Model):

_inherit = "ir.ui.view"

type = fields.Selection(selection_add=[("dms_tree", "DMS Tree")])
type = fields.Selection(selection_add=[("dms_list", "DMS Tree")])

def _postprocess_tag_dms_list(self, node, name_manager, node_info):
parent = node.getparent()

Check warning on line 16 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L16

Added line #L16 was not covered by tests
if parent_name := parent and parent.get("name"):
field = name_manager.model._fields.get(parent_name)

Check warning on line 18 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L18

Added line #L18 was not covered by tests
if field:
model_name = field.comodel_name

Check warning on line 20 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L20

Added line #L20 was not covered by tests
if model_name not in self.env:
self._raise_view_error(

Check warning on line 22 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L22

Added line #L22 was not covered by tests
_("Model not found: %(model)s", model=model_name), node
)
model = self.env[model_name]
new_name_manager = NameManager(model, parent=name_manager)
root_info = {

Check warning on line 27 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L25-L27

Added lines #L25 - L27 were not covered by tests
"view_type": node.tag,
"view_editable": self._editable_node(node, name_manager),
"view_modifiers_from_model": self._modifiers_from_model(node),
}
new_node_info = dict(

Check warning on line 32 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L32

Added line #L32 was not covered by tests
root_info,
modifiers={},
editable=self._editable_node(node, new_name_manager),
)
for child in node:
self._postprocess_tag_field(child, new_name_manager, new_node_info)

Check warning on line 38 in dms_field/models/ir_ui_view.py

View check run for this annotation

Codecov / codecov/patch

dms_field/models/ir_ui_view.py#L38

Added line #L38 was not covered by tests
9 changes: 9 additions & 0 deletions dms_field/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 Tecnativa - Carlos Roca
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import models


class ResPartner(models.Model):
_name = "res.partner"
_inherit = ["res.partner", "dms.field.mixin"]
20 changes: 12 additions & 8 deletions dms_field/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -8,10 +9,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +276,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +302,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -366,9 +368,9 @@ <h1 class="title">DMS Field</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:923426d186000e2da1d7e32f4ba6b770234a94e4f930f56fdbece369f3729153
!! source digest: sha256:ed7854681f73bbc617938529c1da77fcf81cba2bf46a8ae9387d8f20b360a53b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/15.0/dms_field"><img alt="OCA/dms" src="https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/dms-15-0/dms-15-0-dms_field"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/dms&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/16.0/dms_field"><img alt="OCA/dms" src="https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-dms_field"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/dms&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon creates a new kind of view and allows to define a folder
related to a record.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -414,7 +416,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/dms/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/dms/issues/new?body=module:%20dms_field%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/dms/issues/new?body=module:%20dms_field%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -440,11 +442,13 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/dms/tree/15.0/dms_field">OCA/dms</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/dms/tree/16.0/dms_field">OCA/dms</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Loading

0 comments on commit a6ca55c

Please sign in to comment.