{ "info": { "author": "Therp BV,Odoo Community Association (OCA)", "author_email": "support@odoo-community.org", "bugtrack_url": null, "classifiers": [ "Framework :: Odoo", "License :: OSI Approved :: GNU Affero General Public License v3", "Programming Language :: Python" ], "description": ".. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg\n :alt: License: AGPL-3\n\n=====================\nRestrict field access\n=====================\n\nThis module was written to help developers restricting access to fields in a\nsecure and flexible manner on record level.\n\nIf you're not a developer, this module is not for you as you need to write code\nin order to actually use it.\n\nUsage\n=====\n\nTo use this module, you need to inherit this mixin for the model whose fields\nyou want to restrict, and implement at least the following methods to do\nsomething useful:\n\n.. code:: python\n\n class ResPartner(models.Model):\n # inherit from the mixin\n _inherit = ['restrict.field.access.mixin', 'res.partner']\n _name = 'res.partner'\n\n @api.multi\n def _restrict_field_access_get_field_whitelist(self, action='read'):\n # return a whitelist (or a blacklist) of fields, depending on the\n # action passed\n whitelist = [\n 'name', 'parent_id', 'is_company', 'firstname', 'lastname',\n 'infix', 'initials',\n ] + super(ResPartner, self)\\\n ._restrict_field_access_get_field_whitelist(action=action)\n if action == 'read':\n whitelist.extend(['section_id', 'user_id'])\n return whitelist\n\n @api.multi\n def _restrict_field_access_is_field_accessible(self, field_name,\n action='read'):\n # in case the whitelist is not enough, you can also decide for\n # specific records if an action can be carried out on it or not\n result = super(ResPartner, self)\\\n ._restrict_field_access_is_field_accessible(\n field_name, action=action)\n if result or not self:\n return result\n return all(this.section_id in self.env.user.section_ids or\n this.user_id == self.env.user\n for this in self)\n\n @api.multi\n @api.onchange('section_id', 'user_id')\n @api.depends('section_id', 'user_id')\n def _compute_restrict_field_access(self):\n # if your decision depends on other fields, you probably need to\n # override this function in order to attach the correct onchange/\n # depends decorators\n return super(ResPartner, self)._compute_restrict_field_access()\n\n @api.model\n def _restrict_field_access_inject_restrict_field_access_domain(\n self, domain):\n # you also might want to decide with a domain expression which\n # records are visible in the first place\n domain[:] = expression.AND([\n domain,\n [\n '|',\n ('section_id', 'in', self.env.user.section_ids.ids),\n ('user_id', '=', self.env.user.id),\n ],\n ])\n\nThe example code here will allow only reading a few fields for partners of\nwhich the current user is neither the sales person nor in this partner's sales\nteam.\n\nRead the comments of the mixin, that's part of the documentation. Also have a\nlook at the tests, that's another example on how to use this code.\n\nFor further information, please visit:\n\n* https://www.odoo.com/forum/help-1\n\nKnown issues / Roadmap\n======================\n\n* the code contains some TODOs which should be done\n\nBug Tracker\n===========\n\nBugs are tracked on `GitHub Issues `_.\nIn case of trouble, please check there if your issue has already been reported.\nIf you spotted it first, help us smashing it by providing a detailed and welcomed feedback\n`here `_.\n\nCredits\n=======\n\nContributors\n------------\n\n* Holger Brunn \n\nMaintainer\n----------\n\n.. image:: https://odoo-community.org/logo.png\n :alt: Odoo Community Association\n :target: https://odoo-community.org\n\nThis module is maintained by the OCA.\n\nOCA, or the Odoo Community Association, is a nonprofit organization whose\nmission is to support the collaborative development of Odoo features and\npromote its widespread use.\n\nTo contribute to this module, please visit https://odoo-community.org.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "AGPL-3", "maintainer": "", "maintainer_email": "", "name": "odoo8-addon-base-mixin-restrict-field-access", "package_url": "https://pypi.org/project/odoo8-addon-base-mixin-restrict-field-access/", "platform": "", "project_url": "https://pypi.org/project/odoo8-addon-base-mixin-restrict-field-access/", "project_urls": null, "release_url": "https://pypi.org/project/odoo8-addon-base-mixin-restrict-field-access/8.0.1.0.0.99.dev7/", "requires_dist": [ "odoo (<9.0a,>=8.0a)", "odoo8-addon-base-suspend-security" ], "requires_python": "~=2.7", "summary": "Make it simple to restrict read and/or write access to certain fields base on some condition", "version": "8.0.1.0.0.99.dev7" }, "last_serial": 3998847, "releases": { "8.0.1.0.0.99.dev3": [ { "comment_text": "", "digests": { "md5": "e47401471ced7b4d727114933dece5f5", "sha256": "bbf4cb8943fd42850bbe1a0828425ed0c1f95a886d6cde6f0aefc17cfa989d67" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev3-py2-none-any.whl", "has_sig": false, "md5_digest": "e47401471ced7b4d727114933dece5f5", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 27085, "upload_time": "2017-09-29T04:30:26", "url": "https://files.pythonhosted.org/packages/3e/74/6022f9fd8d6cce327fb3db3ecde8feec7b08913a0df0a6ae1d702655238f/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev3-py2-none-any.whl" } ], "8.0.1.0.0.99.dev4": [ { "comment_text": "", "digests": { "md5": "3eebd9be7a1c6e00c9d850b2fbe356f5", "sha256": "36dec187099f886a0cdc65ef263c4f9d859cda537c713f8f6b24880c28c7d11c" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev4-py2-none-any.whl", "has_sig": false, "md5_digest": "3eebd9be7a1c6e00c9d850b2fbe356f5", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": "~=2.7", "size": 26058, "upload_time": "2017-10-18T04:30:21", "url": "https://files.pythonhosted.org/packages/17/58/fdac221da1205404b6f42ea0c4b5586506d245cfbab7cd26d51bbdeebb65/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev4-py2-none-any.whl" } ], "8.0.1.0.0.99.dev5": [ { "comment_text": "", "digests": { "md5": "1654f476b5aba0ec96e79a58dac7be1e", "sha256": "427d511d8298ce25e42d0d3faf1a32ca2e173ff6cfa0579e0c96f9bacad10243" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev5-py2-none-any.whl", "has_sig": false, "md5_digest": "1654f476b5aba0ec96e79a58dac7be1e", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": "~=2.7", "size": 84803, "upload_time": "2017-10-29T05:30:45", "url": "https://files.pythonhosted.org/packages/7e/23/283d0540fc297d8ee66097153af5114bc5d8f359a6563d0ff8ba4fd05350/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev5-py2-none-any.whl" } ], "8.0.1.0.0.99.dev6": [ { "comment_text": "", "digests": { "md5": "188723238900bfa6f02ac50b0c5f66a9", "sha256": "b7ad372d5d7cedaacb1bf1811ffa178fd2c186d6442ea2a0e14c78fa31589382" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev6-py2-none-any.whl", "has_sig": false, "md5_digest": "188723238900bfa6f02ac50b0c5f66a9", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": "~=2.7", "size": 85635, "upload_time": "2018-03-04T05:46:06", "url": "https://files.pythonhosted.org/packages/48/18/4bba6bda17c9357630ca0a7748269c9747611b3bcbb1d65f2fb5a6569d04/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev6-py2-none-any.whl" } ], "8.0.1.0.0.99.dev7": [ { "comment_text": "", "digests": { "md5": "0494d241643abb9aa24d81db995543fa", "sha256": "0692dc69a12acce7b159f4e6ff169b69b4bfa595f9055f5734e04b797ac49da9" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev7-py2-none-any.whl", "has_sig": false, "md5_digest": "0494d241643abb9aa24d81db995543fa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": "~=2.7", "size": 86281, "upload_time": "2018-06-25T04:53:16", "url": "https://files.pythonhosted.org/packages/d3/b6/7f31046a2dbf17953d16f1e93e2ee2e550855051c860882cc57ce625c189/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev7-py2-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0494d241643abb9aa24d81db995543fa", "sha256": "0692dc69a12acce7b159f4e6ff169b69b4bfa595f9055f5734e04b797ac49da9" }, "downloads": -1, "filename": "odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev7-py2-none-any.whl", "has_sig": false, "md5_digest": "0494d241643abb9aa24d81db995543fa", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": "~=2.7", "size": 86281, "upload_time": "2018-06-25T04:53:16", "url": "https://files.pythonhosted.org/packages/d3/b6/7f31046a2dbf17953d16f1e93e2ee2e550855051c860882cc57ce625c189/odoo8_addon_base_mixin_restrict_field_access-8.0.1.0.0.99.dev7-py2-none-any.whl" } ] }