{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/product-attribute/pulls/comments/48280585","id":48280585,"diff_hunk":"@@ -191,14 +139,72 @@ class res_partner(orm.Model):\n \n     def _check_ean_key(self, cr, uid, ids):\n         for rec in self.browse(cr, uid, ids):\n-            if not check_ean(rec.ean13):\n+            if not check_gtin(rec.ean13):\n                 return False\n         return True\n \n     _columns = {\n         'ean13': fields.char(\n-            'EAN', size=14,\n+            'EAN', size = max(VALID_GTIN_LENGTHS),\n             help=\"Code for %s\" % HELP_MESSAGE),\n         }\n \n     _constraints = [(_check_ean_key, CONSTRAINT_MESSAGE, ['ean13'])]\n+    \n+    \n+if __name__ == '__main__':\n+    \n+    import unittest","path":"product_gtin/product_gtin.py","position":240,"original_position":240,"commit_id":"1ec907faebc880a0a3e197317234a3cca165d63b","original_commit_id":"1ec907faebc880a0a3e197317234a3cca165d63b","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":"Make tests in the tests folder and with Odoo structure.","created_at":"2015-12-22T18:11:16Z","updated_at":"2015-12-22T18:11:16Z","html_url":"https://github.com/OCA/product-attribute/pull/99#discussion_r48280585","pull_request_url":"https://api.github.com/repos/OCA/product-attribute/pulls/99","_links":{"self":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/comments/48280585"},"html":{"href":"https://github.com/OCA/product-attribute/pull/99#discussion_r48280585"},"pull_request":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/99"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/product-attribute/pulls/99","id":47546228,"html_url":"https://github.com/OCA/product-attribute/pull/99","diff_url":"https://github.com/OCA/product-attribute/pull/99.diff","patch_url":"https://github.com/OCA/product-attribute/pull/99.patch","issue_url":"https://api.github.com/repos/OCA/product-attribute/issues/99","number":99,"state":"open","locked":false,"title":"check_upc() fails when check-digit is 0","user":{"login":"pjmcdermott","id":10463288,"avatar_url":"https://avatars.githubusercontent.com/u/10463288?v=3","gravatar_id":"","url":"https://api.github.com/users/pjmcdermott","html_url":"https://github.com/pjmcdermott","followers_url":"https://api.github.com/users/pjmcdermott/followers","following_url":"https://api.github.com/users/pjmcdermott/following{/other_user}","gists_url":"https://api.github.com/users/pjmcdermott/gists{/gist_id}","starred_url":"https://api.github.com/users/pjmcdermott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjmcdermott/subscriptions","organizations_url":"https://api.github.com/users/pjmcdermott/orgs","repos_url":"https://api.github.com/users/pjmcdermott/repos","events_url":"https://api.github.com/users/pjmcdermott/events{/privacy}","received_events_url":"https://api.github.com/users/pjmcdermott/received_events","type":"User","site_admin":false},"body":"I discovered that the check_upc() routine was not working when the check-digit was zero, as it was missing the:\r\n\r\n```\r\nif check == 10:\r\n check = 10\r\n```\r\n\r\nthat the other `check_x()` routines have.\r\n\r\nOnce I started poking around the rules for GTIN checksums, I discovered that the algorithm is identical for EAN-8, EAN-13, UPC, EAN-14---you just have to start at the right hand side (ignoring the check digit).\r\n\r\nSo this has led to some major re-factoring as there was considerable duplication of the GTIN checking algorithm.\r\n\r\nI also added some unit tests, as it was a gap that this module did not have any real-world EANs or UPCs to verify the `check_x()` routines with.\r\n\r\nFinally, once all of the identifiers are being checked by the same function, the section to route the identifier to the appropriate check function was redundant, so I zapped that too!\r\n","created_at":"2015-10-13T15:10:44Z","updated_at":"2015-12-22T18:11:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f1eab28a224e8001462f9d49cf08a7d27cf506e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/product-attribute/pulls/99/commits","review_comments_url":"https://api.github.com/repos/OCA/product-attribute/pulls/99/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/99/comments","statuses_url":"https://api.github.com/repos/OCA/product-attribute/statuses/1ec907faebc880a0a3e197317234a3cca165d63b","head":{"label":"pjmcdermott:8.0","ref":"8.0","sha":"1ec907faebc880a0a3e197317234a3cca165d63b","user":{"login":"pjmcdermott","id":10463288,"avatar_url":"https://avatars.githubusercontent.com/u/10463288?v=3","gravatar_id":"","url":"https://api.github.com/users/pjmcdermott","html_url":"https://github.com/pjmcdermott","followers_url":"https://api.github.com/users/pjmcdermott/followers","following_url":"https://api.github.com/users/pjmcdermott/following{/other_user}","gists_url":"https://api.github.com/users/pjmcdermott/gists{/gist_id}","starred_url":"https://api.github.com/users/pjmcdermott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjmcdermott/subscriptions","organizations_url":"https://api.github.com/users/pjmcdermott/orgs","repos_url":"https://api.github.com/users/pjmcdermott/repos","events_url":"https://api.github.com/users/pjmcdermott/events{/privacy}","received_events_url":"https://api.github.com/users/pjmcdermott/received_events","type":"User","site_admin":false},"repo":{"id":44178635,"name":"product-attribute","full_name":"pjmcdermott/product-attribute","owner":{"login":"pjmcdermott","id":10463288,"avatar_url":"https://avatars.githubusercontent.com/u/10463288?v=3","gravatar_id":"","url":"https://api.github.com/users/pjmcdermott","html_url":"https://github.com/pjmcdermott","followers_url":"https://api.github.com/users/pjmcdermott/followers","following_url":"https://api.github.com/users/pjmcdermott/following{/other_user}","gists_url":"https://api.github.com/users/pjmcdermott/gists{/gist_id}","starred_url":"https://api.github.com/users/pjmcdermott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pjmcdermott/subscriptions","organizations_url":"https://api.github.com/users/pjmcdermott/orgs","repos_url":"https://api.github.com/users/pjmcdermott/repos","events_url":"https://api.github.com/users/pjmcdermott/events{/privacy}","received_events_url":"https://api.github.com/users/pjmcdermott/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pjmcdermott/product-attribute","description":"Odoo Product Attribute","fork":true,"url":"https://api.github.com/repos/pjmcdermott/product-attribute","forks_url":"https://api.github.com/repos/pjmcdermott/product-attribute/forks","keys_url":"https://api.github.com/repos/pjmcdermott/product-attribute/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pjmcdermott/product-attribute/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pjmcdermott/product-attribute/teams","hooks_url":"https://api.github.com/repos/pjmcdermott/product-attribute/hooks","issue_events_url":"https://api.github.com/repos/pjmcdermott/product-attribute/issues/events{/number}","events_url":"https://api.github.com/repos/pjmcdermott/product-attribute/events","assignees_url":"https://api.github.com/repos/pjmcdermott/product-attribute/assignees{/user}","branches_url":"https://api.github.com/repos/pjmcdermott/product-attribute/branches{/branch}","tags_url":"https://api.github.com/repos/pjmcdermott/product-attribute/tags","blobs_url":"https://api.github.com/repos/pjmcdermott/product-attribute/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pjmcdermott/product-attribute/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pjmcdermott/product-attribute/git/refs{/sha}","trees_url":"https://api.github.com/repos/pjmcdermott/product-attribute/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pjmcdermott/product-attribute/statuses/{sha}","languages_url":"https://api.github.com/repos/pjmcdermott/product-attribute/languages","stargazers_url":"https://api.github.com/repos/pjmcdermott/product-attribute/stargazers","contributors_url":"https://api.github.com/repos/pjmcdermott/product-attribute/contributors","subscribers_url":"https://api.github.com/repos/pjmcdermott/product-attribute/subscribers","subscription_url":"https://api.github.com/repos/pjmcdermott/product-attribute/subscription","commits_url":"https://api.github.com/repos/pjmcdermott/product-attribute/commits{/sha}","git_commits_url":"https://api.github.com/repos/pjmcdermott/product-attribute/git/commits{/sha}","comments_url":"https://api.github.com/repos/pjmcdermott/product-attribute/comments{/number}","issue_comment_url":"https://api.github.com/repos/pjmcdermott/product-attribute/issues/comments{/number}","contents_url":"https://api.github.com/repos/pjmcdermott/product-attribute/contents/{+path}","compare_url":"https://api.github.com/repos/pjmcdermott/product-attribute/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pjmcdermott/product-attribute/merges","archive_url":"https://api.github.com/repos/pjmcdermott/product-attribute/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pjmcdermott/product-attribute/downloads","issues_url":"https://api.github.com/repos/pjmcdermott/product-attribute/issues{/number}","pulls_url":"https://api.github.com/repos/pjmcdermott/product-attribute/pulls{/number}","milestones_url":"https://api.github.com/repos/pjmcdermott/product-attribute/milestones{/number}","notifications_url":"https://api.github.com/repos/pjmcdermott/product-attribute/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pjmcdermott/product-attribute/labels{/name}","releases_url":"https://api.github.com/repos/pjmcdermott/product-attribute/releases{/id}","created_at":"2015-10-13T13:37:19Z","updated_at":"2015-10-13T13:37:21Z","pushed_at":"2015-10-13T19:13:02Z","git_url":"git://github.com/pjmcdermott/product-attribute.git","ssh_url":"git@github.com:pjmcdermott/product-attribute.git","clone_url":"https://github.com/pjmcdermott/product-attribute.git","svn_url":"https://github.com/pjmcdermott/product-attribute","homepage":"","size":2614,"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":"c525971049a0688fd476c27c52e35e69c0d455ee","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-12-08T16:31:01Z","pushed_at":"2015-12-18T15:36:50Z","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":"https://odoo-community.org/project/product-maintainers-27","size":4592,"stargazers_count":18,"watchers_count":18,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":115,"mirror_url":null,"open_issues_count":45,"forks":115,"open_issues":45,"watchers":18,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/99"},"html":{"href":"https://github.com/OCA/product-attribute/pull/99"},"issue":{"href":"https://api.github.com/repos/OCA/product-attribute/issues/99"},"comments":{"href":"https://api.github.com/repos/OCA/product-attribute/issues/99/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/product-attribute/pulls/99/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/99/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/product-attribute/statuses/1ec907faebc880a0a3e197317234a3cca165d63b"}}}}