Skip to content

Commit

Permalink
Merge PR #297 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Feb 27, 2024
2 parents 4bff400 + 77c3f17 commit a6ea855
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
5 changes: 3 additions & 2 deletions dms_auto_classification/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_dms_classification_template_user,dms_classification_template_user,model_dms_classification_template,dms.group_dms_user,1,0,0,0
access_dms_classification_template_manager,dms_classification_template_manager,model_dms_classification_template,dms.group_dms_manager,1,1,1,1
access_wizard_dms_classification_manager,wizard_dms_classification_manager,model_wizard_dms_classification,dms.group_dms_manager,1,1,1,1
access_wizard_dms_classification_detail_manager,wizard_dms_classification_detail_manager,model_wizard_dms_classification_detail,dms.group_dms_manager,1,1,1,1
access_wizard_dms_classification_manager,wizard_dms_classification_manager,model_wizard_dms_classification,dms.group_dms_user,1,1,1,1
access_wizard_dms_classification_detail_manager,wizard_dms_classification_detail_manager,model_wizard_dms_classification_detail,dms.group_dms_user,1,1,1,1
30 changes: 29 additions & 1 deletion dms_auto_classification/tests/test_dms_auto_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,42 @@
from base64 import b64encode
from os import path

from odoo.tests import Form, common
from odoo.tests import Form, common, new_test_user
from odoo.tests.common import users


class TestDmsAutoClassification(common.TransactionCase):
@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(
"dms_auto_classification.dms_classification_template_documents"
)
cls.directory = cls.env.ref("dms.directory_01_demo")
cls.wizard = cls._create_wizard_dms_classification(cls, cls.template)
cls.extra_wizard = cls._create_wizard_dms_classification(cls, cls.template)
cls.user = new_test_user(
cls.env, login="test_dms_user", groups="dms.group_dms_user"
)
access_group = cls.env["dms.access.group"].create(
{
"name": "Test access group",
"perm_create": True,
"perm_write": True,
"explicit_user_ids": [(4, cls.user.id)],
}
)
cls.directory.group_ids = [(4, access_group.id)]

def _data_file(self, filename, encoding=None):
mode = "rt" if encoding else "rb"
Expand All @@ -32,7 +55,9 @@ def _create_wizard_dms_classification(self, template):
wizard_form.data_file = self._data_file(self, "data/test.zip")
return wizard_form.save()

@users("test_dms_user")
def test_wizard_dms_clasification_process(self):
self.wizard = self.wizard.with_user(self.env.user)
self.assertEqual(self.wizard.state, "draft")
# Wizard - Analyze process
self.wizard.action_analyze()
Expand Down Expand Up @@ -65,6 +90,7 @@ def test_wizard_dms_clasification_process(self):
# Extra wizard
self.assertEqual(self.extra_wizard.state, "draft")
# New Wizard - Analyze process
self.extra_wizard = self.extra_wizard.with_user(self.env.user)
self.extra_wizard.action_analyze()
self.assertEqual(self.extra_wizard.state, "analyze")
self.assertEqual(len(self.extra_wizard.detail_ids), 2)
Expand Down Expand Up @@ -96,10 +122,12 @@ def test_wizard_dms_clasification_process_filename_pattern(self):
self.assertEqual(self.wizard.state, "analyze")
self.assertEqual(len(self.wizard.detail_ids), 0)

@users("test_dms_user")
def test_wizard_dms_clasification_process_directory_pattern(self):
self.template.directory_pattern = "Documents2"
self.assertEqual(self.wizard.state, "draft")
# Analyze process
self.wizard = self.wizard.with_user(self.env.user)
self.wizard.action_analyze()
self.assertEqual(self.wizard.state, "analyze")
self.assertEqual(len(self.wizard.detail_ids), 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
<field name="name">Classification Templates</field>
<field name="res_model">dms.classification.template</field>
<field name="view_mode">tree,form</field>
<field name="groups_id" eval="[(4, ref('dms.group_dms_manager'))]" />
</record>
<menuitem
id="menu_dms_classification_template"
name="Classification Templates"
parent="dms.cat_menu_dms_config_organizing"
sequence="6"
action="action_dms_classification_template"
groups="dms.group_dms_manager"
/>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@
<field name="res_model">wizard.dms.classification</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="groups_id" eval="[(4, ref('dms.group_dms_user'))]" />
</record>
<menuitem
id="menu_wizard_dms_classification"
name="Auto Classification"
parent="dms.main_menu_dms"
sequence="40"
action="action_wizard_dms_classification"
groups="dms.group_dms_user"
/>
</odoo>

0 comments on commit a6ea855

Please sign in to comment.