{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/apps-store/pulls/comments/142464229","pull_request_review_id":66825809,"id":142464229,"diff_hunk":"@@ -0,0 +1,107 @@\n+# -*- coding: utf-8 -*-\n+\n+import os\n+import tempfile\n+import shutil\n+import logging\n+import base64\n+import subprocess\n+import time\n+from odoo.exceptions import ValidationError\n+from odoo import models, fields, api, _\n+_logger = logging.getLogger(__name__)\n+\n+\n+class ProductProduct(models.Model):\n+    _inherit = 'product.product'\n+\n+    dependent_product_ids = fields.Many2many(\n+        'product.product', 'prto_validateoduct_dependent_rel',\n+        'src_id', 'dest_id', string='Dependent Products'\n+    )\n+    module_path = fields.Char('Module Path')\n+\n+    @api.constrains('dependent_product_ids')\n+    def check_dependent_recursion(self):\n+        for product in self:\n+            def child_dependency_check(product_dependent_ids, children):\n+                res = self.env['product.product']\n+                for child in children:\n+                    if not child.dependent_product_ids:\n+                        continue\n+                    if child in product_dependent_ids:\n+                        raise ValidationError(\n+                            _('Error: You cannot create recursive dependency.')\n+                        )\n+                    product_dependent_ids += child\n+                    child_dependency_check(product_dependent_ids,\n+                                           child.dependent_product_ids)\n+                return res\n+\n+            child_dependency_check(product, product.dependent_product_ids)\n+\n+    @api.multi\n+    def create_dependency_list(self):\n+        ret_val = {}\n+\n+        def child_dependency(children):\n+            res = self.env['product.product']\n+            for child in children:\n+                if not child.dependent_product_ids:\n+                    continue\n+                res += child.dependent_product_ids\n+                res += child_dependency(child.dependent_product_ids)\n+            return res\n+        for product in self:\n+            ret_val[product.id] = product.dependent_product_ids\n+            if product.dependent_product_ids:\n+                ret_val[product.id] += child_dependency(\n+                    product.dependent_product_ids)\n+        return ret_val\n+\n+    @api.multi\n+    def generate_zip_file(self):\n+        for product in self:\n+            if not product.module_path:\n+                continue\n+            tmpdir = tempfile.mkdtemp()\n+            tmpdir2 = tempfile.mkdtemp()\n+            dependent_product_ids = product.create_dependency_list(\n+                )[product.id]\n+            for dependent_product in dependent_product_ids:\n+                if not dependent_product.module_path:\n+                    continue\n+                subprocess.Popen(['cp', '-r', dependent_product.module_path,\n+                                  tmpdir], stdout=subprocess.PIPE)\n+            subprocess.Popen(['cp', '-r', product.module_path, tmpdir],\n+                             stdout=subprocess.PIPE)\n+            time_value = time.strftime(\n+                '_%y%m%d_%H%M%S')\n+\n+            tmpzipfile = os.path.join(tmpdir2, product.name) + time_value\n+            shutil.make_archive(tmpzipfile, 'zip', tmpdir)\n+            tmpzipfile = tmpzipfile + '.zip'","path":"apps_download/models/product_product.py","position":83,"original_position":83,"commit_id":"60b92321152d20047acb44e7f7e69f2f53bfd896","original_commit_id":"60b92321152d20047acb44e7f7e69f2f53bfd896","user":{"login":"lasley","id":7397578,"avatar_url":"https://avatars3.githubusercontent.com/u/7397578?v=4","gravatar_id":"","url":"https://api.github.com/users/lasley","html_url":"https://github.com/lasley","followers_url":"https://api.github.com/users/lasley/followers","following_url":"https://api.github.com/users/lasley/following{/other_user}","gists_url":"https://api.github.com/users/lasley/gists{/gist_id}","starred_url":"https://api.github.com/users/lasley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lasley/subscriptions","organizations_url":"https://api.github.com/users/lasley/orgs","repos_url":"https://api.github.com/users/lasley/repos","events_url":"https://api.github.com/users/lasley/events{/privacy}","received_events_url":"https://api.github.com/users/lasley/received_events","type":"User","site_admin":false},"body":"Please use variable interpolation instead of concatenation. It's more efficient and less error prone\r\n\r\n```\r\ntmp_zip_file = '%s.zip' % tmp_zip_file\r\n```","created_at":"2017-10-03T17:13:34Z","updated_at":"2017-10-03T17:20:01Z","html_url":"https://github.com/OCA/apps-store/pull/3#discussion_r142464229","pull_request_url":"https://api.github.com/repos/OCA/apps-store/pulls/3","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/comments/142464229"},"html":{"href":"https://github.com/OCA/apps-store/pull/3#discussion_r142464229"},"pull_request":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/apps-store/pulls/3","id":144403759,"html_url":"https://github.com/OCA/apps-store/pull/3","diff_url":"https://github.com/OCA/apps-store/pull/3.diff","patch_url":"https://github.com/OCA/apps-store/pull/3.patch","issue_url":"https://api.github.com/repos/OCA/apps-store/issues/3","number":3,"state":"open","locked":false,"title":"Added facility for the apps Download","user":{"login":"bizzappdev","id":4273984,"avatar_url":"https://avatars0.githubusercontent.com/u/4273984?v=4","gravatar_id":"","url":"https://api.github.com/users/bizzappdev","html_url":"https://github.com/bizzappdev","followers_url":"https://api.github.com/users/bizzappdev/followers","following_url":"https://api.github.com/users/bizzappdev/following{/other_user}","gists_url":"https://api.github.com/users/bizzappdev/gists{/gist_id}","starred_url":"https://api.github.com/users/bizzappdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizzappdev/subscriptions","organizations_url":"https://api.github.com/users/bizzappdev/orgs","repos_url":"https://api.github.com/users/bizzappdev/repos","events_url":"https://api.github.com/users/bizzappdev/events{/privacy}","received_events_url":"https://api.github.com/users/bizzappdev/received_events","type":"User","site_admin":false},"body":"Module is providing facility for maintaining module dependency and creating zip file ","created_at":"2017-10-03T12:01:39Z","updated_at":"2017-10-03T17:20:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b716f3314cd085a4b7a529c2d4ee8ae215778a54","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/OCA/apps-store/pulls/3/commits","review_comments_url":"https://api.github.com/repos/OCA/apps-store/pulls/3/comments","review_comment_url":"https://api.github.com/repos/OCA/apps-store/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/apps-store/issues/3/comments","statuses_url":"https://api.github.com/repos/OCA/apps-store/statuses/60b92321152d20047acb44e7f7e69f2f53bfd896","head":{"label":"bizzappdev:oca_code_sprint","ref":"oca_code_sprint","sha":"60b92321152d20047acb44e7f7e69f2f53bfd896","user":{"login":"bizzappdev","id":4273984,"avatar_url":"https://avatars0.githubusercontent.com/u/4273984?v=4","gravatar_id":"","url":"https://api.github.com/users/bizzappdev","html_url":"https://github.com/bizzappdev","followers_url":"https://api.github.com/users/bizzappdev/followers","following_url":"https://api.github.com/users/bizzappdev/following{/other_user}","gists_url":"https://api.github.com/users/bizzappdev/gists{/gist_id}","starred_url":"https://api.github.com/users/bizzappdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizzappdev/subscriptions","organizations_url":"https://api.github.com/users/bizzappdev/orgs","repos_url":"https://api.github.com/users/bizzappdev/repos","events_url":"https://api.github.com/users/bizzappdev/events{/privacy}","received_events_url":"https://api.github.com/users/bizzappdev/received_events","type":"User","site_admin":false},"repo":{"id":105533472,"name":"apps-store","full_name":"bizzappdev/apps-store","owner":{"login":"bizzappdev","id":4273984,"avatar_url":"https://avatars0.githubusercontent.com/u/4273984?v=4","gravatar_id":"","url":"https://api.github.com/users/bizzappdev","html_url":"https://github.com/bizzappdev","followers_url":"https://api.github.com/users/bizzappdev/followers","following_url":"https://api.github.com/users/bizzappdev/following{/other_user}","gists_url":"https://api.github.com/users/bizzappdev/gists{/gist_id}","starred_url":"https://api.github.com/users/bizzappdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bizzappdev/subscriptions","organizations_url":"https://api.github.com/users/bizzappdev/orgs","repos_url":"https://api.github.com/users/bizzappdev/repos","events_url":"https://api.github.com/users/bizzappdev/events{/privacy}","received_events_url":"https://api.github.com/users/bizzappdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bizzappdev/apps-store","description":"OCA Apps store module repository","fork":true,"url":"https://api.github.com/repos/bizzappdev/apps-store","forks_url":"https://api.github.com/repos/bizzappdev/apps-store/forks","keys_url":"https://api.github.com/repos/bizzappdev/apps-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bizzappdev/apps-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bizzappdev/apps-store/teams","hooks_url":"https://api.github.com/repos/bizzappdev/apps-store/hooks","issue_events_url":"https://api.github.com/repos/bizzappdev/apps-store/issues/events{/number}","events_url":"https://api.github.com/repos/bizzappdev/apps-store/events","assignees_url":"https://api.github.com/repos/bizzappdev/apps-store/assignees{/user}","branches_url":"https://api.github.com/repos/bizzappdev/apps-store/branches{/branch}","tags_url":"https://api.github.com/repos/bizzappdev/apps-store/tags","blobs_url":"https://api.github.com/repos/bizzappdev/apps-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bizzappdev/apps-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bizzappdev/apps-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/bizzappdev/apps-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bizzappdev/apps-store/statuses/{sha}","languages_url":"https://api.github.com/repos/bizzappdev/apps-store/languages","stargazers_url":"https://api.github.com/repos/bizzappdev/apps-store/stargazers","contributors_url":"https://api.github.com/repos/bizzappdev/apps-store/contributors","subscribers_url":"https://api.github.com/repos/bizzappdev/apps-store/subscribers","subscription_url":"https://api.github.com/repos/bizzappdev/apps-store/subscription","commits_url":"https://api.github.com/repos/bizzappdev/apps-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/bizzappdev/apps-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/bizzappdev/apps-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/bizzappdev/apps-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/bizzappdev/apps-store/contents/{+path}","compare_url":"https://api.github.com/repos/bizzappdev/apps-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bizzappdev/apps-store/merges","archive_url":"https://api.github.com/repos/bizzappdev/apps-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bizzappdev/apps-store/downloads","issues_url":"https://api.github.com/repos/bizzappdev/apps-store/issues{/number}","pulls_url":"https://api.github.com/repos/bizzappdev/apps-store/pulls{/number}","milestones_url":"https://api.github.com/repos/bizzappdev/apps-store/milestones{/number}","notifications_url":"https://api.github.com/repos/bizzappdev/apps-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bizzappdev/apps-store/labels{/name}","releases_url":"https://api.github.com/repos/bizzappdev/apps-store/releases{/id}","deployments_url":"https://api.github.com/repos/bizzappdev/apps-store/deployments","created_at":"2017-10-02T12:48:50Z","updated_at":"2017-10-03T12:23:57Z","pushed_at":"2017-10-03T16:58:01Z","git_url":"git://github.com/bizzappdev/apps-store.git","ssh_url":"git@github.com:bizzappdev/apps-store.git","clone_url":"https://github.com/bizzappdev/apps-store.git","svn_url":"https://github.com/bizzappdev/apps-store","homepage":null,"size":39,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"10.0"}},"base":{"label":"OCA:10.0","ref":"10.0","sha":"6e032a39f4d755a6866d212ee9449fc6383bd985","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars1.githubusercontent.com/u/7600578?v=4","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":105530654,"name":"apps-store","full_name":"OCA/apps-store","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars1.githubusercontent.com/u/7600578?v=4","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/apps-store","description":"OCA Apps store module repository","fork":false,"url":"https://api.github.com/repos/OCA/apps-store","forks_url":"https://api.github.com/repos/OCA/apps-store/forks","keys_url":"https://api.github.com/repos/OCA/apps-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/apps-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/apps-store/teams","hooks_url":"https://api.github.com/repos/OCA/apps-store/hooks","issue_events_url":"https://api.github.com/repos/OCA/apps-store/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/apps-store/events","assignees_url":"https://api.github.com/repos/OCA/apps-store/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/apps-store/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/apps-store/tags","blobs_url":"https://api.github.com/repos/OCA/apps-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/apps-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/apps-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/apps-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/apps-store/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/apps-store/languages","stargazers_url":"https://api.github.com/repos/OCA/apps-store/stargazers","contributors_url":"https://api.github.com/repos/OCA/apps-store/contributors","subscribers_url":"https://api.github.com/repos/OCA/apps-store/subscribers","subscription_url":"https://api.github.com/repos/OCA/apps-store/subscription","commits_url":"https://api.github.com/repos/OCA/apps-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/apps-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/apps-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/apps-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/apps-store/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/apps-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/apps-store/merges","archive_url":"https://api.github.com/repos/OCA/apps-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/apps-store/downloads","issues_url":"https://api.github.com/repos/OCA/apps-store/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/apps-store/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/apps-store/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/apps-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/apps-store/labels{/name}","releases_url":"https://api.github.com/repos/OCA/apps-store/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/apps-store/deployments","created_at":"2017-10-02T12:17:26Z","updated_at":"2017-10-03T15:33:55Z","pushed_at":"2017-10-03T16:58:02Z","git_url":"git://github.com/OCA/apps-store.git","ssh_url":"git@github.com:OCA/apps-store.git","clone_url":"https://github.com/OCA/apps-store.git","svn_url":"https://github.com/OCA/apps-store","homepage":null,"size":17,"stargazers_count":4,"watchers_count":4,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":4,"default_branch":"10.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/3"},"html":{"href":"https://github.com/OCA/apps-store/pull/3"},"issue":{"href":"https://api.github.com/repos/OCA/apps-store/issues/3"},"comments":{"href":"https://api.github.com/repos/OCA/apps-store/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/apps-store/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/apps-store/statuses/60b92321152d20047acb44e7f7e69f2f53bfd896"}},"author_association":"NONE"}}
{"actor":{"display_login":"lasley"}}