From 9284c8cce9fd706c62540a8ca70d3d53bc3d9366 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Tue, 8 Dec 2015 11:40:43 +0530 Subject: [PATCH 01/85] [ADD] Added migrated Operating Unit module for v9. --- operating_unit/README.md | 15 +++++ operating_unit/__init__.py | 21 +++++++ operating_unit/__openerp__.py | 56 +++++++++++++++++ operating_unit/data/operating_unit_data.xml | 19 ++++++ operating_unit/demo/operating_unit_demo.xml | 25 ++++++++ operating_unit/models/__init__.py | 22 +++++++ operating_unit/models/operating_unit.py | 44 +++++++++++++ operating_unit/models/res_users.py | 53 ++++++++++++++++ operating_unit/security/ir.model.access.csv | 3 + .../security/operating_unit_security.xml | 18 ++++++ operating_unit/view/operating_unit_view.xml | 61 +++++++++++++++++++ operating_unit/view/res_users_view.xml | 21 +++++++ 12 files changed, 358 insertions(+) create mode 100644 operating_unit/README.md create mode 100644 operating_unit/__init__.py create mode 100644 operating_unit/__openerp__.py create mode 100644 operating_unit/data/operating_unit_data.xml create mode 100644 operating_unit/demo/operating_unit_demo.xml create mode 100644 operating_unit/models/__init__.py create mode 100644 operating_unit/models/operating_unit.py create mode 100644 operating_unit/models/res_users.py create mode 100644 operating_unit/security/ir.model.access.csv create mode 100644 operating_unit/security/operating_unit_security.xml create mode 100644 operating_unit/view/operating_unit_view.xml create mode 100644 operating_unit/view/res_users_view.xml diff --git a/operating_unit/README.md b/operating_unit/README.md new file mode 100644 index 0000000000..20daae9326 --- /dev/null +++ b/operating_unit/README.md @@ -0,0 +1,15 @@ + +Operating Unit +============== +An operating unit (OU) is an organizational entity part of a company, with +separate management ownership. Management by OU is aimed to introduce the +following features: + +- Partition data from other OU's. +- Define its own sequencing schemes. +- Administer user access to the data for processing and reporting. +- Is not product or customer specific. +- Provides OU specific P&L and Balance sheet + +The current module defines the operating unit entity and the user's security +rules. Other modules extend the standard Odoo apps with the OU. \ No newline at end of file diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py new file mode 100644 index 0000000000..b9ea7f2b3d --- /dev/null +++ b/operating_unit/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Eficent () +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import models diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py new file mode 100644 index 0000000000..2e0f18b22b --- /dev/null +++ b/operating_unit/__openerp__.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Eficent () +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + "name": "Operating Unit", + "version": "9.0.0.0.0", + "author": "Eficent, Odoo Community Association (OCA)", + "website": "http://www.eficent.com", + "category": "Generic", + "depends": ["base"], + "description": """ +Operating Unit +============== +An operating unit (OU) is an organizational entity part of a company, with +separate management ownership. Management by OU is aimed to introduce the +following features: + +- Partition data from other OU's. +- Define its own sequencing schemes. +- Administer user access to the data for processing and reporting. +- Is not product or customer specific. +- Provides OU specific P&L and Balance sheet + +The current module defines the operating unit entity and the user's security +rules. Other modules extend the standard Odoo apps with the OU. + """, + "data": [ + "security/operating_unit_security.xml", + "security/ir.model.access.csv", + "view/operating_unit_view.xml", + "view/res_users_view.xml", + "data/operating_unit_data.xml", + ], + 'demo': [ + "demo/operating_unit_demo.xml" + ], + 'installable': True, +} diff --git a/operating_unit/data/operating_unit_data.xml b/operating_unit/data/operating_unit_data.xml new file mode 100644 index 0000000000..3e45a97b05 --- /dev/null +++ b/operating_unit/data/operating_unit_data.xml @@ -0,0 +1,19 @@ + + + + + + + Main Operating Unit + OU1 + + + + + + + + + + diff --git a/operating_unit/demo/operating_unit_demo.xml b/operating_unit/demo/operating_unit_demo.xml new file mode 100644 index 0000000000..ed193deca3 --- /dev/null +++ b/operating_unit/demo/operating_unit_demo.xml @@ -0,0 +1,25 @@ + + + + + + B2B + B2B + + + + + B2C + B2C + + + + + + + + + + diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py new file mode 100644 index 0000000000..f0a665416f --- /dev/null +++ b/operating_unit/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 Eficent () +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import operating_unit +from . import res_users diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py new file mode 100644 index 0000000000..a960f9ec54 --- /dev/null +++ b/operating_unit/models/operating_unit.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Eficent () +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import models, fields, api + + +class OperatingUnit(models.Model): + + _name = 'operating.unit' + _description = 'Operating Unit' + + name = fields.Char('Name', size=256, required=True) + code = fields.Char('Code', size=32, required=True) + active = fields.Boolean('Active', default=True) + company_id = fields.Many2one('res.company', 'Company', required=True, + default=lambda self: self.env['res.company'].\ + _company_default_get('account.account')) + partner_id = fields.Many2one('res.partner', 'Partner', required=True) + + _sql_constraints = [ + ('code_company_uniq', 'unique (code,company_id)', + 'The code of the operating unit must ' + 'be unique per company !'), + ('name_company_uniq', 'unique (name,company_id)', + 'The name of the operating unit must ' + 'be unique per company !') + ] diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py new file mode 100644 index 0000000000..9def5a5308 --- /dev/null +++ b/operating_unit/models/res_users.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Eficent () +# +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import fields, models, api + + +class ResUsers(models.Model): + + _inherit = 'res.users' + + @api.model + def operating_unit_default_get(self, uid2): + if not uid2: + uid2 = self._uid + user = self.env['res.users'].browse(uid2) + return user.default_operating_unit_id and \ + user.default_operating_unit_id.id + + @api.model + def _operating_unit_default_get(self): + return self.operating_unit_default_get(self._uid) + + @api.model + def _get_operating_units(self): + op_unit = self.operating_unit_default_get(self._uid) + if op_unit: + return [op_unit] + return False + + operating_unit_ids = fields.Many2many( + 'operating.unit', 'operating_unit_users_rel', + 'user_id', 'poid', 'Operating Units', + default=_get_operating_units) + default_operating_unit_id = fields.Many2one( + 'operating.unit', 'Default Operating Unit', + default=_operating_unit_default_get) diff --git a/operating_unit/security/ir.model.access.csv b/operating_unit/security/ir.model.access.csv new file mode 100644 index 0000000000..57e640ceee --- /dev/null +++ b/operating_unit/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_operating_unit_erp_manager,operating.unit erp.manager,model_operating_unit,base.group_erp_manager,1,1,1,1 +access_account_operating_unit_user,operating_unit user,model_operating_unit,,1,0,0,0 \ No newline at end of file diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml new file mode 100644 index 0000000000..e3a8ea2d1c --- /dev/null +++ b/operating_unit/security/operating_unit_security.xml @@ -0,0 +1,18 @@ + + + + + + Multi Operating Unit + + + + + Operating Unit Entry + + + ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + diff --git a/operating_unit/view/operating_unit_view.xml b/operating_unit/view/operating_unit_view.xml new file mode 100644 index 0000000000..2ca17e1849 --- /dev/null +++ b/operating_unit/view/operating_unit_view.xml @@ -0,0 +1,61 @@ + + + + + + operating.unit.form + operating.unit + +
+ + + + + + + +
+
+
+ + + operating.unit.tree + operating.unit + + + + + + + + + + operating.unit.search + operating.unit + + + + + + + + + Operating Units + operating.unit + form + tree,form + +

+ Click to start a new Operating Unit. +

