diff --git a/partner_contact_department/__manifest__.py b/partner_contact_department/__manifest__.py index b0fa03cec..206e931da 100644 --- a/partner_contact_department/__manifest__.py +++ b/partner_contact_department/__manifest__.py @@ -4,22 +4,19 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': 'Partner Contact Department', + "name": "Partner Contact Department", "summary": "Assign contacts to departments", - 'version': '12.0.1.0.0', - 'category': 'Customer Relationship Management', - 'author': 'Tecnativa, ' - 'Odoo Community Association (OCA)', + "version": "13.0.1.0.0", + "category": "Customer Relationship Management", + "author": "Tecnativa, " "Odoo Community Association (OCA)", "license": "AGPL-3", - 'website': 'https://github.com/OCA/partner-contact', + "website": "https://github.com/OCA/partner-contact", "application": False, - 'depends': [ - 'contacts', - ], - 'data': [ - 'security/ir.model.access.csv', - 'views/res_partner_department_view.xml', - 'views/res_partner_view.xml', + "depends": ["contacts"], + "data": [ + "security/ir.model.access.csv", + "views/res_partner_department_view.xml", + "views/res_partner_view.xml", ], "installable": True, } diff --git a/partner_contact_department/migrations/12.0.1.0.0/post-migration.py b/partner_contact_department/migrations/12.0.1.0.0/post-migration.py deleted file mode 100644 index c16403627..000000000 --- a/partner_contact_department/migrations/12.0.1.0.0/post-migration.py +++ /dev/null @@ -1,8 +0,0 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openupgradelib import openupgrade - - -@openupgrade.migrate(use_env=True) -def migrate(env, version): - env['res.partner.department']._parent_store_compute() diff --git a/partner_contact_department/models/res_partner.py b/partner_contact_department/models/res_partner.py index 84423d360..fa0b264fc 100644 --- a/partner_contact_department/models/res_partner.py +++ b/partner_contact_department/models/res_partner.py @@ -2,45 +2,35 @@ # © 2016 Tecnativa S.L. - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, fields, models, _ +from odoo import _, api, fields, models from odoo.exceptions import ValidationError class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" department_id = fields.Many2one( - "res.partner.department", - "Department", - oldname="department" + "res.partner.department", "Department", oldname="department" ) class ResPartnerDepartment(models.Model): - _name = 'res.partner.department' + _name = "res.partner.department" _order = "parent_path" _parent_order = "name" _parent_store = True _description = "Department" - name = fields.Char( - required=True, - translate=True - ) + name = fields.Char(required=True, translate=True) parent_id = fields.Many2one( - "res.partner.department", - "Parent department", - ondelete='restrict' + "res.partner.department", "Parent department", ondelete="restrict" ) child_ids = fields.One2many( - "res.partner.department", - "parent_id", - "Child departments" + "res.partner.department", "parent_id", "Child departments" ) parent_path = fields.Char(index=True) - @api.constrains('parent_id') + @api.constrains("parent_id") def _check_parent_id(self): if not self._check_recursion(): - raise ValidationError( - _('Error! You cannot create recursive departments.')) + raise ValidationError(_("Error! You cannot create recursive departments.")) diff --git a/partner_contact_department/readme/CONTRIBUTORS.rst b/partner_contact_department/readme/CONTRIBUTORS.rst index 2e8045a46..720837fec 100644 --- a/partner_contact_department/readme/CONTRIBUTORS.rst +++ b/partner_contact_department/readme/CONTRIBUTORS.rst @@ -5,3 +5,4 @@ * Vicent Cubells * David Vidal * Nikul Chaudhary +* Harald Panten diff --git a/partner_contact_department/tests/test_recursion.py b/partner_contact_department/tests/test_recursion.py index bcda4aadb..925152cf0 100644 --- a/partner_contact_department/tests/test_recursion.py +++ b/partner_contact_department/tests/test_recursion.py @@ -1,29 +1,26 @@ # © 2016 Tecnativa - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). +from odoo.exceptions import UserError from odoo.tests import common -from odoo.exceptions import ValidationError class TestRecursion(common.SavepointCase): - @classmethod def setUpClass(cls): super(TestRecursion, cls).setUpClass() - cls.department_obj = cls.env['res.partner.department'] + cls.department_obj = cls.env["res.partner.department"] # Instances - cls.dpt1 = cls.department_obj.create({'name': 'Dpt. 1'}) - cls.dpt2 = cls.department_obj.create({ - 'name': 'Dep. 2', - 'parent_id': cls.dpt1.id - }) + cls.dpt1 = cls.department_obj.create({"name": "Dpt. 1"}) + cls.dpt2 = cls.department_obj.create( + {"name": "Dep. 2", "parent_id": cls.dpt1.id} + ) def test_recursion(self): """ Testing recursion """ - self.dpt3 = self.department_obj.create({ - 'name': 'Dep. 3', - 'parent_id': self.dpt2.id - }) + self.dpt3 = self.department_obj.create( + {"name": "Dep. 3", "parent_id": self.dpt2.id} + ) # Creating a parent's child department using dpt1. - with self.assertRaises(ValidationError): - self.dpt1.write(vals={'parent_id': self.dpt3.id}) + with self.assertRaises(UserError): + self.dpt1.write(vals={"parent_id": self.dpt3.id}) diff --git a/partner_contact_department/views/res_partner_department_view.xml b/partner_contact_department/views/res_partner_department_view.xml index 316afc629..facc35dd6 100644 --- a/partner_contact_department/views/res_partner_department_view.xml +++ b/partner_contact_department/views/res_partner_department_view.xml @@ -1,41 +1,36 @@ - - + - Departments res.partner.department - form tree - CRM department tree res.partner.department - - + + - CRM department form res.partner.department
- - - + + +
- - - +
diff --git a/partner_contact_department/views/res_partner_view.xml b/partner_contact_department/views/res_partner_view.xml index b5833571c..5e67228c1 100644 --- a/partner_contact_department/views/res_partner_view.xml +++ b/partner_contact_department/views/res_partner_view.xml @@ -1,44 +1,48 @@ - - + - Partner form with department res.partner - + - + - - - + + + - Partner search with department res.partner - + - + - + -