{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/product-attribute/pulls/comments/43399595","id":43399595,"diff_hunk":"@@ -0,0 +1,84 @@\n+# -*- encoding: utf-8 -*-\n+##############################################################################\n+#\n+#    OpenERP, Odoo Source Management Solution\n+#    Copyright (c) 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)\n+#                       Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>\n+#\n+#    This program is free software: you can redistribute it and/or modify\n+#    it under the terms of the GNU Affero General Public License as published\n+#    by the Free Software Foundation, either version 3 of the License, or\n+#    (at your option) any later version.\n+#\n+#    This program is distributed in the hope that it will be useful,\n+#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+#    GNU Affero General Public License for more details.\n+#\n+#    You should have received a copy of the GNU Affero General Public License\n+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+#\n+##############################################################################\n+import logging\n+from openerp import models, fields, api, _\n+\n+_logger = logging.getLogger(__name__)\n+\n+\n+class ProductProduct(models.Model):\n+    _inherit = \"product.template\"\n+\n+    @api.one\n+    @api.depends('image_ids')\n+    def _get_main_image(self):\n+        self.product_image = False\n+        self.image_medium = False\n+        self.image_small = False\n+        if self.image_ids:\n+            self.product_image = self.image_ids[0].image\n+            self.image_medium = self.image_ids[0].image_medium\n+            self.image_small = self.image_ids[0].image_small\n+\n+    def _set_image(self, image):\n+        if self.image:\n+            if self.image_ids:\n+                self.image_ids[0].write({'type': 'db',\n+                                         'file_db_store': image})\n+            else:\n+                self.image_ids = [(0, 0, {'type': 'db',\n+                                          'file_db_store': image,\n+                                          'name': _('Main image')})]\n+        elif self.image_ids:\n+            self.image_ids[0].unlink()\n+\n+    @api.one\n+    def _set_main_image(self):\n+        self._set_image(self.product_image)\n+\n+    @api.one\n+    def _set_main_image_medium(self):\n+        self._set_image(self.image_medium)\n+\n+    @api.one\n+    def _set_main_image_small(self):\n+        self._set_image(self.image_small)\n+\n+    image_ids = fields.One2many(\n+        comodel_name='product.image', inverse_name='product_id',\n+        string='Product images', copy=True)\n+    product_image = fields.Binary(\n+        string=\"Main image\", compute=\"_get_main_image\", store=False,\n+        inverse=\"_set_main_image\")\n+    image_medium = fields.Binary(\n+        compute=\"_get_main_image\", inverse=\"_set_main_image_medium\",\n+        store=False)\n+    image_small = fields.Binary(\n+        compute=\"_get_main_image\", inverse=\"_set_main_image_small\",","path":"product_multi_image/models/product_product.py","position":76,"original_position":76,"commit_id":"f5dc1062f61346e097d9f0b97c46e551e9274029","original_commit_id":"f5dc1062f61346e097d9f0b97c46e551e9274029","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":"Why different inverse methods that all do the same?","created_at":"2015-10-29T15:26:43Z","updated_at":"2015-10-29T15:26:43Z","html_url":"https://github.com/OCA/product-attribute/pull/57#discussion_r43399595","pull_request_url":"https://api.github.com/repos/OCA/product-attribute/pulls/57","_links":{"self":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/comments/43399595"},"html":{"href":"https://github.com/OCA/product-attribute/pull/57#discussion_r43399595"},"pull_request":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/57"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/product-attribute/pulls/57","id":31015137,"html_url":"https://github.com/OCA/product-attribute/pull/57","diff_url":"https://github.com/OCA/product-attribute/pull/57.diff","patch_url":"https://github.com/OCA/product-attribute/pull/57.patch","issue_url":"https://api.github.com/repos/OCA/product-attribute/issues/57","number":57,"state":"open","locked":false,"title":"[WIP] [MIG] product_multi_image: Module totally redone from old product_images","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":"This is still a work in progress.\r\n\r\nRefactorized:\r\n* Take into account templates and products\r\n* Code for creating and updating\r\n* Views\r\n* All!\r\n\r\nNew planned features:\r\n* Three possible sources: URL, file or DB.\r\n* Possibility to share images between different products.\r\n* New kanban view\r\n* Others not yet thought.","created_at":"2015-03-12T08:10:25Z","updated_at":"2015-10-29T15:26:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ce4a74f9f426b33fa57d7b21ebed3632cce4fb4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/product-attribute/pulls/57/commits","review_comments_url":"https://api.github.com/repos/OCA/product-attribute/pulls/57/comments","review_comment_url":"https://api.github.com/repos/OCA/product-attribute/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/product-attribute/issues/57/comments","statuses_url":"https://api.github.com/repos/OCA/product-attribute/statuses/f5dc1062f61346e097d9f0b97c46e551e9274029","head":{"label":"pedrobaeza:8.0-product_images","ref":"8.0-product_images","sha":"f5dc1062f61346e097d9f0b97c46e551e9274029","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},"repo":{"id":25539659,"name":"product-attribute","full_name":"pedrobaeza/product-attribute","owner":{"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},"private":false,"html_url":"https://github.com/pedrobaeza/product-attribute","description":"","fork":true,"url":"https://api.github.com/repos/pedrobaeza/product-attribute","forks_url":"https://api.github.com/repos/pedrobaeza/product-attribute/forks","keys_url":"https://api.github.com/repos/pedrobaeza/product-attribute/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pedrobaeza/product-attribute/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pedrobaeza/product-attribute/teams","hooks_url":"https://api.github.com/repos/pedrobaeza/product-attribute/hooks","issue_events_url":"https://api.github.com/repos/pedrobaeza/product-attribute/issues/events{/number}","events_url":"https://api.github.com/repos/pedrobaeza/product-attribute/events","assignees_url":"https://api.github.com/repos/pedrobaeza/product-attribute/assignees{/user}","branches_url":"https://api.github.com/repos/pedrobaeza/product-attribute/branches{/branch}","tags_url":"https://api.github.com/repos/pedrobaeza/product-attribute/tags","blobs_url":"https://api.github.com/repos/pedrobaeza/product-attribute/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pedrobaeza/product-attribute/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pedrobaeza/product-attribute/git/refs{/sha}","trees_url":"https://api.github.com/repos/pedrobaeza/product-attribute/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pedrobaeza/product-attribute/statuses/{sha}","languages_url":"https://api.github.com/repos/pedrobaeza/product-attribute/languages","stargazers_url":"https://api.github.com/repos/pedrobaeza/product-attribute/stargazers","contributors_url":"https://api.github.com/repos/pedrobaeza/product-attribute/contributors","subscribers_url":"https://api.github.com/repos/pedrobaeza/product-attribute/subscribers","subscription_url":"https://api.github.com/repos/pedrobaeza/product-attribute/subscription","commits_url":"https://api.github.com/repos/pedrobaeza/product-attribute/commits{/sha}","git_commits_url":"https://api.github.com/repos/pedrobaeza/product-attribute/git/commits{/sha}","comments_url":"https://api.github.com/repos/pedrobaeza/product-attribute/comments{/number}","issue_comment_url":"https://api.github.com/repos/pedrobaeza/product-attribute/issues/comments{/number}","contents_url":"https://api.github.com/repos/pedrobaeza/product-attribute/contents/{+path}","compare_url":"https://api.github.com/repos/pedrobaeza/product-attribute/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pedrobaeza/product-attribute/merges","archive_url":"https://api.github.com/repos/pedrobaeza/product-attribute/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pedrobaeza/product-attribute/downloads","issues_url":"https://api.github.com/repos/pedrobaeza/product-attribute/issues{/number}","pulls_url":"https://api.github.com/repos/pedrobaeza/product-attribute/pulls{/number}","milestones_url":"https://api.github.com/repos/pedrobaeza/product-attribute/milestones{/number}","notifications_url":"https://api.github.com/repos/pedrobaeza/product-attribute/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pedrobaeza/product-attribute/labels{/name}","releases_url":"https://api.github.com/repos/pedrobaeza/product-attribute/releases{/id}","created_at":"2014-10-21T18:46:33Z","updated_at":"2015-09-13T19:59:57Z","pushed_at":"2015-09-15T08:52:28Z","git_url":"git://github.com/pedrobaeza/product-attribute.git","ssh_url":"git@github.com:pedrobaeza/product-attribute.git","clone_url":"https://github.com/pedrobaeza/product-attribute.git","svn_url":"https://github.com/pedrobaeza/product-attribute","homepage":null,"size":2431,"stargazers_count":2,"watchers_count":2,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":2,"default_branch":"8.0"}},"base":{"label":"OCA:8.0","ref":"8.0","sha":"a520b859f294dbb5f43c9c6398ff0602255c767e","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":20894654,"name":"product-attribute","full_name":"OCA/product-attribute","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/product-attribute","description":"Odoo Product Attribute","fork":false,"url":"https://api.github.com/repos/OCA/product-attribute","forks_url":"https://api.github.com/repos/OCA/product-attribute/forks","keys_url":"https://api.github.com/repos/OCA/product-attribute/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/product-attribute/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/product-attribute/teams","hooks_url":"https://api.github.com/repos/OCA/product-attribute/hooks","issue_events_url":"https://api.github.com/repos/OCA/product-attribute/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/product-attribute/events","assignees_url":"https://api.github.com/repos/OCA/product-attribute/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/product-attribute/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/product-attribute/tags","blobs_url":"https://api.github.com/repos/OCA/product-attribute/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/product-attribute/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/product-attribute/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/product-attribute/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/product-attribute/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/product-attribute/languages","stargazers_url":"https://api.github.com/repos/OCA/product-attribute/stargazers","contributors_url":"https://api.github.com/repos/OCA/product-attribute/contributors","subscribers_url":"https://api.github.com/repos/OCA/product-attribute/subscribers","subscription_url":"https://api.github.com/repos/OCA/product-attribute/subscription","commits_url":"https://api.github.com/repos/OCA/product-attribute/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/product-attribute/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/product-attribute/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/product-attribute/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/product-attribute/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/product-attribute/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/product-attribute/merges","archive_url":"https://api.github.com/repos/OCA/product-attribute/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/product-attribute/downloads","issues_url":"https://api.github.com/repos/OCA/product-attribute/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/product-attribute/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/product-attribute/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/product-attribute/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/product-attribute/labels{/name}","releases_url":"https://api.github.com/repos/OCA/product-attribute/releases{/id}","created_at":"2014-06-16T17:57:41Z","updated_at":"2015-09-12T14:10:46Z","pushed_at":"2015-10-29T08:07:20Z","git_url":"git://github.com/OCA/product-attribute.git","ssh_url":"git@github.com:OCA/product-attribute.git","clone_url":"https://github.com/OCA/product-attribute.git","svn_url":"https://github.com/OCA/product-attribute","homepage":"","size":5729,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":37,"forks":104,"open_issues":37,"watchers":16,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/57"},"html":{"href":"https://github.com/OCA/product-attribute/pull/57"},"issue":{"href":"https://api.github.com/repos/OCA/product-attribute/issues/57"},"comments":{"href":"https://api.github.com/repos/OCA/product-attribute/issues/57/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/57/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/57/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/product-attribute/statuses/f5dc1062f61346e097d9f0b97c46e551e9274029"}}}}