+
+
+ + +
+
diff --git a/operating_unit/view/res_users_view.xml b/operating_unit/view/res_users_view.xml new file mode 100644 index 0000000000..47a756aab5 --- /dev/null +++ b/operating_unit/view/res_users_view.xml @@ -0,0 +1,21 @@ + + + + + + res.users.form + res.users + + + + + + + + + + + + + From bb1741089def55e0b5d10ed5b7b6987f01ddc6c6 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Wed, 9 Dec 2015 18:16:25 +0530 Subject: [PATCH 02/85] [IMP] Improved the license terms and improved the module standard as per the OCA guidelines. --- operating_unit/README.md | 71 ++++++++++++++++++- operating_unit/__init__.py | 22 +----- operating_unit/__openerp__.py | 25 ++----- operating_unit/models/__init__.py | 22 +----- operating_unit/models/operating_unit.py | 22 +----- operating_unit/models/res_users.py | 22 +----- .../security/operating_unit_security.xml | 2 +- 7 files changed, 86 insertions(+), 100 deletions(-) diff --git a/operating_unit/README.md b/operating_unit/README.md index 20daae9326..c7912ec248 100644 --- a/operating_unit/README.md +++ b/operating_unit/README.md @@ -1,6 +1,11 @@ +.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg + :target: https://www.gnu.org/licenses/lgpl.html + :alt: License: LGPL-3 +============== Operating Unit ============== + An operating unit (OU) is an organizational entity part of a company, with separate management ownership. Management by OU is aimed to introduce the following features: @@ -9,7 +14,67 @@ following features: - Define its own sequencing schemes. - Administer user access to the data for processing and reporting. - Is not product or customer specific. -- Provides OU specific P&L and Balance sheet +- Provides OU specific P&L and Balance sheet. + +Installation +============ + +No external library is used. + +Configuration +============= + +To configure this module, you need to: +* Assign *Multi Operating Unit* group to user. +* Go to *Settings / Companies / Operating Units* and create Operating Units. + +Usage +===== + +This module defines the operating unit entity and the user's security rules. +Other modules extend the standard Odoo apps with the OU. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/213/9.0 + +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 smashing it by providing a detailed and welcomed `feedback +`_. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Eficent +* Serpent Consulting Services Pvt. Ltd. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. -The current module defines the operating unit entity and the user's security -rules. Other modules extend the standard Odoo apps with the OU. \ No newline at end of file +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py index b9ea7f2b3d..fa0beae12f 100644 --- a/operating_unit/__init__.py +++ b/operating_unit/__init__.py @@ -1,21 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py index 2e0f18b22b..50730a07c1 100644 --- a/operating_unit/__openerp__.py +++ b/operating_unit/__openerp__.py @@ -1,27 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit", - "version": "9.0.0.0.0", + "version": "9.0.1.0.0", "author": "Eficent, Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Generic", @@ -42,6 +26,7 @@ The current module defines the operating unit entity and the user's security rules. Other modules extend the standard Odoo apps with the OU. """, + "license": "LGPL-3", "data": [ "security/operating_unit_security.xml", "security/ir.model.access.csv", diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py index f0a665416f..996d41c203 100644 --- a/operating_unit/models/__init__.py +++ b/operating_unit/models/__init__.py @@ -1,22 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2014 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import operating_unit from . import res_users diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index a960f9ec54..c1da3db1dd 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -1,23 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import models, fields, api diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index 9def5a5308..799e07551e 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -1,23 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Eficent () -# -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import fields, models, api diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml index e3a8ea2d1c..cf4d04d2eb 100644 --- a/operating_unit/security/operating_unit_security.xml +++ b/operating_unit/security/operating_unit_security.xml @@ -1,6 +1,6 @@ - + Multi Operating Unit From 5ecf3488251c1a2c7cd68da267fe09bd1f331402 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Wed, 9 Dec 2015 19:07:47 +0530 Subject: [PATCH 03/85] [ADD] Renamed README.md to README.rst --- operating_unit/{README.md => README.rst} | 1 + 1 file changed, 1 insertion(+) rename operating_unit/{README.md => README.rst} (99%) diff --git a/operating_unit/README.md b/operating_unit/README.rst similarity index 99% rename from operating_unit/README.md rename to operating_unit/README.rst index c7912ec248..286bc103c0 100644 --- a/operating_unit/README.md +++ b/operating_unit/README.rst @@ -25,6 +25,7 @@ Configuration ============= To configure this module, you need to: + * Assign *Multi Operating Unit* group to user. * Go to *Settings / Companies / Operating Units* and create Operating Units. From 74415ac0ab5aca3e9dd7eb6ca50a1cb63d65e809 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Thu, 10 Dec 2015 11:21:36 +0100 Subject: [PATCH 04/85] [IMP] Assign multi_ou grup and add OCA logo. --- operating_unit/data/operating_unit_data.xml | 2 ++ operating_unit/demo/operating_unit_demo.xml | 2 ++ operating_unit/static/description/icon.png | Bin 0 -> 9455 bytes 3 files changed, 4 insertions(+) create mode 100644 operating_unit/static/description/icon.png diff --git a/operating_unit/data/operating_unit_data.xml b/operating_unit/data/operating_unit_data.xml index 3e45a97b05..421a24fcba 100644 --- a/operating_unit/data/operating_unit_data.xml +++ b/operating_unit/data/operating_unit_data.xml @@ -13,6 +13,8 @@ + diff --git a/operating_unit/demo/operating_unit_demo.xml b/operating_unit/demo/operating_unit_demo.xml index ed193deca3..855b8ac29c 100644 --- a/operating_unit/demo/operating_unit_demo.xml +++ b/operating_unit/demo/operating_unit_demo.xml @@ -19,6 +19,8 @@ ref="main_operating_unit"/> + diff --git a/operating_unit/static/description/icon.png b/operating_unit/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVM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sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 From 182b7b60bb898133029f8ada7e25b0dfc29dc201 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Thu, 10 Dec 2015 11:26:09 +0100 Subject: [PATCH 05/85] [FIX] remove description from __openerp__.py --- operating_unit/__openerp__.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py index 50730a07c1..1cf648b2c6 100644 --- a/operating_unit/__openerp__.py +++ b/operating_unit/__openerp__.py @@ -5,27 +5,13 @@ { "name": "Operating Unit", + "summary": "An operating unit (OU) is an organizational entity part of a " + "company", "version": "9.0.1.0.0", "author": "Eficent, Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Generic", "depends": ["base"], - "description": """ -Operating Unit -============== -An operating unit (OU) is an organizational entity part of a company, with -separate management ownership. Management by OU is aimed to introduce the -following features: - -- Partition data from other OU's. -- Define its own sequencing schemes. -- Administer user access to the data for processing and reporting. -- Is not product or customer specific. -- Provides OU specific P&L and Balance sheet - -The current module defines the operating unit entity and the user's security -rules. Other modules extend the standard Odoo apps with the OU. - """, "license": "LGPL-3", "data": [ "security/operating_unit_security.xml", From 4da53ce98e38f2180da1c7a36c0dad9641eb95b5 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Thu, 10 Dec 2015 13:32:59 +0100 Subject: [PATCH 06/85] [FIX] Corrections as per review comments --- operating_unit/README.rst | 12 ++++++------ operating_unit/__openerp__.py | 3 ++- operating_unit/models/operating_unit.py | 12 ++++++------ operating_unit/models/res_users.py | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index 286bc103c0..ba95a0f44a 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -10,11 +10,11 @@ An operating unit (OU) is an organizational entity part of a company, with separate management ownership. Management by OU is aimed to introduce the following features: -- Partition data from other OU's. -- Define its own sequencing schemes. -- Administer user access to the data for processing and reporting. -- Is not product or customer specific. -- Provides OU specific P&L and Balance sheet. +* Data partitioning from other OU. +* Own sequencing schemes. +* User access administration for data processing and reporting. +* Product and customer independence of OU. +* OU specific P&L and Balance sheet. Installation ============ @@ -70,7 +70,7 @@ Maintainer .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: https://odoo-community.org + :target: http://odoo-community.org This module is maintained by the OCA. diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py index 1cf648b2c6..175c249403 100644 --- a/operating_unit/__openerp__.py +++ b/operating_unit/__openerp__.py @@ -8,7 +8,8 @@ "summary": "An operating unit (OU) is an organizational entity part of a " "company", "version": "9.0.1.0.0", - "author": "Eficent, Odoo Community Association (OCA)", + "author": "Eficent, Serpent Consulting Services Pvt. Ltd., " + "Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Generic", "depends": ["base"], diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index c1da3db1dd..a84c7cdfce 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -2,7 +2,7 @@ # © 2015 Eficent - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import models, fields, api +from openerp import api, fields, models class OperatingUnit(models.Model): @@ -13,16 +13,16 @@ class OperatingUnit(models.Model): name = fields.Char('Name', size=256, required=True) code = fields.Char('Code', size=32, required=True) active = fields.Boolean('Active', default=True) - company_id = fields.Many2one('res.company', 'Company', required=True, - default=lambda self: self.env['res.company'].\ - _company_default_get('account.account')) + company_id = fields.Many2one( + 'res.company', 'Company', required=True, default=lambda self: + self.env['res.company']._company_default_get('account.account')) partner_id = fields.Many2one('res.partner', 'Partner', required=True) _sql_constraints = [ ('code_company_uniq', 'unique (code,company_id)', 'The code of the operating unit must ' - 'be unique per company !'), + 'be unique per company!'), ('name_company_uniq', 'unique (name,company_id)', 'The name of the operating unit must ' - 'be unique per company !') + 'be unique per company!') ] diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index 799e07551e..92b89c67ba 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -2,7 +2,7 @@ # © 2015 Eficent - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models, api +from openerp import api, fields, models class ResUsers(models.Model): From e6a880724d41fb2510ed8ba1d714f0e639bda541 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Fri, 11 Dec 2015 11:40:37 +0530 Subject: [PATCH 07/85] [ADD] Added travis yml file and changed the code as per travis test suggestions. --- operating_unit/models/operating_unit.py | 2 +- operating_unit/models/res_users.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index a84c7cdfce..07030ec9d2 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -2,7 +2,7 @@ # © 2015 Eficent - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models +from openerp import fields, models class OperatingUnit(models.Model): diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index 92b89c67ba..f258cefdf8 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -18,7 +18,7 @@ def operating_unit_default_get(self, uid2): user.default_operating_unit_id.id @api.model - def _operating_unit_default_get(self): + def _get_operating_unit(self): return self.operating_unit_default_get(self._uid) @api.model @@ -28,10 +28,10 @@ def _get_operating_units(self): return [op_unit] return False - operating_unit_ids = fields.Many2many( - 'operating.unit', 'operating_unit_users_rel', - 'user_id', 'poid', 'Operating Units', - default=_get_operating_units) - default_operating_unit_id = fields.Many2one( - 'operating.unit', 'Default Operating Unit', - default=_operating_unit_default_get) + operating_unit_ids = fields.Many2many('operating.unit', + 'operating_unit_users_rel', + 'user_id', 'poid', 'Operating Units', + default=_get_operating_units) + default_operating_unit_id = fields.Many2one('operating.unit', + 'Default Operating Unit', + default=_get_operating_unit) From 4a29835033cdb18cc515e903fb7e383a06965442 Mon Sep 17 00:00:00 2001 From: Sudhir Arya Date: Fri, 11 Dec 2015 17:57:04 +0530 Subject: [PATCH 08/85] [IMP] Added name_search to search the OU based on name and code. --- operating_unit/models/operating_unit.py | 15 ++++++++++++++- operating_unit/view/operating_unit_view.xml | 5 ++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 07030ec9d2..395a71f0c4 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -2,7 +2,7 @@ # © 2015 Eficent - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import fields, models +from openerp import api, fields, models class OperatingUnit(models.Model): @@ -26,3 +26,16 @@ class OperatingUnit(models.Model): 'The name of the operating unit must ' 'be unique per company!') ] + + @api.model + def name_search(self, name, args=None, operator='ilike', limit=100): + if not args: + args = [] + if name: + self = self.search([('code', operator, name)] + args, limit=limit) + if not self: + self = self.search([('name', operator, name)] + args, + limit=limit) + else: + self = self.search(args, limit=limit) + return self.name_get() diff --git a/operating_unit/view/operating_unit_view.xml b/operating_unit/view/operating_unit_view.xml index 2ca17e1849..ab11b50685 100644 --- a/operating_unit/view/operating_unit_view.xml +++ b/operating_unit/view/operating_unit_view.xml @@ -34,9 +34,8 @@ operating.unit - + + From f279f2232e2190f10eb3e7cc872094e10ede1fd5 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 11 Dec 2015 15:15:51 +0100 Subject: [PATCH 09/85] [FIX] Review as per @dreispt comments --- operating_unit/models/operating_unit.py | 29 +++++++++++++++++-------- operating_unit/models/res_users.py | 8 ++----- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 395a71f0c4..c1052c0fbe 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -3,6 +3,7 @@ # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models +from openerp.osv import expression class OperatingUnit(models.Model): @@ -29,13 +30,23 @@ class OperatingUnit(models.Model): @api.model def name_search(self, name, args=None, operator='ilike', limit=100): - if not args: - args = [] + # Make a search with default criteria + temp = super(models.Model, self).name_search( + name=name, args=args, operator=operator, limit=limit) + # Make the other search + domain = [] if name: - self = self.search([('code', operator, name)] + args, limit=limit) - if not self: - self = self.search([('name', operator, name)] + args, - limit=limit) - else: - self = self.search(args, limit=limit) - return self.name_get() + domain = [('code', '=ilike', name + '%')] + temp += self.search(domain, limit=limit).name_get() + # Merge both results + res = [] + keys = [] + for val in temp: + if val[0] not in keys: + res.append(val) + keys.append(val[0]) + if len(res) >= limit: + break + + return res + diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index f258cefdf8..803f5759c9 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -14,8 +14,7 @@ def operating_unit_default_get(self, uid2): if not uid2: uid2 = self._uid user = self.env['res.users'].browse(uid2) - return user.default_operating_unit_id and \ - user.default_operating_unit_id.id + return user.default_operating_unit_id @api.model def _get_operating_unit(self): @@ -23,10 +22,7 @@ def _get_operating_unit(self): @api.model def _get_operating_units(self): - op_unit = self.operating_unit_default_get(self._uid) - if op_unit: - return [op_unit] - return False + return self._get_operating_unit() operating_unit_ids = fields.Many2many('operating.unit', 'operating_unit_users_rel', From 8081ab383e96cf59f4f07524376268535e78c7b2 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 11 Dec 2015 15:59:22 +0100 Subject: [PATCH 10/85] [FIX] Review as per travis --- operating_unit/models/operating_unit.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index c1052c0fbe..f1faaf158e 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -3,7 +3,6 @@ # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models -from openerp.osv import expression class OperatingUnit(models.Model): @@ -34,7 +33,6 @@ def name_search(self, name, args=None, operator='ilike', limit=100): temp = super(models.Model, self).name_search( name=name, args=args, operator=operator, limit=limit) # Make the other search - domain = [] if name: domain = [('code', '=ilike', name + '%')] temp += self.search(domain, limit=limit).name_get() From 1ab61b7f872a468622334818937fff1d1e55ba49 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 11 Dec 2015 16:08:43 +0100 Subject: [PATCH 11/85] [FIX] flake8 --- operating_unit/models/operating_unit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index f1faaf158e..34066dce47 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -47,4 +47,3 @@ def name_search(self, name, args=None, operator='ilike', limit=100): break return res - From 42175f142d813e3e3ed37e98bed1a5a1565235fe Mon Sep 17 00:00:00 2001 From: jbeficent Date: Fri, 11 Dec 2015 17:46:04 +0100 Subject: [PATCH 12/85] [IMP] improve name_search --- operating_unit/models/operating_unit.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 34066dce47..2ffd11b43e 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -30,20 +30,12 @@ class OperatingUnit(models.Model): @api.model def name_search(self, name, args=None, operator='ilike', limit=100): # Make a search with default criteria - temp = super(models.Model, self).name_search( + names1 = super(models.Model, self).name_search( name=name, args=args, operator=operator, limit=limit) # Make the other search + names2 = [] if name: domain = [('code', '=ilike', name + '%')] - temp += self.search(domain, limit=limit).name_get() + names2 = self.search(domain, limit=limit).name_get() # Merge both results - res = [] - keys = [] - for val in temp: - if val[0] not in keys: - res.append(val) - keys.append(val[0]) - if len(res) >= limit: - break - - return res + return list(set(names1) | set(names2))[:limit] From 9047faa26711780a9a060df3d4937768fef074da Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 30 Dec 2015 12:44:09 +0100 Subject: [PATCH 13/85] [IMP] changed readme.rst --- operating_unit/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index ba95a0f44a..b60fb06edb 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -62,7 +62,7 @@ Images Contributors ------------ -* Eficent +* Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. Maintainer From 5a9e806d16a57e01682133f1c44bbeef7f3ab17c Mon Sep 17 00:00:00 2001 From: jbeficent Date: Wed, 30 Dec 2015 12:48:54 +0100 Subject: [PATCH 14/85] [IMP] changed Eficent copyright --- operating_unit/__init__.py | 3 ++- operating_unit/__openerp__.py | 6 ++++-- operating_unit/models/__init__.py | 3 ++- operating_unit/models/operating_unit.py | 3 ++- operating_unit/models/res_users.py | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py index fa0beae12f..381cb68fa3 100644 --- a/operating_unit/__init__.py +++ b/operating_unit/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py index 175c249403..17692bb3c3 100644 --- a/operating_unit/__openerp__.py +++ b/operating_unit/__openerp__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). @@ -8,7 +9,8 @@ "summary": "An operating unit (OU) is an organizational entity part of a " "company", "version": "9.0.1.0.0", - "author": "Eficent, Serpent Consulting Services Pvt. Ltd., " + "author": "Eficent Business and IT Consulting Services S.L., " + "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", "website": "http://www.eficent.com", "category": "Generic", diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py index 996d41c203..19a94ce0ba 100644 --- a/operating_unit/models/__init__.py +++ b/operating_unit/models/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import operating_unit diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 2ffd11b43e..7c8ac3b4e9 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index 803f5759c9..ed280d44f9 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent - Jordi Ballester Alomar +# © 2015 Eficent Business and IT Consulting Services S.L. +# - Jordi Ballester Alomar # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from openerp import api, fields, models From e67621501f3b2659b70764ca3d20d9c4cdf57273 Mon Sep 17 00:00:00 2001 From: jbeficent Date: Mon, 11 Jan 2016 05:21:28 +0100 Subject: [PATCH 15/85] [IMP] removed size from char fields. General improvement to XML style. --- operating_unit/models/operating_unit.py | 4 ++-- operating_unit/view/operating_unit_view.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 7c8ac3b4e9..3e41f0ea6c 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -11,8 +11,8 @@ class OperatingUnit(models.Model): _name = 'operating.unit' _description = 'Operating Unit' - name = fields.Char('Name', size=256, required=True) - code = fields.Char('Code', size=32, required=True) + name = fields.Char('Name', required=True) + code = fields.Char('Code', required=True) active = fields.Boolean('Active', default=True) company_id = fields.Many2one( 'res.company', 'Company', required=True, default=lambda self: diff --git a/operating_unit/view/operating_unit_view.xml b/operating_unit/view/operating_unit_view.xml index ab11b50685..6f22f50277 100644 --- a/operating_unit/view/operating_unit_view.xml +++ b/operating_unit/view/operating_unit_view.xml @@ -53,8 +53,8 @@ + groups="operating_unit.group_multi_operating_unit"/> From afab3c70afb05dfde8f7626bacc10b856602a61c Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 16:04:30 +0200 Subject: [PATCH 16/85] [MIG] Make modules uninstallable --- operating_unit/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operating_unit/__openerp__.py b/operating_unit/__openerp__.py index 17692bb3c3..951fdc669c 100644 --- a/operating_unit/__openerp__.py +++ b/operating_unit/__openerp__.py @@ -26,5 +26,5 @@ 'demo': [ "demo/operating_unit_demo.xml" ], - 'installable': True, + 'installable': False, } From c6b798ced3806f85a32b1a89375e8712007d6601 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 6 Oct 2016 16:04:31 +0200 Subject: [PATCH 17/85] [MIG] Rename manifest files --- operating_unit/{__openerp__.py => __manifest__.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename operating_unit/{__openerp__.py => __manifest__.py} (100%) diff --git a/operating_unit/__openerp__.py b/operating_unit/__manifest__.py similarity index 100% rename from operating_unit/__openerp__.py rename to operating_unit/__manifest__.py From 259f0dff48d22084dfc32499462b27e94f011c5d Mon Sep 17 00:00:00 2001 From: mreficent Date: Thu, 26 Jan 2017 18:41:43 +0100 Subject: [PATCH 18/85] [MIG] operating_unit to v10.0 (#45) * [MIG] operating_unit to v10.0 --- operating_unit/README.rst | 19 +--- operating_unit/__init__.py | 4 +- operating_unit/__manifest__.py | 12 +- operating_unit/data/operating_unit_data.xml | 34 +++--- operating_unit/demo/operating_unit_demo.xml | 43 ++++--- operating_unit/models/__init__.py | 4 +- operating_unit/models/operating_unit.py | 6 +- operating_unit/models/res_users.py | 6 +- operating_unit/security/ir.model.access.csv | 2 +- .../security/operating_unit_security.xml | 7 +- operating_unit/view/operating_unit_view.xml | 107 +++++++++--------- operating_unit/view/res_users_view.xml | 34 +++--- 12 files changed, 126 insertions(+), 152 deletions(-) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index b60fb06edb..eed2bc1268 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -16,11 +16,6 @@ following features: * Product and customer independence of OU. * OU specific P&L and Balance sheet. -Installation -============ - -No external library is used. - Configuration ============= @@ -37,19 +32,15 @@ Other modules extend the standard Odoo apps with the OU. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/9.0 + :target: https://runbot.odoo-community.org/runbot/213/10.0 Bug Tracker =========== Bugs are tracked on `GitHub Issues -`_. In case of trouble, please +`_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed `feedback -`_. +help us smash it by providing detailed and welcomed feedback. Credits ======= @@ -62,7 +53,7 @@ Images Contributors ------------ -* Eficent Business and IT Consulting Services S.L. +* Eficent * Serpent Consulting Services Pvt. Ltd. Maintainer @@ -78,4 +69,4 @@ 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. -To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file +To contribute to this module, please visit http://odoo-community.org. diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py index 381cb68fa3..245219f12b 100644 --- a/operating_unit/__init__.py +++ b/operating_unit/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/operating_unit/__manifest__.py b/operating_unit/__manifest__.py index 951fdc669c..83a11e8601 100644 --- a/operating_unit/__manifest__.py +++ b/operating_unit/__manifest__.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# License: LGPL-3 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit", "summary": "An operating unit (OU) is an organizational entity part of a " "company", - "version": "9.0.1.0.0", - "author": "Eficent Business and IT Consulting Services S.L., " + "version": "10.0.1.0.0", + "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", "website": "http://www.eficent.com", @@ -26,5 +26,5 @@ 'demo': [ "demo/operating_unit_demo.xml" ], - 'installable': False, + 'installable': True, } diff --git a/operating_unit/data/operating_unit_data.xml b/operating_unit/data/operating_unit_data.xml index 421a24fcba..212490a30b 100644 --- a/operating_unit/data/operating_unit_data.xml +++ b/operating_unit/data/operating_unit_data.xml @@ -1,21 +1,17 @@ - - + + + + Main Operating Unit + OU1 + + - - - Main Operating Unit - OU1 - - - - - - - - - - - + + + + + + diff --git a/operating_unit/demo/operating_unit_demo.xml b/operating_unit/demo/operating_unit_demo.xml index 855b8ac29c..2931a893cf 100644 --- a/operating_unit/demo/operating_unit_demo.xml +++ b/operating_unit/demo/operating_unit_demo.xml @@ -1,27 +1,24 @@ - - + + + B2B + B2B + + - - B2B - B2B - - - - B2C - B2C - - + + B2C + B2C + + - - - - - - - - + + + + + + diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py index 19a94ce0ba..e33250227d 100644 --- a/operating_unit/models/__init__.py +++ b/operating_unit/models/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import operating_unit from . import res_users diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 3e41f0ea6c..8956183fa0 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models +from odoo import api, fields, models class OperatingUnit(models.Model): diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index ed280d44f9..439e52e78b 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# © 2015 Eficent Business and IT Consulting Services S.L. +# © 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from openerp import api, fields, models +from odoo import api, fields, models class ResUsers(models.Model): diff --git a/operating_unit/security/ir.model.access.csv b/operating_unit/security/ir.model.access.csv index 57e640ceee..cc826c47c6 100644 --- a/operating_unit/security/ir.model.access.csv +++ b/operating_unit/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_account_operating_unit_erp_manager,operating.unit erp.manager,model_operating_unit,base.group_erp_manager,1,1,1,1 -access_account_operating_unit_user,operating_unit user,model_operating_unit,,1,0,0,0 \ No newline at end of file +access_account_operating_unit_user,operating_unit user,model_operating_unit,,1,0,0,0 diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml index cf4d04d2eb..1c731107cb 100644 --- a/operating_unit/security/operating_unit_security.xml +++ b/operating_unit/security/operating_unit_security.xml @@ -1,6 +1,5 @@ - - + Multi Operating Unit @@ -13,6 +12,4 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] - - - + diff --git a/operating_unit/view/operating_unit_view.xml b/operating_unit/view/operating_unit_view.xml index 6f22f50277..2ad1cb169e 100644 --- a/operating_unit/view/operating_unit_view.xml +++ b/operating_unit/view/operating_unit_view.xml @@ -1,60 +1,57 @@ - - - - - operating.unit.form - operating.unit - -
- - - - - - - -
-
-
- - - operating.unit.tree - operating.unit - - - + + + operating.unit.form + operating.unit + +
+ + + + - - - - - operating.unit.search - operating.unit - - - - - - - + +
+
+
+ + + operating.unit.tree + operating.unit + + + + + + + + + + operating.unit.search + operating.unit + + + + + + + - - Operating Units - operating.unit - form - tree,form - -

