{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/server-tools/pulls/comments/53477681","id":53477681,"diff_hunk":"@@ -0,0 +1,101 @@\n+# -*- coding: utf-8 -*-\n+# © 2015 Antiun Ingeniería S.L. - Sergio Teruel\n+# © 2015 Antiun Ingeniería S.L. - Carlos Dauden\n+# © 2015 Antiun Ingeniería S.L. - Jairo Llopis\n+# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html\n+\n+from openerp import api, fields, models\n+\n+\n+class CustomInfoTemplate(models.Model):\n+    \"\"\"Defines custom properties expected for a given database object.\"\"\"\n+    _name = \"custom.info.template\"\n+    _description = \"Custom information template\"\n+    _sql_constraints = [\n+        (\"name_model\",\n+         \"UNIQUE (name, model_id)\",\n+         \"Another template with that name exists for that model.\"),\n+    ]\n+\n+    name = fields.Char(translate=True)\n+    model_id = fields.Many2one(comodel_name='ir.model', string='Model')\n+    info_ids = fields.One2many(\n+        comodel_name='custom.info.property',\n+        inverse_name='template_id',\n+        string='Properties')\n+\n+\n+class CustomInfoProperty(models.Model):\n+    \"\"\"Name of the custom information property.\"\"\"\n+    _name = \"custom.info.property\"\n+    _description = \"Custom information property\"\n+    _sql_constraints = [\n+        (\"name_template\",\n+         \"UNIQUE (name, template_id)\",\n+         \"Another property with that name exists for that template.\"),\n+    ]\n+\n+    name = fields.Char(translate=True)\n+    template_id = fields.Many2one(\n+        comodel_name='custom.info.template',\n+        string='Template')\n+    info_value_ids = fields.One2many(\n+        comodel_name=\"custom.info.value\",\n+        inverse_name=\"property_id\",\n+        string=\"Property Values\")\n+\n+\n+class CustomInfoValue(models.Model):\n+    _name = \"custom.info.value\"\n+    _description = \"Custom information value\"\n+    _rec_name = 'value'\n+    _sql_constraints = [\n+        (\"property_model_res\",\n+         \"UNIQUE (property_id, model, res_id)\",\n+         \"Another property with that name exists for that resource.\"),\n+    ]\n+\n+    model = fields.Char(index=True, required=True)\n+    res_id = fields.Integer(\"Resource ID\", index=True, required=True)\n+    property_id = fields.Many2one(\n+        comodel_name='custom.info.property',\n+        required=True,\n+        string='Property')\n+    name = fields.Char(related='property_id.name')\n+    value = fields.Char(translate=True)\n+\n+\n+class CustomInfo(models.AbstractModel):\n+    _name = \"custom.info\"\n+    _description = \"Inheritable abstract model to add custom info in any model\"\n+\n+    custom_info_template_id = fields.Many2one(\n+        comodel_name='custom.info.template',\n+        string='Custom Information Template')\n+    custom_info_ids = fields.One2many(\n+        comodel_name='custom.info.value',\n+        inverse_name='res_id',\n+        domain=lambda self: [('model', '=', self._name)],\n+        auto_join=True,\n+        string='Custom Properties')\n+\n+    @api.onchange('custom_info_template_id')\n+    def _onchange_custom_info_template_id(self):\n+        if not self.custom_info_template_id:\n+            self.custom_info_ids = False\n+        else:\n+            info_list = self.custom_info_ids.mapped('property_id')\n+            for info_name in self.custom_info_template_id.info_ids:\n+                if info_name not in info_list:\n+                    self.custom_info_ids |= self.custom_info_ids.new({\n+                        'model': self._name,\n+                        'property_id': info_name.id,\n+                    })\n+\n+    @api.multi\n+    def unlink(self):\n+        info_values = self.mapped('custom_info_ids')","path":"base_custom_info/models/custom_info.py","position":121,"original_position":97,"commit_id":"be0981ad0202131ac499c4fa144cfe9b1018010f","original_commit_id":"256523933cec5c362210ca3f92a359848d7b0cad","user":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars.githubusercontent.com/u/7165771?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"body":"OK, I see. There's no other solution then.","created_at":"2016-02-19T15:54:06Z","updated_at":"2016-02-19T15:54:06Z","html_url":"https://github.com/OCA/server-tools/pull/313#discussion_r53477681","pull_request_url":"https://api.github.com/repos/OCA/server-tools/pulls/313","_links":{"self":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/comments/53477681"},"html":{"href":"https://github.com/OCA/server-tools/pull/313#discussion_r53477681"},"pull_request":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/313"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/server-tools/pulls/313","id":54005550,"html_url":"https://github.com/OCA/server-tools/pull/313","diff_url":"https://github.com/OCA/server-tools/pull/313.diff","patch_url":"https://github.com/OCA/server-tools/pull/313.patch","issue_url":"https://api.github.com/repos/OCA/server-tools/issues/313","number":313,"state":"open","locked":false,"title":"[8.0][base_custom_info] New module to have custom information associated to any model","user":{"login":"Yajo","id":973709,"avatar_url":"https://avatars.githubusercontent.com/u/973709?v=3","gravatar_id":"","url":"https://api.github.com/users/Yajo","html_url":"https://github.com/Yajo","followers_url":"https://api.github.com/users/Yajo/followers","following_url":"https://api.github.com/users/Yajo/following{/other_user}","gists_url":"https://api.github.com/users/Yajo/gists{/gist_id}","starred_url":"https://api.github.com/users/Yajo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yajo/subscriptions","organizations_url":"https://api.github.com/users/Yajo/orgs","repos_url":"https://api.github.com/users/Yajo/repos","events_url":"https://api.github.com/users/Yajo/events{/privacy}","received_events_url":"https://api.github.com/users/Yajo/received_events","type":"User","site_admin":false},"body":"This module does nothing by itself, so don't lose time doing functional reviews. It is the base module that was sent in https://github.com/OCA/product-attribute/pull/120#issuecomment-165512293.\r\n\r\nIt just adds a base to make other modules able to add a custom attribute list in any model with 2 LOC.\r\n\r\n@carlos-incaser @rafaelbn @pedrobaeza.","created_at":"2015-12-17T17:22:34Z","updated_at":"2016-02-19T15:54:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fb67f1a3ccc9458e7e0ed2fc3ae7764817439c1","assignee":null,"milestone":{"url":"https://api.github.com/repos/OCA/server-tools/milestones/3","html_url":"https://github.com/OCA/server-tools/milestones/8.0","labels_url":"https://api.github.com/repos/OCA/server-tools/milestones/3/labels","id":983662,"number":3,"title":"8.0","description":"","creator":{"login":"max3903","id":939952,"avatar_url":"https://avatars.githubusercontent.com/u/939952?v=3","gravatar_id":"","url":"https://api.github.com/users/max3903","html_url":"https://github.com/max3903","followers_url":"https://api.github.com/users/max3903/followers","following_url":"https://api.github.com/users/max3903/following{/other_user}","gists_url":"https://api.github.com/users/max3903/gists{/gist_id}","starred_url":"https://api.github.com/users/max3903/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/max3903/subscriptions","organizations_url":"https://api.github.com/users/max3903/orgs","repos_url":"https://api.github.com/users/max3903/repos","events_url":"https://api.github.com/users/max3903/events{/privacy}","received_events_url":"https://api.github.com/users/max3903/received_events","type":"User","site_admin":false},"open_issues":36,"closed_issues":49,"state":"open","created_at":"2015-02-17T21:52:00Z","updated_at":"2016-02-17T01:25:38Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/OCA/server-tools/pulls/313/commits","review_comments_url":"https://api.github.com/repos/OCA/server-tools/pulls/313/comments","review_comment_url":"https://api.github.com/repos/OCA/server-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/server-tools/issues/313/comments","statuses_url":"https://api.github.com/repos/OCA/server-tools/statuses/be0981ad0202131ac499c4fa144cfe9b1018010f","head":{"label":"Yajo:custom-info","ref":"custom-info","sha":"be0981ad0202131ac499c4fa144cfe9b1018010f","user":{"login":"Yajo","id":973709,"avatar_url":"https://avatars.githubusercontent.com/u/973709?v=3","gravatar_id":"","url":"https://api.github.com/users/Yajo","html_url":"https://github.com/Yajo","followers_url":"https://api.github.com/users/Yajo/followers","following_url":"https://api.github.com/users/Yajo/following{/other_user}","gists_url":"https://api.github.com/users/Yajo/gists{/gist_id}","starred_url":"https://api.github.com/users/Yajo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yajo/subscriptions","organizations_url":"https://api.github.com/users/Yajo/orgs","repos_url":"https://api.github.com/users/Yajo/repos","events_url":"https://api.github.com/users/Yajo/events{/privacy}","received_events_url":"https://api.github.com/users/Yajo/received_events","type":"User","site_admin":false},"repo":{"id":45119003,"name":"server-tools","full_name":"Yajo/server-tools","owner":{"login":"Yajo","id":973709,"avatar_url":"https://avatars.githubusercontent.com/u/973709?v=3","gravatar_id":"","url":"https://api.github.com/users/Yajo","html_url":"https://github.com/Yajo","followers_url":"https://api.github.com/users/Yajo/followers","following_url":"https://api.github.com/users/Yajo/following{/other_user}","gists_url":"https://api.github.com/users/Yajo/gists{/gist_id}","starred_url":"https://api.github.com/users/Yajo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yajo/subscriptions","organizations_url":"https://api.github.com/users/Yajo/orgs","repos_url":"https://api.github.com/users/Yajo/repos","events_url":"https://api.github.com/users/Yajo/events{/privacy}","received_events_url":"https://api.github.com/users/Yajo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Yajo/server-tools","description":"Tools for Odoo Administrators to improve some technical features on Odoo.","fork":true,"url":"https://api.github.com/repos/Yajo/server-tools","forks_url":"https://api.github.com/repos/Yajo/server-tools/forks","keys_url":"https://api.github.com/repos/Yajo/server-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yajo/server-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yajo/server-tools/teams","hooks_url":"https://api.github.com/repos/Yajo/server-tools/hooks","issue_events_url":"https://api.github.com/repos/Yajo/server-tools/issues/events{/number}","events_url":"https://api.github.com/repos/Yajo/server-tools/events","assignees_url":"https://api.github.com/repos/Yajo/server-tools/assignees{/user}","branches_url":"https://api.github.com/repos/Yajo/server-tools/branches{/branch}","tags_url":"https://api.github.com/repos/Yajo/server-tools/tags","blobs_url":"https://api.github.com/repos/Yajo/server-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yajo/server-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yajo/server-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yajo/server-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yajo/server-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/Yajo/server-tools/languages","stargazers_url":"https://api.github.com/repos/Yajo/server-tools/stargazers","contributors_url":"https://api.github.com/repos/Yajo/server-tools/contributors","subscribers_url":"https://api.github.com/repos/Yajo/server-tools/subscribers","subscription_url":"https://api.github.com/repos/Yajo/server-tools/subscription","commits_url":"https://api.github.com/repos/Yajo/server-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yajo/server-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yajo/server-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yajo/server-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yajo/server-tools/contents/{+path}","compare_url":"https://api.github.com/repos/Yajo/server-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yajo/server-tools/merges","archive_url":"https://api.github.com/repos/Yajo/server-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yajo/server-tools/downloads","issues_url":"https://api.github.com/repos/Yajo/server-tools/issues{/number}","pulls_url":"https://api.github.com/repos/Yajo/server-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/Yajo/server-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/Yajo/server-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yajo/server-tools/labels{/name}","releases_url":"https://api.github.com/repos/Yajo/server-tools/releases{/id}","deployments_url":"https://api.github.com/repos/Yajo/server-tools/deployments","created_at":"2015-10-28T14:43:19Z","updated_at":"2015-10-28T14:43:21Z","pushed_at":"2016-02-18T10:25:13Z","git_url":"git://github.com/Yajo/server-tools.git","ssh_url":"git@github.com:Yajo/server-tools.git","clone_url":"https://github.com/Yajo/server-tools.git","svn_url":"https://github.com/Yajo/server-tools","homepage":"https://community.odoo.com/project/30","size":2709,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"9.0"}},"base":{"label":"OCA:8.0","ref":"8.0","sha":"a723a6596af8290cb4e4870d5006d49170e7a848","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"repo":{"id":20896532,"name":"server-tools","full_name":"OCA/server-tools","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OCA/server-tools","description":"Tools for Odoo Administrators to improve some technical features on Odoo.","fork":false,"url":"https://api.github.com/repos/OCA/server-tools","forks_url":"https://api.github.com/repos/OCA/server-tools/forks","keys_url":"https://api.github.com/repos/OCA/server-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/server-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/server-tools/teams","hooks_url":"https://api.github.com/repos/OCA/server-tools/hooks","issue_events_url":"https://api.github.com/repos/OCA/server-tools/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/server-tools/events","assignees_url":"https://api.github.com/repos/OCA/server-tools/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/server-tools/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/server-tools/tags","blobs_url":"https://api.github.com/repos/OCA/server-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/server-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/server-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/server-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/server-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/server-tools/languages","stargazers_url":"https://api.github.com/repos/OCA/server-tools/stargazers","contributors_url":"https://api.github.com/repos/OCA/server-tools/contributors","subscribers_url":"https://api.github.com/repos/OCA/server-tools/subscribers","subscription_url":"https://api.github.com/repos/OCA/server-tools/subscription","commits_url":"https://api.github.com/repos/OCA/server-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/server-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/server-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/server-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/server-tools/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/server-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/server-tools/merges","archive_url":"https://api.github.com/repos/OCA/server-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/server-tools/downloads","issues_url":"https://api.github.com/repos/OCA/server-tools/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/server-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/server-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/server-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/server-tools/labels{/name}","releases_url":"https://api.github.com/repos/OCA/server-tools/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/server-tools/deployments","created_at":"2014-06-16T18:52:44Z","updated_at":"2016-02-16T10:16:34Z","pushed_at":"2016-02-18T10:25:14Z","git_url":"git://github.com/OCA/server-tools.git","ssh_url":"git@github.com:OCA/server-tools.git","clone_url":"https://github.com/OCA/server-tools.git","svn_url":"https://github.com/OCA/server-tools","homepage":"https://odoo-community.org/project/tools-maintainers-30","size":8730,"stargazers_count":90,"watchers_count":90,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":253,"mirror_url":null,"open_issues_count":97,"forks":253,"open_issues":97,"watchers":90,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/313"},"html":{"href":"https://github.com/OCA/server-tools/pull/313"},"issue":{"href":"https://api.github.com/repos/OCA/server-tools/issues/313"},"comments":{"href":"https://api.github.com/repos/OCA/server-tools/issues/313/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/313/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/server-tools/pulls/313/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/server-tools/statuses/be0981ad0202131ac499c4fa144cfe9b1018010f"}}}}