Skip to content

Commit

Permalink
[MIG] hr_dms_field: Migration to 16.0
Browse files Browse the repository at this point in the history
TT48870
  • Loading branch information
victoralmau committed Jun 20, 2024
1 parent 04ce49b commit 8b71f8b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 69 deletions.
2 changes: 1 addition & 1 deletion dms_field/tests/test_dms_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_creation_process_01(self):
self.assertEqual(total, 1)
# Create directory again (access groups are the same)
template.create_dms_directory()
self.partner.refresh()
self.partner.invalidate_model()
directory_0 = self.partner.dms_directory_ids[0]
self.assertEqual(directory_0.group_ids, old_groups)

Expand Down
10 changes: 5 additions & 5 deletions hr_dms_field/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Add dms field for employees
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdms-lightgray.png?logo=github
:target: https://github.com/OCA/dms/tree/15.0/hr_dms_field
:target: https://github.com/OCA/dms/tree/16.0/hr_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-hr_dms_field
:target: https://translation.odoo-community.org/projects/dms-16-0/dms-16-0-hr_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 @@ -57,7 +57,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:%20hr_dms_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:%20hr_dms_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 @@ -98,6 +98,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion hr_dms_field/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Add dms field for employees",
"version": "15.0.1.2.0",
"version": "16.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/dms",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
30 changes: 3 additions & 27 deletions hr_dms_field/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,6 @@
from odoo import models


class HrEmployee(models.Model):
_inherit = "hr.employee"

def write(self, vals):
"""When modifying a record that has linked directories and changing the
user_id field it is necessary to update the auto-generated access group
(name and explicit_user_ids).
"""
res = super().write(vals)
for item in self.filtered("dms_directory_ids"):
if "user_id":
template = self.env["dms.field.template"]._get_template_from_model(
item._name
)
if template:
template._get_autogenerated_group(item)
return res

def unlink(self):
"""When deleting a record, we also delete the linked directories and the
auto-generated access group.
"""
for record in self.filtered("dms_directory_ids"):
group = self.env["dms.access.group"]._get_item_from_dms_field_ref(record)
record.sudo().dms_directory_ids.unlink()
group.sudo().unlink()
return super().unlink()
class HrEmployeeBase(models.AbstractModel):
_name = "hr.employee.base"
_inherit = ["hr.employee.base", "dms.field.mixin"]
6 changes: 3 additions & 3 deletions hr_dms_field/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ <h1 class="title">Add dms field for employees</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:75c4cb1c0cd65b8bcfa4c07c1a764db17142895a46365763c1fcadae513db0a6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/15.0/hr_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-hr_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/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/dms/tree/16.0/hr_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-hr_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>Add the Documents tab with the files in the employee’s form view.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -404,7 +404,7 @@ <h1><a class="toc-backref" href="#toc-entry-3">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:%20hr_dms_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:%20hr_dms_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 Down Expand Up @@ -434,7 +434,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/dms/tree/15.0/hr_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/hr_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
13 changes: 13 additions & 0 deletions hr_dms_field/static/src/js/base/dms_list_controller.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @odoo-module **/

import {DMSListControllerObject} from "@dms_field/views/dms_list/dms_list_controller.esm";
import {patch} from "@web/core/utils/patch";

patch(DMSListControllerObject, "hr_dms_field.DMSListControllerObject", {
sanitizeDMSModel: function (model) {
if (model === "hr.employee.public") {
return "hr.employee";
}
return this._super(...arguments);
},
});
15 changes: 0 additions & 15 deletions hr_dms_field/static/src/js/base/dms_tree_controller.js

This file was deleted.

22 changes: 7 additions & 15 deletions hr_dms_field/tests/test_hr_dms_field.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo.tests import common, new_test_user
from odoo.tests import new_test_user
from odoo.tools import mute_logger

from odoo.addons.base.tests.common import BaseCommon

class TestHrDmsField(common.TransactionCase):

class TestHrDmsField(BaseCommon):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(
context=dict(
cls.env.context,
mail_create_nolog=True,
mail_create_nosubscribe=True,
mail_notrack=True,
no_reset_password=True,
tracking_disable=True,
)
)
cls.template = cls.env.ref("hr_dms_field.field_template_employee")
cls.storage = cls.template.storage_id
cls.access_group = cls.template.group_ids
Expand All @@ -45,7 +37,7 @@ def test_employee_exists(self):

def test_employee_create_01(self):
employee = self.employee_model.create({"name": "Test employee"})
employee.refresh()
employee.invalidate_model()
directory = employee.dms_directory_ids
self.assertEqual(len(directory), 1)
self.assertEqual(directory.storage_id, self.storage)
Expand All @@ -63,7 +55,7 @@ def test_employee_create_02(self):
"user_id": self.user.id,
}
)
employee.refresh()
employee.invalidate_model()
group_custom = employee.dms_directory_ids.group_ids.filtered("dms_field_ref")
self.assertIn(self.user, group_custom.explicit_user_ids)

Expand All @@ -75,7 +67,7 @@ def test_employee_full_process(self):
"user_id": self.user.id,
}
)
employee.refresh()
employee.invalidate_model()
directory_0 = employee.dms_directory_ids[0]
group_custom = directory_0.group_ids.filtered("dms_field_ref")
self.assertIn(self.user, group_custom.explicit_user_ids)
Expand Down
4 changes: 2 additions & 2 deletions hr_dms_field/views/hr_employee_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
string="Documents"
attrs="{'invisible': [('id', '=', False)]}"
>
<field name="dms_directory_ids" mode="dms_tree" />
<field name="dms_directory_ids" mode="dms_list" />
</page>
</notebook>
</field>
Expand All @@ -31,7 +31,7 @@
string="Documents"
attrs="{'invisible': [('is_logged', '=', False)]}"
>
<field name="dms_directory_ids" mode="dms_tree" />
<field name="dms_directory_ids" mode="dms_list" />
</page>
</notebook>
</field>
Expand Down

0 comments on commit 8b71f8b

Please sign in to comment.