{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/manufacture/pulls/comments/29559193","id":29559193,"diff_hunk":"@@ -0,0 +1,267 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+#\n+#    OpenERP, Open Source Management Solution\n+#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).\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\n+#    published by the Free Software Foundation, either version 3 of the\n+#    License, or (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+\n+from openerp.osv import osv, fields, expression\n+\n+\n+class mrp_bom(osv.osv):\n+    _inherit = 'mrp.bom'\n+\n+    def get_child_boms(self, cr, uid, ids, context=None):\n+        result = {}\n+        if not ids:\n+            return result\n+        for curr_id in ids:\n+            result[curr_id] = True\n+        # Now add the children\n+        cr.execute('''\n+        WITH RECURSIVE children AS (\n+        SELECT bom_id, id\n+        FROM mrp_bom\n+        WHERE bom_id IN %s\n+        UNION ALL\n+        SELECT a.bom_id, a.id\n+        FROM mrp_bom a\n+        JOIN children b ON(a.bom_id = b.id)\n+        )\n+        SELECT * FROM children order by bom_id\n+        ''', (tuple(ids),))\n+        res = cr.fetchall()\n+        for x, y in res:\n+            result[y] = True\n+        return result\n+\n+    def _get_boms_from_product(self, cr, uid, ids, context=None):\n+        result = {}\n+        bom_obj = self.pool.get('mrp.bom')\n+        for p in ids:\n+            product_bom_ids = bom_obj.search(\n+                cr, uid, [('product_id', '=', p)])\n+            bom_ids = bom_obj.get_child_boms(cr, uid, product_bom_ids,\n+                                             context=context)\n+            for bom_id in bom_ids:\n+                result[bom_id] = True\n+        return result\n+\n+    def _is_bom(self, cr, uid, ids, name, arg, context=None):\n+        result = {}\n+        if context is None:\n+            context = {}\n+        for bom in self.browse(cr, uid, ids, context=context):\n+            result[bom.id] = False\n+            if bom.bom_lines:\n+                result[bom.id] = True\n+        return result\n+\n+    def _bom_hierarchy_indent_calc(self, cr, uid, ids, prop, unknow_none,\n+                                   unknow_dict):\n+        if not ids:\n+            return []\n+        res = []\n+        for bom in self.browse(cr, uid, ids, context=None):\n+            data = []\n+            b = bom\n+            while b:\n+                if b.name and b.bom_id:\n+                    data.insert(0, '>')\n+                else:\n+                    data.insert(0, '')\n+\n+                b = b.bom_id\n+            data = ''.join(data)\n+            res.append((bom.id, data))\n+        return dict(res)\n+\n+    def _complete_bom_hierarchy_code_calc(\n+            self, cr, uid, ids, prop, unknow_none, unknow_dict):\n+        if not ids:\n+            return []\n+        res = []\n+        for bom in self.browse(cr, uid, ids, context=None):\n+            data = []\n+            b = bom\n+            while b:\n+                if b.code:\n+                    data.insert(0, b.code)\n+                elif b.position:\n+                    data.insert(0, b.position)\n+                elif b.product_id.default_code:\n+                    data.insert(0, b.product_id.default_code)\n+                else:\n+                    data.insert(0, '')\n+\n+                b = b.bom_id\n+            data = ' / '.join(data)\n+            data = '[' + data + '] '\n+\n+            res.append((bom.id, data))\n+        return dict(res)\n+\n+    def _complete_bom_hierarchy_name_calc(\n+            self, cr, uid, ids, prop, unknow_none, unknow_dict):\n+        if not ids:\n+            return []\n+        res = []\n+        for bom in self.browse(cr, uid, ids, context=None):\n+            data = []\n+            b = bom\n+            while b:\n+                if b.name:\n+                    data.insert(0, b.name)\n+                elif b.product_id.name:\n+                    data.insert(0, b.product_id.name)\n+                else:\n+                    data.insert(0, '')\n+\n+                b = b.bom_id\n+\n+            data = ' / '.join(data)\n+            res.append((bom.id, data))\n+        return dict(res)\n+\n+    def _is_parent(self, cr, uid, ids, prop, unknow_none, unknow_dict):\n+        res = {}\n+        for bom in self.browse(cr, uid, ids, context=None):\n+            if not bom.bom_id:\n+                res[bom.id] = True\n+            else:\n+                res[bom.id] = False\n+        return res\n+\n+    def _product_has_own_bom(self, cr, uid, ids, prop, unknow_none,\n+                             unknow_dict):\n+        res = {}\n+        for bom in self.browse(cr, uid, ids, context=None):\n+            bom_ids = self.pool.get('mrp.bom').search(\n+                cr, uid, [('product_id', '=', bom.product_id.id),\n+                          ('bom_id', '=', False)], context=None)\n+            if bom_ids:","path":"mrp_bom_hierarchy/model/mrp.py","position":156,"original_position":156,"commit_id":"041affaa2773fe65557517091c08b939875a50bc","original_commit_id":"041affaa2773fe65557517091c08b939875a50bc","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":"`res[bom.id] = bool(bom_ids)`","created_at":"2015-05-03T19:27:45Z","updated_at":"2015-05-03T19:27:45Z","html_url":"https://github.com/OCA/manufacture/pull/27#discussion_r29559193","pull_request_url":"https://api.github.com/repos/OCA/manufacture/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/comments/29559193"},"html":{"href":"https://github.com/OCA/manufacture/pull/27#discussion_r29559193"},"pull_request":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/manufacture/pulls/27","id":34483387,"html_url":"https://github.com/OCA/manufacture/pull/27","diff_url":"https://github.com/OCA/manufacture/pull/27.diff","patch_url":"https://github.com/OCA/manufacture/pull/27.patch","issue_url":"https://api.github.com/repos/OCA/manufacture/issues/27","number":27,"state":"open","locked":false,"title":"7.0 mrp bom hierarchy","user":{"login":"jbeficent","id":7683926,"avatar_url":"https://avatars.githubusercontent.com/u/7683926?v=3","gravatar_id":"","url":"https://api.github.com/users/jbeficent","html_url":"https://github.com/jbeficent","followers_url":"https://api.github.com/users/jbeficent/followers","following_url":"https://api.github.com/users/jbeficent/following{/other_user}","gists_url":"https://api.github.com/users/jbeficent/gists{/gist_id}","starred_url":"https://api.github.com/users/jbeficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbeficent/subscriptions","organizations_url":"https://api.github.com/users/jbeficent/orgs","repos_url":"https://api.github.com/users/jbeficent/repos","events_url":"https://api.github.com/users/jbeficent/events{/privacy}","received_events_url":"https://api.github.com/users/jbeficent/received_events","type":"User","site_admin":false},"body":"This module was written to extend the functionality of Bill of\r\nMaterials to support users to better maintain the BOM hierarchy.\r\n\r\nThis module replaces the existing BOM tree views with a new one, from\r\nwhich the user can create a complete BOM hierarchy.\r\n\r\nThe user can navigate from the  tree view to child BOM's, or to the\r\nproduct's BOM components with a single click.\r\n\r\nThe user can now search using the field 'Complete Reference' (or Name) to\r\nfind all the BOM hierarchy associated to a particular BOM Reference (or\r\nName) at once.\r\n\r\nThis PR substitutes https://github.com/OCA/manufacture/pull/23","created_at":"2015-04-30T17:42:00Z","updated_at":"2015-05-03T19:27:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd12f7070500b90f17f26daf921a1536a94da97c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/manufacture/pulls/27/commits","review_comments_url":"https://api.github.com/repos/OCA/manufacture/pulls/27/comments","review_comment_url":"https://api.github.com/repos/OCA/manufacture/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/manufacture/issues/27/comments","statuses_url":"https://api.github.com/repos/OCA/manufacture/statuses/041affaa2773fe65557517091c08b939875a50bc","head":{"label":"Eficent:7.0-mrp_bom_hierarchy","ref":"7.0-mrp_bom_hierarchy","sha":"041affaa2773fe65557517091c08b939875a50bc","user":{"login":"Eficent","id":7718403,"avatar_url":"https://avatars.githubusercontent.com/u/7718403?v=3","gravatar_id":"","url":"https://api.github.com/users/Eficent","html_url":"https://github.com/Eficent","followers_url":"https://api.github.com/users/Eficent/followers","following_url":"https://api.github.com/users/Eficent/following{/other_user}","gists_url":"https://api.github.com/users/Eficent/gists{/gist_id}","starred_url":"https://api.github.com/users/Eficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eficent/subscriptions","organizations_url":"https://api.github.com/users/Eficent/orgs","repos_url":"https://api.github.com/users/Eficent/repos","events_url":"https://api.github.com/users/Eficent/events{/privacy}","received_events_url":"https://api.github.com/users/Eficent/received_events","type":"Organization","site_admin":false},"repo":{"id":34867464,"name":"manufacture","full_name":"Eficent/manufacture","owner":{"login":"Eficent","id":7718403,"avatar_url":"https://avatars.githubusercontent.com/u/7718403?v=3","gravatar_id":"","url":"https://api.github.com/users/Eficent","html_url":"https://github.com/Eficent","followers_url":"https://api.github.com/users/Eficent/followers","following_url":"https://api.github.com/users/Eficent/following{/other_user}","gists_url":"https://api.github.com/users/Eficent/gists{/gist_id}","starred_url":"https://api.github.com/users/Eficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eficent/subscriptions","organizations_url":"https://api.github.com/users/Eficent/orgs","repos_url":"https://api.github.com/users/Eficent/repos","events_url":"https://api.github.com/users/Eficent/events{/privacy}","received_events_url":"https://api.github.com/users/Eficent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Eficent/manufacture","description":"Odoo Manufacturing Addons","fork":true,"url":"https://api.github.com/repos/Eficent/manufacture","forks_url":"https://api.github.com/repos/Eficent/manufacture/forks","keys_url":"https://api.github.com/repos/Eficent/manufacture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eficent/manufacture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eficent/manufacture/teams","hooks_url":"https://api.github.com/repos/Eficent/manufacture/hooks","issue_events_url":"https://api.github.com/repos/Eficent/manufacture/issues/events{/number}","events_url":"https://api.github.com/repos/Eficent/manufacture/events","assignees_url":"https://api.github.com/repos/Eficent/manufacture/assignees{/user}","branches_url":"https://api.github.com/repos/Eficent/manufacture/branches{/branch}","tags_url":"https://api.github.com/repos/Eficent/manufacture/tags","blobs_url":"https://api.github.com/repos/Eficent/manufacture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eficent/manufacture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eficent/manufacture/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eficent/manufacture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eficent/manufacture/statuses/{sha}","languages_url":"https://api.github.com/repos/Eficent/manufacture/languages","stargazers_url":"https://api.github.com/repos/Eficent/manufacture/stargazers","contributors_url":"https://api.github.com/repos/Eficent/manufacture/contributors","subscribers_url":"https://api.github.com/repos/Eficent/manufacture/subscribers","subscription_url":"https://api.github.com/repos/Eficent/manufacture/subscription","commits_url":"https://api.github.com/repos/Eficent/manufacture/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eficent/manufacture/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eficent/manufacture/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eficent/manufacture/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eficent/manufacture/contents/{+path}","compare_url":"https://api.github.com/repos/Eficent/manufacture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eficent/manufacture/merges","archive_url":"https://api.github.com/repos/Eficent/manufacture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eficent/manufacture/downloads","issues_url":"https://api.github.com/repos/Eficent/manufacture/issues{/number}","pulls_url":"https://api.github.com/repos/Eficent/manufacture/pulls{/number}","milestones_url":"https://api.github.com/repos/Eficent/manufacture/milestones{/number}","notifications_url":"https://api.github.com/repos/Eficent/manufacture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eficent/manufacture/labels{/name}","releases_url":"https://api.github.com/repos/Eficent/manufacture/releases{/id}","created_at":"2015-04-30T17:31:31Z","updated_at":"2015-04-30T17:31:31Z","pushed_at":"2015-04-30T20:07:45Z","git_url":"git://github.com/Eficent/manufacture.git","ssh_url":"git@github.com:Eficent/manufacture.git","clone_url":"https://github.com/Eficent/manufacture.git","svn_url":"https://github.com/Eficent/manufacture","homepage":"","size":246,"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":"8.0"}},"base":{"label":"OCA:7.0","ref":"7.0","sha":"2228123c7bba254e772a7555d21211cdb2012c8a","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":20894327,"name":"manufacture","full_name":"OCA/manufacture","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/manufacture","description":"Odoo Manufacturing Addons","fork":false,"url":"https://api.github.com/repos/OCA/manufacture","forks_url":"https://api.github.com/repos/OCA/manufacture/forks","keys_url":"https://api.github.com/repos/OCA/manufacture/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/manufacture/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/manufacture/teams","hooks_url":"https://api.github.com/repos/OCA/manufacture/hooks","issue_events_url":"https://api.github.com/repos/OCA/manufacture/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/manufacture/events","assignees_url":"https://api.github.com/repos/OCA/manufacture/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/manufacture/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/manufacture/tags","blobs_url":"https://api.github.com/repos/OCA/manufacture/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/manufacture/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/manufacture/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/manufacture/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/manufacture/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/manufacture/languages","stargazers_url":"https://api.github.com/repos/OCA/manufacture/stargazers","contributors_url":"https://api.github.com/repos/OCA/manufacture/contributors","subscribers_url":"https://api.github.com/repos/OCA/manufacture/subscribers","subscription_url":"https://api.github.com/repos/OCA/manufacture/subscription","commits_url":"https://api.github.com/repos/OCA/manufacture/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/manufacture/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/manufacture/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/manufacture/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/manufacture/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/manufacture/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/manufacture/merges","archive_url":"https://api.github.com/repos/OCA/manufacture/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/manufacture/downloads","issues_url":"https://api.github.com/repos/OCA/manufacture/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/manufacture/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/manufacture/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/manufacture/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/manufacture/labels{/name}","releases_url":"https://api.github.com/repos/OCA/manufacture/releases{/id}","created_at":"2014-06-16T17:48:41Z","updated_at":"2015-03-27T15:27:05Z","pushed_at":"2015-04-30T20:07:46Z","git_url":"git://github.com/OCA/manufacture.git","ssh_url":"git@github.com:OCA/manufacture.git","clone_url":"https://github.com/OCA/manufacture.git","svn_url":"https://github.com/OCA/manufacture","homepage":"","size":1018,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":13,"forks":13,"open_issues":13,"watchers":4,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/27"},"html":{"href":"https://github.com/OCA/manufacture/pull/27"},"issue":{"href":"https://api.github.com/repos/OCA/manufacture/issues/27"},"comments":{"href":"https://api.github.com/repos/OCA/manufacture/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/manufacture/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/manufacture/statuses/041affaa2773fe65557517091c08b939875a50bc"}}}}