- Click to start a new Operating Unit. -

-
-
+ + Operating Units + operating.unit + form + tree,form + +

+ Click to start a new Operating Unit. +

+
+
- -
-
+ + diff --git a/operating_unit/view/res_users_view.xml b/operating_unit/view/res_users_view.xml index 47a756aab5..ed394e12de 100644 --- a/operating_unit/view/res_users_view.xml +++ b/operating_unit/view/res_users_view.xml @@ -1,21 +1,17 @@ - - - - - res.users.form - res.users - - - - - - - - + + + res.users.form + res.users + + + + + + + - - - - + + + From f70726d7c0a8ffef0377b286a1f5d59d3ae22b20 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Tue, 31 Jan 2017 15:06:51 +0100 Subject: [PATCH 19/85] A user can only select the operating units that he is allowed (#59) --- operating_unit/security/operating_unit_security.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml index 1c731107cb..5389320d62 100644 --- a/operating_unit/security/operating_unit_security.xml +++ b/operating_unit/security/operating_unit_security.xml @@ -12,4 +12,17 @@ ['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])] + + + + [('id','in',[g.id for g in user.operating_unit_ids])] + Allowed operating units + + + + + + + From 68dce57ad2fcc3c45f1703b2809022baa788e878 Mon Sep 17 00:00:00 2001 From: Graeme Gellatly Date: Mon, 19 Feb 2018 12:04:57 +1300 Subject: [PATCH 20/85] Port to v11 - retry --- operating_unit/README.rst | 4 +-- operating_unit/__init__.py | 5 ++-- operating_unit/__manifest__.py | 9 +++--- operating_unit/models/__init__.py | 5 ++-- operating_unit/models/operating_unit.py | 7 ++--- operating_unit/models/res_users.py | 30 +++++++++---------- .../security/operating_unit_security.xml | 2 +- operating_unit/view/operating_unit_view.xml | 4 +-- operating_unit/view/res_users_view.xml | 4 +-- 9 files changed, 33 insertions(+), 37 deletions(-) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index eed2bc1268..39d9c9014e 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -22,7 +22,7 @@ Configuration To configure this module, you need to: * Assign *Multi Operating Unit* group to user. -* Go to *Settings / Companies / Operating Units* and create Operating Units. +* Go to *Settings / Users & Companies / Operating Units* and create Operating Units. Usage ===== @@ -32,7 +32,7 @@ Other modules extend the standard Odoo apps with the OU. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/10.0 + :target: https://runbot.odoo-community.org/runbot/213/11.0 Bug Tracker =========== diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py index 245219f12b..966479bef7 100644 --- a/operating_unit/__init__.py +++ b/operating_unit/__init__.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2015-2017 Eficent +# Copyright 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/operating_unit/__manifest__.py b/operating_unit/__manifest__.py index 83a11e8601..27fbfc7b23 100644 --- a/operating_unit/__manifest__.py +++ b/operating_unit/__manifest__.py @@ -1,18 +1,17 @@ -# -*- coding: utf-8 -*- -# © 2015-2017 Eficent +# Copyright 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License: LGPL-3 or later (https://www.gnu.org/licenses/lgpl.html). { "name": "Operating Unit", "summary": "An operating unit (OU) is an organizational entity part of a " "company", - "version": "10.0.1.0.0", + "version": "11.0.1.0.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", - "website": "http://www.eficent.com", + "website": "https://github.com/OCA/operating-unit", "category": "Generic", "depends": ["base"], "license": "LGPL-3", diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py index e33250227d..6c6bd6325b 100644 --- a/operating_unit/models/__init__.py +++ b/operating_unit/models/__init__.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2017 Eficent +# Copyright 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import operating_unit from . import res_users diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index 8956183fa0..de78df9979 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2017 Eficent +# Copyright 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models @@ -29,7 +28,7 @@ class OperatingUnit(models.Model): ] @api.model - def name_search(self, name, args=None, operator='ilike', limit=100): + def name_search(self, name='', args=None, operator='ilike', limit=100): # Make a search with default criteria names1 = super(models.Model, self).name_search( name=name, args=args, operator=operator, limit=limit) diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index 439e52e78b..a2c81ea7f2 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2015-2017 Eficent +# Copyright 2015-2017 Eficent # - Jordi Ballester Alomar -# © 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models @@ -11,24 +10,25 @@ class ResUsers(models.Model): _inherit = 'res.users' @api.model - def operating_unit_default_get(self, uid2): + def operating_unit_default_get(self, uid2=False): if not uid2: uid2 = self._uid user = self.env['res.users'].browse(uid2) return user.default_operating_unit_id @api.model - def _get_operating_unit(self): - return self.operating_unit_default_get(self._uid) + def _default_operating_unit(self): + return self.operating_unit_default_get() @api.model - def _get_operating_units(self): - return self._get_operating_unit() + def _default_operating_units(self): + return self._default_operating_unit() - operating_unit_ids = fields.Many2many('operating.unit', - 'operating_unit_users_rel', - 'user_id', 'poid', 'Operating Units', - default=_get_operating_units) - default_operating_unit_id = fields.Many2one('operating.unit', - 'Default Operating Unit', - default=_get_operating_unit) + operating_unit_ids = fields.Many2many( + 'operating.unit', 'operating_unit_users_rel', 'user_id', 'poid', + 'Operating Units', default=lambda self: self._default_operating_units() + ) + default_operating_unit_id = fields.Many2one( + 'operating.unit', 'Default Operating Unit', + default=lambda self: self._default_operating_unit() + ) diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml index 5389320d62..b496651c73 100644 --- a/operating_unit/security/operating_unit_security.xml +++ b/operating_unit/security/operating_unit_security.xml @@ -16,7 +16,7 @@ - [('id','in',[g.id for g in user.operating_unit_ids])] + [('id','in',user.operating_unit_ids.ids)] Allowed operating units diff --git a/operating_unit/view/operating_unit_view.xml b/operating_unit/view/operating_unit_view.xml index 2ad1cb169e..ebc1ee70c0 100644 --- a/operating_unit/view/operating_unit_view.xml +++ b/operating_unit/view/operating_unit_view.xml @@ -4,8 +4,8 @@ operating.unit.form operating.unit -
- + + diff --git a/operating_unit/view/res_users_view.xml b/operating_unit/view/res_users_view.xml index ed394e12de..0dd37fa798 100644 --- a/operating_unit/view/res_users_view.xml +++ b/operating_unit/view/res_users_view.xml @@ -5,13 +5,13 @@ res.users - + - + From c2c53750c80bb04b8aab1fbab579abd6c69be855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Gil=20Sorribes?= Date: Mon, 19 Nov 2018 16:06:11 +0100 Subject: [PATCH 21/85] [12.0][MIG] operating_unit: Migration to v12.0 --- operating_unit/README.rst | 64 ++++++++++--- operating_unit/__init__.py | 4 - operating_unit/__manifest__.py | 9 +- operating_unit/data/operating_unit_data.xml | 7 +- operating_unit/models/__init__.py | 4 - operating_unit/models/operating_unit.py | 11 ++- operating_unit/models/res_users.py | 4 +- operating_unit/readme/CONFIGURE.rst | 5 + operating_unit/readme/CONTRIBUTORS.rst | 3 + operating_unit/readme/DESCRIPTION.rst | 10 ++ operating_unit/readme/USAGE.rst | 3 + operating_unit/security/ir.model.access.csv | 2 +- .../security/operating_unit_security.xml | 29 +++++- operating_unit/tests/__init__.py | 1 + operating_unit/tests/test_operating_unit.py | 91 +++++++++++++++++++ 15 files changed, 209 insertions(+), 38 deletions(-) create mode 100644 operating_unit/readme/CONFIGURE.rst create mode 100644 operating_unit/readme/CONTRIBUTORS.rst create mode 100644 operating_unit/readme/DESCRIPTION.rst create mode 100644 operating_unit/readme/USAGE.rst create mode 100644 operating_unit/tests/__init__.py create mode 100644 operating_unit/tests/test_operating_unit.py diff --git a/operating_unit/README.rst b/operating_unit/README.rst index 39d9c9014e..afb1017cb8 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -1,11 +1,31 @@ -.. image:: https://img.shields.io/badge/license-LGPLv3-blue.svg - :target: https://www.gnu.org/licenses/lgpl.html - :alt: License: LGPL-3 ============== Operating Unit ============== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/operating_unit/tree/12.0/operating_unit + :alt: OCA/operating_unit +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-11-0/server-tools-11-0-kpi + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/253/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| + An operating unit (OU) is an organizational entity part of a company, with separate management ownership. Management by OU is aimed to introduce the following features: @@ -16,6 +36,12 @@ following features: * Product and customer independence of OU. * OU specific P&L and Balance sheet. + +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -30,43 +56,51 @@ Usage This module defines the operating unit entity and the user's security rules. Other modules extend the standard Odoo apps with the OU. +See usage of version: 11.0 + .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot :target: https://runbot.odoo-community.org/runbot/213/11.0 + 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 smash it by providing detailed and welcomed feedback. +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= Images ------- +~~~~~~ * Odoo Community Association: `Icon `_. Contributors ------------- +~~~~~~~~~~~~ * Eficent * Serpent Consulting Services Pvt. Ltd. -Maintainer ----------- -.. image:: https://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org +Maintainers +~~~~~~~~~~~ This module is maintained by the OCA. +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + 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. -To contribute to this module, please visit http://odoo-community.org. +This module is part of the `OCA/operating-unit `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/operating_unit/__init__.py b/operating_unit/__init__.py index 966479bef7..0650744f6b 100644 --- a/operating_unit/__init__.py +++ b/operating_unit/__init__.py @@ -1,5 +1 @@ -# Copyright 2015-2017 Eficent -# - Jordi Ballester Alomar -# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import models diff --git a/operating_unit/__manifest__.py b/operating_unit/__manifest__.py index 27fbfc7b23..c176faa634 100644 --- a/operating_unit/__manifest__.py +++ b/operating_unit/__manifest__.py @@ -1,13 +1,12 @@ -# Copyright 2015-2017 Eficent +# Copyright 2015-TODAY Eficent # - Jordi Ballester Alomar -# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-TODAY Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License: LGPL-3 or later (https://www.gnu.org/licenses/lgpl.html). - { "name": "Operating Unit", "summary": "An operating unit (OU) is an organizational entity part of a " "company", - "version": "11.0.1.0.0", + "version": "12.0.1.0.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", @@ -18,9 +17,9 @@ "data": [ "security/operating_unit_security.xml", "security/ir.model.access.csv", + "data/operating_unit_data.xml", "view/operating_unit_view.xml", "view/res_users_view.xml", - "data/operating_unit_data.xml", ], 'demo': [ "demo/operating_unit_demo.xml" diff --git a/operating_unit/data/operating_unit_data.xml b/operating_unit/data/operating_unit_data.xml index 212490a30b..239eb7bc57 100644 --- a/operating_unit/data/operating_unit_data.xml +++ b/operating_unit/data/operating_unit_data.xml @@ -11,7 +11,10 @@ - + + + + diff --git a/operating_unit/models/__init__.py b/operating_unit/models/__init__.py index 6c6bd6325b..b2dcf9371c 100644 --- a/operating_unit/models/__init__.py +++ b/operating_unit/models/__init__.py @@ -1,6 +1,2 @@ -# Copyright 2015-2017 Eficent -# - Jordi Ballester Alomar -# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya -# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from . import operating_unit from . import res_users diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index de78df9979..f7930159c4 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -1,6 +1,6 @@ -# Copyright 2015-2017 Eficent +# Copyright 2015-TODAY Eficent # - Jordi Ballester Alomar -# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-TODAY Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models @@ -39,3 +39,10 @@ def name_search(self, name='', args=None, operator='ilike', limit=100): names2 = self.search(domain, limit=limit).name_get() # Merge both results return list(set(names1) | set(names2))[:limit] + + @api.model + def create(self, values): + res = super(OperatingUnit, self).create(values) + self.env.user.write({'operating_unit_ids': [(4, res.id)]}) + + return res diff --git a/operating_unit/models/res_users.py b/operating_unit/models/res_users.py index a2c81ea7f2..4cf5941043 100644 --- a/operating_unit/models/res_users.py +++ b/operating_unit/models/res_users.py @@ -1,6 +1,6 @@ -# Copyright 2015-2017 Eficent +# Copyright 2015-TODAY Eficent # - Jordi Ballester Alomar -# Copyright 2015-2017 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya +# Copyright 2015-TODAY Serpent Consulting Services Pvt. Ltd. - Sudhir Arya # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models diff --git a/operating_unit/readme/CONFIGURE.rst b/operating_unit/readme/CONFIGURE.rst new file mode 100644 index 0000000000..d344202199 --- /dev/null +++ b/operating_unit/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ + +To configure this module, you need to: + +* Assign *Multi Operating Unit* group to user. +* Go to *Settings / Users & Companies / Operating Units* and create Operating Units. diff --git a/operating_unit/readme/CONTRIBUTORS.rst b/operating_unit/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..994bacbc98 --- /dev/null +++ b/operating_unit/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ + +* Eficent +* Serpent Consulting Services Pvt. Ltd. diff --git a/operating_unit/readme/DESCRIPTION.rst b/operating_unit/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..93e24808e4 --- /dev/null +++ b/operating_unit/readme/DESCRIPTION.rst @@ -0,0 +1,10 @@ + +An operating unit (OU) is an organizational entity part of a company, with +separate management ownership. Management by OU is aimed to introduce the +following features: + +* Data partitioning from other OU. +* Own sequencing schemes. +* User access administration for data processing and reporting. +* Product and customer independence of OU. +* OU specific P&L and Balance sheet. diff --git a/operating_unit/readme/USAGE.rst b/operating_unit/readme/USAGE.rst new file mode 100644 index 0000000000..bc01c29c20 --- /dev/null +++ b/operating_unit/readme/USAGE.rst @@ -0,0 +1,3 @@ + +This module defines the operating unit entity and the user's security rules. +Other modules extend the standard Odoo apps with the OU. diff --git a/operating_unit/security/ir.model.access.csv b/operating_unit/security/ir.model.access.csv index cc826c47c6..684eb665b6 100644 --- a/operating_unit/security/ir.model.access.csv +++ b/operating_unit/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_account_operating_unit_erp_manager,operating.unit erp.manager,model_operating_unit,base.group_erp_manager,1,1,1,1 +access_account_operating_unit_erp_manager,operating.unit erp.manager,model_operating_unit,group_manager_operating_unit,1,1,1,1 access_account_operating_unit_user,operating_unit user,model_operating_unit,,1,0,0,0 diff --git a/operating_unit/security/operating_unit_security.xml b/operating_unit/security/operating_unit_security.xml index b496651c73..700f5628bf 100644 --- a/operating_unit/security/operating_unit_security.xml +++ b/operating_unit/security/operating_unit_security.xml @@ -1,9 +1,21 @@ + + Operating Units Group + 30 + + - Multi Operating Unit - + Multiple Operating Unit + + + + + Manager of Operating Units + + + @@ -18,11 +30,22 @@ [('id','in',user.operating_unit_ids.ids)] Allowed operating units - + + + + + Operating Unit Manager + + [(1, '=', 1)] + + + + + diff --git a/operating_unit/tests/__init__.py b/operating_unit/tests/__init__.py new file mode 100644 index 0000000000..8096d86683 --- /dev/null +++ b/operating_unit/tests/__init__.py @@ -0,0 +1 @@ +from . import test_operating_unit diff --git a/operating_unit/tests/test_operating_unit.py b/operating_unit/tests/test_operating_unit.py new file mode 100644 index 0000000000..63b147f592 --- /dev/null +++ b/operating_unit/tests/test_operating_unit.py @@ -0,0 +1,91 @@ +# © 2017-TODAY Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo.tests import common +from odoo.exceptions import AccessError + + +class TestOperatingUnit(common.TransactionCase): + + def setUp(self): + super(TestOperatingUnit, self).setUp() + self.res_users_model = self.env['res.users'].with_context( + tracking_disable=True, no_reset_password=True) + + # Groups + self.grp_ou_mngr = self.env.ref( + 'operating_unit.group_manager_operating_unit') + self.grp_ou_multi = self.env.ref( + 'operating_unit.group_multi_operating_unit') + # Company + self.company = self.env.ref('base.main_company') + # Main Operating Unit + self.ou1 = self.env.ref('operating_unit.main_operating_unit') + # B2C Operating Unit + self.b2c = self.env.ref('operating_unit.b2c_operating_unit') + # B2B Operating Unit + self.b2b = self.env.ref('operating_unit.b2b_operating_unit') + # Create User 1 with Main OU + self.user1 = self._create_user('user_1', + self.grp_ou_mngr, + self.company, + self.ou1) + # Create User 2 with B2C OU + self.user2 = self._create_user('user_2', + self.grp_ou_multi, + self.company, + self.b2c) + + def _create_user(self, login, group, company, operating_units, + context=None): + """ Create a user. """ + user = self.res_users_model.create({ + 'name': 'Test User', + 'login': login, + 'password': 'demo', + 'email': 'test@yourcompany.com', + 'company_id': company.id, + 'company_ids': [(4, company.id)], + 'operating_unit_ids': [(4, ou.id) for ou in operating_units], + 'sel_groups_13_14': group.id + }) + return user + + def _create_operating_unit(self, uid, name, code): + """ Create Operating Unit""" + ou = self.env['operating.unit'].sudo(uid).create({ + 'name': name, + 'code': code, + 'partner_id': self.company.id, + }) + return ou + + def test_01_operating_unit(self): + # User 1 tries to create and modify an OU + # Create + self._create_operating_unit(self.user1.id, "Test", "TEST") + # Write + self.b2b.sudo(self.user1.id).write({'code': 'B2B_changed'}) + # Read list of OU available by User 1 + operating_unit_list_1 = self.env[ + 'operating.unit'].sudo(self.user1.id).\ + search([]).mapped('code') + self.assertEqual(len(operating_unit_list_1), 4, + 'User 1 should have access to all the OU') + + # User 2 tries to create and modify an OU + with self.assertRaises(AccessError): + # Create + self._create_operating_unit(self.user2.id, "Test", "TEST") + with self.assertRaises(AccessError): + # Write + self.b2b.sudo(self.user2.id).write({'code': 'B2B_changed'}) + + # Read list of OU available by User 2 + operating_unit_list_2 = self.env[ + 'operating.unit'].sudo(self.user2.id).\ + search([]).mapped('code') + self.assertEqual(len(operating_unit_list_2), 1, + 'User 2 should have access to one OU') + self.assertEqual(operating_unit_list_2[0], 'B2C', + 'User 2 should have access to ' '%s' % self.b2c.name) From 3d03d41e7d141c3c306a150afa4fe216069f6469 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Wed, 21 Nov 2018 11:12:41 +0000 Subject: [PATCH 22/85] [UPD] README.rst --- operating_unit/README.rst | 39 +- operating_unit/static/description/index.html | 445 +++++++++++++++++++ 2 files changed, 462 insertions(+), 22 deletions(-) create mode 100644 operating_unit/static/description/index.html diff --git a/operating_unit/README.rst b/operating_unit/README.rst index afb1017cb8..7d54482d1c 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -1,4 +1,3 @@ - ============== Operating Unit ============== @@ -14,17 +13,18 @@ Operating Unit .. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/operating_unit/tree/12.0/operating_unit - :alt: OCA/operating_unit +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github + :target: https://github.com/OCA/operating-unit/tree/12.0/operating_unit + :alt: OCA/operating-unit .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-11-0/server-tools-11-0-kpi + :target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-operating_unit :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/253/11.0 + :target: https://runbot.odoo-community.org/runbot/213/12.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| +|badge1| |badge2| |badge3| |badge4| |badge5| + An operating unit (OU) is an organizational entity part of a company, with separate management ownership. Management by OU is aimed to introduce the @@ -36,15 +36,15 @@ following features: * Product and customer independence of OU. * OU specific P&L and Balance sheet. - **Table of contents** .. contents:: - :local: + :local: Configuration ============= + To configure this module, you need to: * Assign *Multi Operating Unit* group to user. @@ -53,41 +53,36 @@ To configure this module, you need to: Usage ===== + This module defines the operating unit entity and the user's security rules. Other modules extend the standard Odoo apps with the OU. -See usage of version: 11.0 - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/213/11.0 - - 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 smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. Credits ======= -Images -~~~~~~ +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Eficent +* Serpent Consulting Services Pvt. Ltd. Contributors ~~~~~~~~~~~~ + * Eficent * Serpent Consulting Services Pvt. Ltd. - Maintainers ~~~~~~~~~~~ @@ -101,6 +96,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/operating-unit `_ project on GitHub. +This module is part of the `OCA/operating-unit `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/operating_unit/static/description/index.html b/operating_unit/static/description/index.html new file mode 100644 index 0000000000..ee5adccdb9 --- /dev/null +++ b/operating_unit/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +Operating Unit + + + +
+

Operating Unit

+ + +

Beta License: LGPL-3 OCA/operating-unit Translate me on Weblate Try me on Runbot

+

An operating unit (OU) is an organizational entity part of a company, with +separate management ownership. Management by OU is aimed to introduce the +following features:

+
    +
  • Data partitioning from other OU.
  • +
  • Own sequencing schemes.
  • +
  • User access administration for data processing and reporting.
  • +
  • Product and customer independence of OU.
  • +
  • OU specific P&L and Balance sheet.
  • +
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • Assign Multi Operating Unit group to user.
  • +
  • Go to Settings / Users & Companies / Operating Units and create Operating Units.
  • +
+
+
+

Usage

+

This module defines the operating unit entity and the user’s security rules. +Other modules extend the standard Odoo apps with the OU.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Eficent
  • +
  • Serpent Consulting Services Pvt. Ltd.
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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/operating-unit project on GitHub.

+

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

+
+
+
+ + From c02c90a93c91c1f013144ca9b9cc409d048efd66 Mon Sep 17 00:00:00 2001 From: aheficent Date: Fri, 30 Nov 2018 11:14:16 +0100 Subject: [PATCH 23/85] [IMP]add user_ids field in operating unit. Useful for accesing in other models --- operating_unit/__manifest__.py | 2 +- operating_unit/models/operating_unit.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/operating_unit/__manifest__.py b/operating_unit/__manifest__.py index c176faa634..769406c0c3 100644 --- a/operating_unit/__manifest__.py +++ b/operating_unit/__manifest__.py @@ -6,7 +6,7 @@ "name": "Operating Unit", "summary": "An operating unit (OU) is an organizational entity part of a " "company", - "version": "12.0.1.0.0", + "version": "12.0.1.1.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index f7930159c4..e3c6bc7172 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -17,6 +17,10 @@ class OperatingUnit(models.Model): 'res.company', 'Company', required=True, default=lambda self: self.env['res.company']._company_default_get('account.account')) partner_id = fields.Many2one('res.partner', 'Partner', required=True) + user_ids = fields.Many2many( + 'res.users', 'operating_unit_users_rel', 'poid', 'user_id', + 'Users Allowed', + ) _sql_constraints = [ ('code_company_uniq', 'unique (code,company_id)', From 515ca9f433d7f2c666a714eb28b9c4ebd67057a3 Mon Sep 17 00:00:00 2001 From: aheficent Date: Mon, 3 Dec 2018 17:01:51 +0100 Subject: [PATCH 24/85] [UPT]operating_unit roadmap --- operating_unit/README.rst | 7 +++++++ operating_unit/readme/ROADMAP.rst | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 operating_unit/readme/ROADMAP.rst diff --git a/operating_unit/README.rst b/operating_unit/README.rst index 7d54482d1c..f6e3df0d0d 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -57,6 +57,13 @@ Usage This module defines the operating unit entity and the user's security rules. Other modules extend the standard Odoo apps with the OU. +Known issues / Roadmap +====================== + +The column name of the table operating_unit_users_rel is bad. Change it in v13 +and create the proper migration script. + + Bug Tracker =========== diff --git a/operating_unit/readme/ROADMAP.rst b/operating_unit/readme/ROADMAP.rst new file mode 100644 index 0000000000..4d7243a814 --- /dev/null +++ b/operating_unit/readme/ROADMAP.rst @@ -0,0 +1,3 @@ + +The column name of the table operating_unit_users_rel is bad. Change it in v13 +and create the proper migration script. From 9a237397ba8bc8a2d6769b3dada50f474c4a2261 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 4 Dec 2018 10:18:08 +0000 Subject: [PATCH 25/85] [UPD] README.rst --- operating_unit/README.rst | 2 +- operating_unit/static/description/index.html | 26 ++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/operating_unit/README.rst b/operating_unit/README.rst index f6e3df0d0d..6baffcd1c0 100644 --- a/operating_unit/README.rst +++ b/operating_unit/README.rst @@ -60,10 +60,10 @@ Other modules extend the standard Odoo apps with the OU. Known issues / Roadmap ====================== + The column name of the table operating_unit_users_rel is bad. Change it in v13 and create the proper migration script. - Bug Tracker =========== diff --git a/operating_unit/static/description/index.html b/operating_unit/static/description/index.html index ee5adccdb9..96374801b0 100644 --- a/operating_unit/static/description/index.html +++ b/operating_unit/static/description/index.html @@ -383,11 +383,12 @@

Operating Unit

  • Configuration
  • Usage
  • -
  • Bug Tracker
  • -
  • Credits @@ -405,8 +406,13 @@

    Usage

    This module defines the operating unit entity and the user’s security rules. Other modules extend the standard Odoo apps with the OU.

    +
    +

    Known issues / Roadmap

    +

    The column name of the table operating_unit_users_rel is bad. Change it in v13 +and create the proper migration script.

    +
    -

    Bug Tracker

    +

    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 smashing it by providing a detailed and welcomed @@ -414,23 +420,23 @@

    Bug Tracker

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

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Eficent
    • Serpent Consulting Services Pvt. Ltd.
    -

    Contributors

    +

    Contributors

    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    OCA, or the Odoo Community Association, is a nonprofit organization whose From b5e01a22187fa970d5ffb106335cabdd0b6a4660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Be=C3=B1at=20Jimenez?= Date: Tue, 18 Dec 2018 10:58:47 +0100 Subject: [PATCH 26/85] [FIX] operating_unit: Failing test --- operating_unit/tests/test_operating_unit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/operating_unit/tests/test_operating_unit.py b/operating_unit/tests/test_operating_unit.py index 63b147f592..cbd5dd29bb 100644 --- a/operating_unit/tests/test_operating_unit.py +++ b/operating_unit/tests/test_operating_unit.py @@ -70,7 +70,8 @@ def test_01_operating_unit(self): operating_unit_list_1 = self.env[ 'operating.unit'].sudo(self.user1.id).\ search([]).mapped('code') - self.assertEqual(len(operating_unit_list_1), 4, + nou = self.env['operating.unit'].search([]) + self.assertEqual(len(operating_unit_list_1), len(nou), 'User 1 should have access to all the OU') # User 2 tries to create and modify an OU From f8440690fa04bb22cc28433aed9efbff97c15f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Be=C3=B1at=20Jimenez?= Date: Mon, 21 Jan 2019 13:17:37 +0100 Subject: [PATCH 27/85] [FIX] operating_unit: Creation of OU's failing cause of wrong environment --- operating_unit/models/operating_unit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index e3c6bc7172..e7d6f1e9e3 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -47,6 +47,5 @@ def name_search(self, name='', args=None, operator='ilike', limit=100): @api.model def create(self, values): res = super(OperatingUnit, self).create(values) - self.env.user.write({'operating_unit_ids': [(4, res.id)]}) - + res.user_ids += self.env.user return res From 46351458d823e4ac6cb2796766890bee00b8dafe Mon Sep 17 00:00:00 2001 From: Aaron Henriquez Date: Tue, 29 Jan 2019 10:37:25 +0100 Subject: [PATCH 28/85] [FIX]clear caches when saving so OU rules are updated --- operating_unit/__manifest__.py | 2 +- operating_unit/models/operating_unit.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/operating_unit/__manifest__.py b/operating_unit/__manifest__.py index 769406c0c3..6c4f0e1659 100644 --- a/operating_unit/__manifest__.py +++ b/operating_unit/__manifest__.py @@ -6,7 +6,7 @@ "name": "Operating Unit", "summary": "An operating unit (OU) is an organizational entity part of a " "company", - "version": "12.0.1.1.0", + "version": "12.0.1.2.0", "author": "Eficent, " "Serpent Consulting Services Pvt. Ltd.," "Odoo Community Association (OCA)", diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index e7d6f1e9e3..ae6b39ddbf 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -48,4 +48,10 @@ def name_search(self, name='', args=None, operator='ilike', limit=100): def create(self, values): res = super(OperatingUnit, self).create(values) res.user_ids += self.env.user + self.clear_caches() return res + + @api.multi + def write(self, vals): + self.clear_caches() + return super(OperatingUnit, self).write(vals) From 9c306d43f73dec63653781dc57e9d80806feb7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Be=C3=B1at=20Jimenez?= Date: Wed, 30 Jan 2019 10:27:17 +0100 Subject: [PATCH 29/85] [FIX] Make company_id readonly to avoid crashes in multi-company environments --- operating_unit/models/operating_unit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/operating_unit/models/operating_unit.py b/operating_unit/models/operating_unit.py index ae6b39ddbf..66b01c3fee 100644 --- a/operating_unit/models/operating_unit.py +++ b/operating_unit/models/operating_unit.py @@ -14,7 +14,8 @@ class OperatingUnit(models.Model): code = fields.Char('Code', required=True) active = fields.Boolean('Active', default=True) company_id = fields.Many2one( - 'res.company', 'Company', required=True, default=lambda self: + 'res.company', 'Company', required=True, readonly=True, + default=lambda self: self.env['res.company']._company_default_get('account.account')) partner_id = fields.Many2one('res.partner', 'Partner', required=True) user_ids = fields.Many2many( From c44e4a64b83237de52b365ec1826b9d5221acb36 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 29 Jul 2019 03:23:48 +0000 Subject: [PATCH 30/85] [UPD] README.rst --- operating_unit/static/description/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operating_unit/static/description/index.html b/operating_unit/static/description/index.html index 96374801b0..72b16df98b 100644 --- a/operating_unit/static/description/index.html +++ b/operating_unit/static/description/index.html @@ -3,7 +3,7 @@ - + Operating Unit