diff --git a/dms_field/tests/test_dms_field.py b/dms_field/tests/test_dms_field.py index 6d44efef2..7aa374556 100644 --- a/dms_field/tests/test_dms_field.py +++ b/dms_field/tests/test_dms_field.py @@ -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) diff --git a/hr_dms_field/README.rst b/hr_dms_field/README.rst index edbd6b9ae..06ee5707c 100644 --- a/hr_dms_field/README.rst +++ b/hr_dms_field/README.rst @@ -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| @@ -57,7 +57,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -98,6 +98,6 @@ Current `maintainer `__: |maintainer-victoralmau| -This module is part of the `OCA/dms `_ project on GitHub. +This module is part of the `OCA/dms `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_dms_field/__manifest__.py b/hr_dms_field/__manifest__.py index 621c120ee..f82b0ee60 100644 --- a/hr_dms_field/__manifest__.py +++ b/hr_dms_field/__manifest__.py @@ -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)", diff --git a/hr_dms_field/models/hr_employee.py b/hr_dms_field/models/hr_employee.py index a15a6305b..0e6d9856c 100644 --- a/hr_dms_field/models/hr_employee.py +++ b/hr_dms_field/models/hr_employee.py @@ -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"] diff --git a/hr_dms_field/static/description/index.html b/hr_dms_field/static/description/index.html index a3247778b..05a88bcf9 100644 --- a/hr_dms_field/static/description/index.html +++ b/hr_dms_field/static/description/index.html @@ -368,7 +368,7 @@

Add dms field for employees

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:75c4cb1c0cd65b8bcfa4c07c1a764db17142895a46365763c1fcadae513db0a6 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/dms Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/dms Translate me on Weblate Try me on Runboat

Add the Documents tab with the files in the employee’s form view.

Table of contents

@@ -404,7 +404,7 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -434,7 +434,7 @@

Maintainers

promote its widespread use.

Current maintainer:

victoralmau

-

This module is part of the OCA/dms project on GitHub.

+

This module is part of the OCA/dms project on GitHub.

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

diff --git a/hr_dms_field/static/src/js/base/dms_list_controller.esm.js b/hr_dms_field/static/src/js/base/dms_list_controller.esm.js new file mode 100644 index 000000000..3455c516b --- /dev/null +++ b/hr_dms_field/static/src/js/base/dms_list_controller.esm.js @@ -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); + }, +}); diff --git a/hr_dms_field/static/src/js/base/dms_tree_controller.js b/hr_dms_field/static/src/js/base/dms_tree_controller.js deleted file mode 100644 index 14e884382..000000000 --- a/hr_dms_field/static/src/js/base/dms_tree_controller.js +++ /dev/null @@ -1,15 +0,0 @@ -odoo.define("hr_dms_field.DmsTreeController", function (require) { - "use strict"; - var FormController = require("web.FormController"); - var DmsTreeController = require("dms.DmsTreeController"); - const DmsTreeControllerExtension = { - sanitizeDMSModel: function (model) { - if (model === "hr.employee.public") { - return "hr.employee"; - } - return this._super(...arguments); - }, - }; - FormController.include(DmsTreeControllerExtension); - DmsTreeController.Controller.include(DmsTreeControllerExtension); -}); diff --git a/hr_dms_field/tests/test_hr_dms_field.py b/hr_dms_field/tests/test_hr_dms_field.py index 7cc3cea31..5ea9f393d 100644 --- a/hr_dms_field/tests/test_hr_dms_field.py +++ b/hr_dms_field/tests/test_hr_dms_field.py @@ -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 @@ -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) @@ -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) @@ -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) diff --git a/hr_dms_field/views/hr_employee_view.xml b/hr_dms_field/views/hr_employee_view.xml index c4c6d8546..88521ecf5 100644 --- a/hr_dms_field/views/hr_employee_view.xml +++ b/hr_dms_field/views/hr_employee_view.xml @@ -11,7 +11,7 @@ string="Documents" attrs="{'invisible': [('id', '=', False)]}" > - + @@ -31,7 +31,7 @@ string="Documents" attrs="{'invisible': [('is_logged', '=', False)]}" > - +