{"action":"created","comment":{"url":"https://api.github.com/repos/odoo/odoo/pulls/comments/40299057","id":40299057,"diff_hunk":"@@ -584,35 +585,69 @@ class binary(_column):\n     _symbol_set = (_symbol_c, _symbol_f)\n     _symbol_get = lambda self, x: x and str(x)\n \n-    __slots__ = ['filters']\n+    __slots__ = ['attachment', 'filters']\n \n     def __init__(self, string='unknown', filters=None, **args):\n         args['_prefetch'] = args.get('_prefetch', False)\n+        args['attachment'] = args.get('attachment', True)\n         _column.__init__(self, string=string, filters=filters, **args)\n \n+    def to_field_args(self):\n+        args = super(binary, self).to_field_args()\n+        args['attachment'] = self.attachment\n+        return args\n+\n     def get(self, cr, obj, ids, name, user=None, context=None, values=None):\n-        if not context:\n-            context = {}\n-        if not values:\n-            values = []\n-        res = {}\n-        for i in ids:\n-            val = None\n-            for v in values:\n-                if v['id'] == i:\n-                    val = v[name]\n-                    break\n-\n-            # If client is requesting only the size of the field, we return it instead\n-            # of the content. Presumably a separate request will be done to read the actual\n-            # content if it's needed at some point.\n-            # TODO: after 6.0 we should consider returning a dict with size and content instead of\n-            #       having an implicit convention for the value\n-            if val and context.get('bin_size_%s' % name, context.get('bin_size')):\n-                res[i] = tools.human_size(long(val))\n+        result = dict.fromkeys(ids, False)\n+\n+        if self.attachment:\n+            # values are stored in attachments, retrieve them\n+            atts = obj.pool['ir.attachment'].browse(cr, user, [], context)\n+            domain = [\n+                ('res_model', '=', obj._name),\n+                ('res_field', '=', name),\n+                ('res_id', 'in', ids),\n+            ]\n+            for att in atts.search(domain):\n+                # the 'bin_size' flag is handled by the field 'datas' itself\n+                result[att.res_id] = att.datas\n+        else:","path":"openerp/osv/fields.py","position":58,"original_position":58,"commit_id":"d14343dbba77290415bad4b720c62c2a95bbf20e","original_commit_id":"d14343dbba77290415bad4b720c62c2a95bbf20e","user":{"login":"KangOl","id":38731,"avatar_url":"https://avatars.githubusercontent.com/u/38731?v=3","gravatar_id":"","url":"https://api.github.com/users/KangOl","html_url":"https://github.com/KangOl","followers_url":"https://api.github.com/users/KangOl/followers","following_url":"https://api.github.com/users/KangOl/following{/other_user}","gists_url":"https://api.github.com/users/KangOl/gists{/gist_id}","starred_url":"https://api.github.com/users/KangOl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KangOl/subscriptions","organizations_url":"https://api.github.com/users/KangOl/orgs","repos_url":"https://api.github.com/users/KangOl/repos","events_url":"https://api.github.com/users/KangOl/events{/privacy}","received_events_url":"https://api.github.com/users/KangOl/received_events","type":"User","site_admin":false},"body":"You should also postprocess attachment data to handle `bin_size`","created_at":"2015-09-24T09:12:58Z","updated_at":"2015-09-24T09:12:58Z","html_url":"https://github.com/odoo/odoo/pull/8683#discussion_r40299057","pull_request_url":"https://api.github.com/repos/odoo/odoo/pulls/8683","_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments/40299057"},"html":{"href":"https://github.com/odoo/odoo/pull/8683#discussion_r40299057"},"pull_request":{"href":"https://api.github.com/repos/odoo/odoo/pulls/8683"}}},"pull_request":{"url":"https://api.github.com/repos/odoo/odoo/pulls/8683","id":45791139,"html_url":"https://github.com/odoo/odoo/pull/8683","diff_url":"https://github.com/odoo/odoo/pull/8683.diff","patch_url":"https://github.com/odoo/odoo/pull/8683.patch","issue_url":"https://api.github.com/repos/odoo/odoo/issues/8683","number":8683,"state":"open","locked":false,"title":"[IMP] Store binary fields into attachments","user":{"login":"rco-odoo","id":7578141,"avatar_url":"https://avatars.githubusercontent.com/u/7578141?v=3","gravatar_id":"","url":"https://api.github.com/users/rco-odoo","html_url":"https://github.com/rco-odoo","followers_url":"https://api.github.com/users/rco-odoo/followers","following_url":"https://api.github.com/users/rco-odoo/following{/other_user}","gists_url":"https://api.github.com/users/rco-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/rco-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rco-odoo/subscriptions","organizations_url":"https://api.github.com/users/rco-odoo/orgs","repos_url":"https://api.github.com/users/rco-odoo/repos","events_url":"https://api.github.com/users/rco-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/rco-odoo/received_events","type":"User","site_admin":false},"body":"When enabled, store the content of binary fields into attachment.\r\nFor instance, `record.image` will be stored into an attachment `att` such that:\r\n\r\n    att.res_model = record._name\r\n    att.res_field = 'image'             # this is a new field\r\n    att.res_id = record.id\r\n","created_at":"2015-09-23T15:10:05Z","updated_at":"2015-09-24T09:12:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91c524eff6d124d2156ac4606c3b0dae7bf2803b","assignee":{"login":"rco-odoo","id":7578141,"avatar_url":"https://avatars.githubusercontent.com/u/7578141?v=3","gravatar_id":"","url":"https://api.github.com/users/rco-odoo","html_url":"https://github.com/rco-odoo","followers_url":"https://api.github.com/users/rco-odoo/followers","following_url":"https://api.github.com/users/rco-odoo/following{/other_user}","gists_url":"https://api.github.com/users/rco-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/rco-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rco-odoo/subscriptions","organizations_url":"https://api.github.com/users/rco-odoo/orgs","repos_url":"https://api.github.com/users/rco-odoo/repos","events_url":"https://api.github.com/users/rco-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/rco-odoo/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/odoo/odoo/pulls/8683/commits","review_comments_url":"https://api.github.com/repos/odoo/odoo/pulls/8683/comments","review_comment_url":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/8683/comments","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/d14343dbba77290415bad4b720c62c2a95bbf20e","head":{"label":"odoo-dev:9.0-binarypocalypse-rco","ref":"9.0-binarypocalypse-rco","sha":"d14343dbba77290415bad4b720c62c2a95bbf20e","user":{"login":"odoo-dev","id":7466976,"avatar_url":"https://avatars.githubusercontent.com/u/7466976?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":19853934,"name":"odoo","full_name":"odoo-dev/odoo","owner":{"login":"odoo-dev","id":7466976,"avatar_url":"https://avatars.githubusercontent.com/u/7466976?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoo-dev/odoo","description":"RD Dev Repository","fork":true,"url":"https://api.github.com/repos/odoo-dev/odoo","forks_url":"https://api.github.com/repos/odoo-dev/odoo/forks","keys_url":"https://api.github.com/repos/odoo-dev/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo-dev/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo-dev/odoo/teams","hooks_url":"https://api.github.com/repos/odoo-dev/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo-dev/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo-dev/odoo/events","assignees_url":"https://api.github.com/repos/odoo-dev/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo-dev/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo-dev/odoo/tags","blobs_url":"https://api.github.com/repos/odoo-dev/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo-dev/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo-dev/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo-dev/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo-dev/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo-dev/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo-dev/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo-dev/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo-dev/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo-dev/odoo/subscription","commits_url":"https://api.github.com/repos/odoo-dev/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo-dev/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo-dev/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo-dev/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo-dev/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo-dev/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo-dev/odoo/merges","archive_url":"https://api.github.com/repos/odoo-dev/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo-dev/odoo/downloads","issues_url":"https://api.github.com/repos/odoo-dev/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo-dev/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo-dev/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo-dev/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo-dev/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo-dev/odoo/releases{/id}","created_at":"2014-05-16T11:16:19Z","updated_at":"2015-09-09T08:41:10Z","pushed_at":"2015-09-24T09:08:10Z","git_url":"git://github.com/odoo-dev/odoo.git","ssh_url":"git@github.com:odoo-dev/odoo.git","clone_url":"https://github.com/odoo-dev/odoo.git","svn_url":"https://github.com/odoo-dev/odoo","homepage":"https://www.odoo.com","size":1387847,"stargazers_count":60,"watchers_count":60,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":0,"forks":24,"open_issues":0,"watchers":60,"default_branch":"master"}},"base":{"label":"odoo:9.0","ref":"9.0","sha":"21c88933f78d13e0bd5c4d07e46a324fe70454c7","user":{"login":"odoo","id":6368483,"avatar_url":"https://avatars.githubusercontent.com/u/6368483?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"repo":{"id":19745004,"name":"odoo","full_name":"odoo/odoo","owner":{"login":"odoo","id":6368483,"avatar_url":"https://avatars.githubusercontent.com/u/6368483?v=3","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoo/odoo","description":"Odoo (formerly OpenERP). Open Source Apps To Grow Your Business.","fork":false,"url":"https://api.github.com/repos/odoo/odoo","forks_url":"https://api.github.com/repos/odoo/odoo/forks","keys_url":"https://api.github.com/repos/odoo/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo/odoo/teams","hooks_url":"https://api.github.com/repos/odoo/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo/odoo/events","assignees_url":"https://api.github.com/repos/odoo/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo/odoo/tags","blobs_url":"https://api.github.com/repos/odoo/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo/odoo/subscription","commits_url":"https://api.github.com/repos/odoo/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo/odoo/merges","archive_url":"https://api.github.com/repos/odoo/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo/odoo/downloads","issues_url":"https://api.github.com/repos/odoo/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo/odoo/releases{/id}","created_at":"2014-05-13T15:38:58Z","updated_at":"2015-09-24T04:48:55Z","pushed_at":"2015-09-24T09:09:17Z","git_url":"git://github.com/odoo/odoo.git","ssh_url":"git@github.com:odoo/odoo.git","clone_url":"https://github.com/odoo/odoo.git","svn_url":"https://github.com/odoo/odoo","homepage":"https://www.odoo.com","size":1525677,"stargazers_count":3128,"watchers_count":3128,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2720,"mirror_url":null,"open_issues_count":2624,"forks":2720,"open_issues":2624,"watchers":3128,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/8683"},"html":{"href":"https://github.com/odoo/odoo/pull/8683"},"issue":{"href":"https://api.github.com/repos/odoo/odoo/issues/8683"},"comments":{"href":"https://api.github.com/repos/odoo/odoo/issues/8683/comments"},"review_comments":{"href":"https://api.github.com/repos/odoo/odoo/pulls/8683/comments"},"review_comment":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odoo/odoo/pulls/8683/commits"},"statuses":{"href":"https://api.github.com/repos/odoo/odoo/statuses/d14343dbba77290415bad4b720c62c2a95bbf20e"}}}}