{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/comments/56833136","id":56833136,"diff_hunk":"@@ -0,0 +1,90 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+#\n+#    Authors: Laetitia Gangloff\n+#    Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)\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 import api, models\n+\n+\n+class SaleOrderLine(models.Model):\n+    _inherit = 'sale.order.line'\n+\n+    @api.cr_uid_context\n+    def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,\n+                           uom=False, qty_uos=0, uos=False, name='',\n+                           partner_id=False, lang=False, update_tax=True,\n+                           date_order=False, packaging=False, context=None):\n+        \"\"\"\n+        Replace product_uom_change to use packaging in product_id_change call\n+        \"\"\"\n+        lang = lang or ('lang' in context and context['lang'])\n+        if not uom:\n+            return {'value': {'price_unit': 0.0, 'product_uom': False}}\n+        return self.product_id_change(\n+            cursor, user, ids, pricelist, product, qty=qty, uom=uom,\n+            qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,\n+            lang=lang, update_tax=update_tax, date_order=date_order,\n+            packaging=packaging, context=context)\n+\n+    @api.cr_uid_context\n+    def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0,\n+                                 uom=False, partner_id=False, packaging=False,\n+                                 flag=False, context=None):\n+        \"\"\"\n+        Set product_uom when set product_packaging\n+        \"\"\"\n+        if not product:\n+            packaging = False\n+        else:\n+            products = self.pool['product.product'].browse(cr, uid, product,\n+                                                           context=context)\n+            if not products.packaging_ids or not flag:\n+                # reset empty if flag is not set, the update is not packaging\n+                packaging = False\n+        res = super(SaleOrderLine, self).product_packaging_change(\n+            cr, uid, ids, pricelist, product, qty=qty, uom=uom,\n+            partner_id=partner_id, packaging=packaging, flag=flag,\n+            context=context)\n+        if packaging:\n+            uom = self.pool['product.packaging'].read(\n+                cr, uid, packaging, ['uom_id'], context=context)['uom_id'][0]\n+            res['value']['product_uom'] = uom\n+        else:\n+            res['value']['product_packaging'] = False\n+\n+        return res\n+\n+    @api.model\n+    def update_vals(self, vals):\n+        \"\"\"\n+        When product_packaging is set, product_uom is readonly,\n+        so we need to reset the uom value in the vals dict\n+        \"\"\"\n+        if vals.get('product_packaging'):\n+            vals['product_uom'] = self.env['product.packaging'].browse(\n+                vals['product_packaging']).uom_id.id\n+        return vals\n+\n+    @api.model\n+    def create(self, vals):","path":"sale_packaging/models/sale_order_line.py","position":85,"original_position":85,"commit_id":"f7a338d6d349d1d4fb424e1865fda0a210cc1242","original_commit_id":"f7a338d6d349d1d4fb424e1865fda0a210cc1242","user":{"login":"gurneyalex","id":2032807,"avatar_url":"https://avatars.githubusercontent.com/u/2032807?v=3","gravatar_id":"","url":"https://api.github.com/users/gurneyalex","html_url":"https://github.com/gurneyalex","followers_url":"https://api.github.com/users/gurneyalex/followers","following_url":"https://api.github.com/users/gurneyalex/following{/other_user}","gists_url":"https://api.github.com/users/gurneyalex/gists{/gist_id}","starred_url":"https://api.github.com/users/gurneyalex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gurneyalex/subscriptions","organizations_url":"https://api.github.com/users/gurneyalex/orgs","repos_url":"https://api.github.com/users/gurneyalex/repos","events_url":"https://api.github.com/users/gurneyalex/events{/privacy}","received_events_url":"https://api.github.com/users/gurneyalex/received_events","type":"User","site_admin":false},"body":"you need to add @api.return here too","created_at":"2016-03-21T14:44:36Z","updated_at":"2016-03-21T14:44:36Z","html_url":"https://github.com/OCA/stock-logistics-warehouse/pull/61#discussion_r56833136","pull_request_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61","_links":{"self":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/comments/56833136"},"html":{"href":"https://github.com/OCA/stock-logistics-warehouse/pull/61#discussion_r56833136"},"pull_request":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61","id":40593435,"html_url":"https://github.com/OCA/stock-logistics-warehouse/pull/61","diff_url":"https://github.com/OCA/stock-logistics-warehouse/pull/61.diff","patch_url":"https://github.com/OCA/stock-logistics-warehouse/pull/61.patch","issue_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/61","number":61,"state":"open","locked":false,"title":"[ADD] add modules to use product packaging","user":{"login":"laetitia-gangloff","id":7602419,"avatar_url":"https://avatars.githubusercontent.com/u/7602419?v=3","gravatar_id":"","url":"https://api.github.com/users/laetitia-gangloff","html_url":"https://github.com/laetitia-gangloff","followers_url":"https://api.github.com/users/laetitia-gangloff/followers","following_url":"https://api.github.com/users/laetitia-gangloff/following{/other_user}","gists_url":"https://api.github.com/users/laetitia-gangloff/gists{/gist_id}","starred_url":"https://api.github.com/users/laetitia-gangloff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laetitia-gangloff/subscriptions","organizations_url":"https://api.github.com/users/laetitia-gangloff/orgs","repos_url":"https://api.github.com/users/laetitia-gangloff/repos","events_url":"https://api.github.com/users/laetitia-gangloff/events{/privacy}","received_events_url":"https://api.github.com/users/laetitia-gangloff/received_events","type":"User","site_admin":false},"body":"packaging_extended: to use uom in packaging\r\npurchase_packaging: to improve supplierinfo with purchase uom and packaging and use them in purchase order\r\nsale_packaging: to use packaging uom in sale order line","created_at":"2015-07-22T18:01:07Z","updated_at":"2016-03-21T14:44:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"918c028b5a40f7edc0ef8400aeb95c5e058ae251","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61/commits","review_comments_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61/comments","review_comment_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/61/comments","statuses_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/statuses/f7a338d6d349d1d4fb424e1865fda0a210cc1242","head":{"label":"acsone:8.0-packaging_management-lga","ref":"8.0-packaging_management-lga","sha":"f7a338d6d349d1d4fb424e1865fda0a210cc1242","user":{"login":"acsone","id":7601056,"avatar_url":"https://avatars.githubusercontent.com/u/7601056?v=3","gravatar_id":"","url":"https://api.github.com/users/acsone","html_url":"https://github.com/acsone","followers_url":"https://api.github.com/users/acsone/followers","following_url":"https://api.github.com/users/acsone/following{/other_user}","gists_url":"https://api.github.com/users/acsone/gists{/gist_id}","starred_url":"https://api.github.com/users/acsone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acsone/subscriptions","organizations_url":"https://api.github.com/users/acsone/orgs","repos_url":"https://api.github.com/users/acsone/repos","events_url":"https://api.github.com/users/acsone/events{/privacy}","received_events_url":"https://api.github.com/users/acsone/received_events","type":"Organization","site_admin":false},"repo":{"id":25580388,"name":"stock-logistics-warehouse","full_name":"acsone/stock-logistics-warehouse","owner":{"login":"acsone","id":7601056,"avatar_url":"https://avatars.githubusercontent.com/u/7601056?v=3","gravatar_id":"","url":"https://api.github.com/users/acsone","html_url":"https://github.com/acsone","followers_url":"https://api.github.com/users/acsone/followers","following_url":"https://api.github.com/users/acsone/following{/other_user}","gists_url":"https://api.github.com/users/acsone/gists{/gist_id}","starred_url":"https://api.github.com/users/acsone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acsone/subscriptions","organizations_url":"https://api.github.com/users/acsone/orgs","repos_url":"https://api.github.com/users/acsone/repos","events_url":"https://api.github.com/users/acsone/events{/privacy}","received_events_url":"https://api.github.com/users/acsone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/acsone/stock-logistics-warehouse","description":"","fork":true,"url":"https://api.github.com/repos/acsone/stock-logistics-warehouse","forks_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/forks","keys_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/teams","hooks_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/hooks","issue_events_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/issues/events{/number}","events_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/events","assignees_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/assignees{/user}","branches_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/branches{/branch}","tags_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/tags","blobs_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/statuses/{sha}","languages_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/languages","stargazers_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/stargazers","contributors_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/contributors","subscribers_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/subscribers","subscription_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/subscription","commits_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/contents/{+path}","compare_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/merges","archive_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/downloads","issues_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/issues{/number}","pulls_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/pulls{/number}","milestones_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/milestones{/number}","notifications_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/labels{/name}","releases_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/releases{/id}","deployments_url":"https://api.github.com/repos/acsone/stock-logistics-warehouse/deployments","created_at":"2014-10-22T12:33:03Z","updated_at":"2016-01-14T00:03:23Z","pushed_at":"2016-03-21T12:41:54Z","git_url":"git://github.com/acsone/stock-logistics-warehouse.git","ssh_url":"git@github.com:acsone/stock-logistics-warehouse.git","clone_url":"https://github.com/acsone/stock-logistics-warehouse.git","svn_url":"https://github.com/acsone/stock-logistics-warehouse","homepage":null,"size":1355,"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:8.0","ref":"8.0","sha":"645f7ff8b80bfc87f7e8a73d533621ed0e5866a9","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":20891354,"name":"stock-logistics-warehouse","full_name":"OCA/stock-logistics-warehouse","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/stock-logistics-warehouse","description":"Odoo Warehouse Management Addons","fork":false,"url":"https://api.github.com/repos/OCA/stock-logistics-warehouse","forks_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/forks","keys_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/teams","hooks_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/hooks","issue_events_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/events","assignees_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/tags","blobs_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/languages","stargazers_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/stargazers","contributors_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/contributors","subscribers_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/subscribers","subscription_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/subscription","commits_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/merges","archive_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/downloads","issues_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/labels{/name}","releases_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/stock-logistics-warehouse/deployments","created_at":"2014-06-16T16:08:03Z","updated_at":"2016-02-17T12:33:03Z","pushed_at":"2016-03-21T13:47:50Z","git_url":"git://github.com/OCA/stock-logistics-warehouse.git","ssh_url":"git@github.com:OCA/stock-logistics-warehouse.git","clone_url":"https://github.com/OCA/stock-logistics-warehouse.git","svn_url":"https://github.com/OCA/stock-logistics-warehouse","homepage":"","size":2540,"stargazers_count":24,"watchers_count":24,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":95,"mirror_url":null,"open_issues_count":49,"forks":95,"open_issues":49,"watchers":24,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61"},"html":{"href":"https://github.com/OCA/stock-logistics-warehouse/pull/61"},"issue":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/61"},"comments":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/issues/61/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/pulls/61/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/stock-logistics-warehouse/statuses/f7a338d6d349d1d4fb424e1865fda0a210cc1242"}}}}