{"action":"created","comment":{"url":"https://api.github.com/repos/Vauxoo/rma/pulls/comments/62909864","id":62909864,"diff_hunk":"@@ -39,6 +34,46 @@ class ClaimLine(models.Model):\n                              \"purchase of goods sold to \"\n                              \"customer\")\n \n+    supplier_id = \\\n+        fields.Many2one('res.partner', string='Supplier',\n+                        related='supplier_invoice_id.partner_id',\n+                        store=True,\n+                        help=\"Supplier of good in claim\")\n+\n+    @api.model\n+    def _search_invoice_to_get_information(self, product):\n+        \"\"\" When the product has not serial/lot number,\n+        the system has not way to determine the supplier\n+        and supplier invoice of product.\n+\n+        This method helps to search the last supplier invoice\n+        to get required information.\n+        @param product: A product.product browse to avoid\n+        send a id integer or a browse_list.\n+        This will be the product in the invoice line to be searched.\n+        \"\"\"\n+        invoice_obj = invoice_to_return = self.env[\"account.invoice\"]\n+        invoice_line_obj = self.env[\"account.invoice.line\"]\n+\n+        # Search one invoice with:\n+        # 1. max(date_invoice)\n+        # 2. state not in ('draft', 'cancel')\n+        # 3. and type = 'in_invoice'\n+        inv = invoice_obj.search(\n+            [(\"state\", \"not in\", (\"draft\", \"cancel\")),\n+             (\"type\", \"=\", \"in_invoice\")],\n+            limit=1, order=\"date_invoice,id desc\")\n+\n+        # Search if resulting invoice from the query above has\n+        # the product to search in the invoice lines\n+        inv_line = invoice_line_obj.search(\n+            [(\"product_id\", \"=\", product.id), (\"invoice_id\", \"=\", inv.id)],","path":"crm_claim_product_supplier/models/claim_line.py","position":49,"original_position":49,"commit_id":"47061a0824c7168862e541553ebd9bfba82ecf44","original_commit_id":"5d5412707ce8305a7871cc608dbc922055c0bc51","user":{"login":"moylop260","id":6644187,"avatar_url":"https://avatars.githubusercontent.com/u/6644187?v=3","gravatar_id":"","url":"https://api.github.com/users/moylop260","html_url":"https://github.com/moylop260","followers_url":"https://api.github.com/users/moylop260/followers","following_url":"https://api.github.com/users/moylop260/following{/other_user}","gists_url":"https://api.github.com/users/moylop260/gists{/gist_id}","starred_url":"https://api.github.com/users/moylop260/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moylop260/subscriptions","organizations_url":"https://api.github.com/users/moylop260/orgs","repos_url":"https://api.github.com/users/moylop260/repos","events_url":"https://api.github.com/users/moylop260/events{/privacy}","received_events_url":"https://api.github.com/users/moylop260/received_events","type":"User","site_admin":false},"body":"@osvalr \r\nWe had the following error:\r\n```bash\r\ninvoice_line_obj.search([(\"invoice_id.state\", \"not in\", (\"draft\", \"cancel\")),(\"invoice_id.type\", \"=\", \"in_invoice\"),(\"product_id\", \"=\", product.id)],limit=1, order=\"date_invoice desc\")\r\n*** ValueError: Sorting field date_invoice not found on model account.invoice.line\r\n```","created_at":"2016-05-11T19:23:21Z","updated_at":"2016-05-11T19:23:21Z","html_url":"https://github.com/Vauxoo/rma/pull/112#discussion_r62909864","pull_request_url":"https://api.github.com/repos/Vauxoo/rma/pulls/112","_links":{"self":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/comments/62909864"},"html":{"href":"https://github.com/Vauxoo/rma/pull/112#discussion_r62909864"},"pull_request":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/112"}}},"pull_request":{"url":"https://api.github.com/repos/Vauxoo/rma/pulls/112","id":69412820,"html_url":"https://github.com/Vauxoo/rma/pull/112","diff_url":"https://github.com/Vauxoo/rma/pull/112.diff","patch_url":"https://github.com/Vauxoo/rma/pull/112.patch","issue_url":"https://api.github.com/repos/Vauxoo/rma/issues/112","number":112,"state":"open","locked":false,"title":"[IMP] Method to search the last supplier invoice to get required information.","user":{"login":"yaniaular","id":7602170,"avatar_url":"https://avatars.githubusercontent.com/u/7602170?v=3","gravatar_id":"","url":"https://api.github.com/users/yaniaular","html_url":"https://github.com/yaniaular","followers_url":"https://api.github.com/users/yaniaular/followers","following_url":"https://api.github.com/users/yaniaular/following{/other_user}","gists_url":"https://api.github.com/users/yaniaular/gists{/gist_id}","starred_url":"https://api.github.com/users/yaniaular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaniaular/subscriptions","organizations_url":"https://api.github.com/users/yaniaular/orgs","repos_url":"https://api.github.com/users/yaniaular/repos","events_url":"https://api.github.com/users/yaniaular/events{/privacy}","received_events_url":"https://api.github.com/users/yaniaular/received_events","type":"User","site_admin":false},"body":"## This PR just improves one method structure to use in another place.\r\n## Issue https://github.com/Vauxoo/yoytec/issues/1071\r\n## Dummy PR: https://github.com/Vauxoo/yoytec/pull/1186\r\nWhen the product has not serial/lot number, the system has not way to determine the supplier and supplier invoice of product. A new method is added to modularize and search the last supplier invoice  to get required information.","created_at":"2016-05-09T21:19:11Z","updated_at":"2016-05-11T19:23:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4fa06678f56c37fbf21b8cb76dc74991b4f068d3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Vauxoo/rma/pulls/112/commits","review_comments_url":"https://api.github.com/repos/Vauxoo/rma/pulls/112/comments","review_comment_url":"https://api.github.com/repos/Vauxoo/rma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vauxoo/rma/issues/112/comments","statuses_url":"https://api.github.com/repos/Vauxoo/rma/statuses/47061a0824c7168862e541553ebd9bfba82ecf44","head":{"label":"vauxoo-dev:8.0-make_generic_method_for_use_in_yoytec-dev-yani","ref":"8.0-make_generic_method_for_use_in_yoytec-dev-yani","sha":"47061a0824c7168862e541553ebd9bfba82ecf44","user":{"login":"vauxoo-dev","id":7662790,"avatar_url":"https://avatars.githubusercontent.com/u/7662790?v=3","gravatar_id":"","url":"https://api.github.com/users/vauxoo-dev","html_url":"https://github.com/vauxoo-dev","followers_url":"https://api.github.com/users/vauxoo-dev/followers","following_url":"https://api.github.com/users/vauxoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/vauxoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/vauxoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vauxoo-dev/subscriptions","organizations_url":"https://api.github.com/users/vauxoo-dev/orgs","repos_url":"https://api.github.com/users/vauxoo-dev/repos","events_url":"https://api.github.com/users/vauxoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/vauxoo-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":26508381,"name":"rma","full_name":"vauxoo-dev/rma","owner":{"login":"vauxoo-dev","id":7662790,"avatar_url":"https://avatars.githubusercontent.com/u/7662790?v=3","gravatar_id":"","url":"https://api.github.com/users/vauxoo-dev","html_url":"https://github.com/vauxoo-dev","followers_url":"https://api.github.com/users/vauxoo-dev/followers","following_url":"https://api.github.com/users/vauxoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/vauxoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/vauxoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vauxoo-dev/subscriptions","organizations_url":"https://api.github.com/users/vauxoo-dev/orgs","repos_url":"https://api.github.com/users/vauxoo-dev/repos","events_url":"https://api.github.com/users/vauxoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/vauxoo-dev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vauxoo-dev/rma","description":"","fork":true,"url":"https://api.github.com/repos/vauxoo-dev/rma","forks_url":"https://api.github.com/repos/vauxoo-dev/rma/forks","keys_url":"https://api.github.com/repos/vauxoo-dev/rma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vauxoo-dev/rma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vauxoo-dev/rma/teams","hooks_url":"https://api.github.com/repos/vauxoo-dev/rma/hooks","issue_events_url":"https://api.github.com/repos/vauxoo-dev/rma/issues/events{/number}","events_url":"https://api.github.com/repos/vauxoo-dev/rma/events","assignees_url":"https://api.github.com/repos/vauxoo-dev/rma/assignees{/user}","branches_url":"https://api.github.com/repos/vauxoo-dev/rma/branches{/branch}","tags_url":"https://api.github.com/repos/vauxoo-dev/rma/tags","blobs_url":"https://api.github.com/repos/vauxoo-dev/rma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vauxoo-dev/rma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vauxoo-dev/rma/git/refs{/sha}","trees_url":"https://api.github.com/repos/vauxoo-dev/rma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vauxoo-dev/rma/statuses/{sha}","languages_url":"https://api.github.com/repos/vauxoo-dev/rma/languages","stargazers_url":"https://api.github.com/repos/vauxoo-dev/rma/stargazers","contributors_url":"https://api.github.com/repos/vauxoo-dev/rma/contributors","subscribers_url":"https://api.github.com/repos/vauxoo-dev/rma/subscribers","subscription_url":"https://api.github.com/repos/vauxoo-dev/rma/subscription","commits_url":"https://api.github.com/repos/vauxoo-dev/rma/commits{/sha}","git_commits_url":"https://api.github.com/repos/vauxoo-dev/rma/git/commits{/sha}","comments_url":"https://api.github.com/repos/vauxoo-dev/rma/comments{/number}","issue_comment_url":"https://api.github.com/repos/vauxoo-dev/rma/issues/comments{/number}","contents_url":"https://api.github.com/repos/vauxoo-dev/rma/contents/{+path}","compare_url":"https://api.github.com/repos/vauxoo-dev/rma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vauxoo-dev/rma/merges","archive_url":"https://api.github.com/repos/vauxoo-dev/rma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vauxoo-dev/rma/downloads","issues_url":"https://api.github.com/repos/vauxoo-dev/rma/issues{/number}","pulls_url":"https://api.github.com/repos/vauxoo-dev/rma/pulls{/number}","milestones_url":"https://api.github.com/repos/vauxoo-dev/rma/milestones{/number}","notifications_url":"https://api.github.com/repos/vauxoo-dev/rma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vauxoo-dev/rma/labels{/name}","releases_url":"https://api.github.com/repos/vauxoo-dev/rma/releases{/id}","deployments_url":"https://api.github.com/repos/vauxoo-dev/rma/deployments","created_at":"2014-11-11T22:43:23Z","updated_at":"2014-12-10T18:48:36Z","pushed_at":"2016-05-11T18:49:45Z","git_url":"git://github.com/vauxoo-dev/rma.git","ssh_url":"git@github.com:vauxoo-dev/rma.git","clone_url":"https://github.com/vauxoo-dev/rma.git","svn_url":"https://github.com/vauxoo-dev/rma","homepage":null,"size":2400,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":false,"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":"master"}},"base":{"label":"Vauxoo:8.0","ref":"8.0","sha":"384843040b21e0675ef70a45f61ca18ecd7eef89","user":{"login":"Vauxoo","id":5997834,"avatar_url":"https://avatars.githubusercontent.com/u/5997834?v=3","gravatar_id":"","url":"https://api.github.com/users/Vauxoo","html_url":"https://github.com/Vauxoo","followers_url":"https://api.github.com/users/Vauxoo/followers","following_url":"https://api.github.com/users/Vauxoo/following{/other_user}","gists_url":"https://api.github.com/users/Vauxoo/gists{/gist_id}","starred_url":"https://api.github.com/users/Vauxoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vauxoo/subscriptions","organizations_url":"https://api.github.com/users/Vauxoo/orgs","repos_url":"https://api.github.com/users/Vauxoo/repos","events_url":"https://api.github.com/users/Vauxoo/events{/privacy}","received_events_url":"https://api.github.com/users/Vauxoo/received_events","type":"Organization","site_admin":false},"repo":{"id":26508378,"name":"rma","full_name":"Vauxoo/rma","owner":{"login":"Vauxoo","id":5997834,"avatar_url":"https://avatars.githubusercontent.com/u/5997834?v=3","gravatar_id":"","url":"https://api.github.com/users/Vauxoo","html_url":"https://github.com/Vauxoo","followers_url":"https://api.github.com/users/Vauxoo/followers","following_url":"https://api.github.com/users/Vauxoo/following{/other_user}","gists_url":"https://api.github.com/users/Vauxoo/gists{/gist_id}","starred_url":"https://api.github.com/users/Vauxoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vauxoo/subscriptions","organizations_url":"https://api.github.com/users/Vauxoo/orgs","repos_url":"https://api.github.com/users/Vauxoo/repos","events_url":"https://api.github.com/users/Vauxoo/events{/privacy}","received_events_url":"https://api.github.com/users/Vauxoo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Vauxoo/rma","description":"","fork":true,"url":"https://api.github.com/repos/Vauxoo/rma","forks_url":"https://api.github.com/repos/Vauxoo/rma/forks","keys_url":"https://api.github.com/repos/Vauxoo/rma/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vauxoo/rma/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vauxoo/rma/teams","hooks_url":"https://api.github.com/repos/Vauxoo/rma/hooks","issue_events_url":"https://api.github.com/repos/Vauxoo/rma/issues/events{/number}","events_url":"https://api.github.com/repos/Vauxoo/rma/events","assignees_url":"https://api.github.com/repos/Vauxoo/rma/assignees{/user}","branches_url":"https://api.github.com/repos/Vauxoo/rma/branches{/branch}","tags_url":"https://api.github.com/repos/Vauxoo/rma/tags","blobs_url":"https://api.github.com/repos/Vauxoo/rma/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vauxoo/rma/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vauxoo/rma/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vauxoo/rma/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vauxoo/rma/statuses/{sha}","languages_url":"https://api.github.com/repos/Vauxoo/rma/languages","stargazers_url":"https://api.github.com/repos/Vauxoo/rma/stargazers","contributors_url":"https://api.github.com/repos/Vauxoo/rma/contributors","subscribers_url":"https://api.github.com/repos/Vauxoo/rma/subscribers","subscription_url":"https://api.github.com/repos/Vauxoo/rma/subscription","commits_url":"https://api.github.com/repos/Vauxoo/rma/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vauxoo/rma/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vauxoo/rma/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vauxoo/rma/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vauxoo/rma/contents/{+path}","compare_url":"https://api.github.com/repos/Vauxoo/rma/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vauxoo/rma/merges","archive_url":"https://api.github.com/repos/Vauxoo/rma/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vauxoo/rma/downloads","issues_url":"https://api.github.com/repos/Vauxoo/rma/issues{/number}","pulls_url":"https://api.github.com/repos/Vauxoo/rma/pulls{/number}","milestones_url":"https://api.github.com/repos/Vauxoo/rma/milestones{/number}","notifications_url":"https://api.github.com/repos/Vauxoo/rma/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vauxoo/rma/labels{/name}","releases_url":"https://api.github.com/repos/Vauxoo/rma/releases{/id}","deployments_url":"https://api.github.com/repos/Vauxoo/rma/deployments","created_at":"2014-11-11T22:43:18Z","updated_at":"2016-01-29T17:46:40Z","pushed_at":"2016-05-11T18:49:46Z","git_url":"git://github.com/Vauxoo/rma.git","ssh_url":"git@github.com:Vauxoo/rma.git","clone_url":"https://github.com/Vauxoo/rma.git","svn_url":"https://github.com/Vauxoo/rma","homepage":null,"size":2306,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":17,"forks":3,"open_issues":17,"watchers":1,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/112"},"html":{"href":"https://github.com/Vauxoo/rma/pull/112"},"issue":{"href":"https://api.github.com/repos/Vauxoo/rma/issues/112"},"comments":{"href":"https://api.github.com/repos/Vauxoo/rma/issues/112/comments"},"review_comments":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/112/comments"},"review_comment":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/112/commits"},"statuses":{"href":"https://api.github.com/repos/Vauxoo/rma/statuses/47061a0824c7168862e541553ebd9bfba82ecf44"}}}}