{"action":"created","comment":{"url":"https://api.github.com/repos/Vauxoo/rma/pulls/comments/65383852","id":65383852,"diff_hunk":"@@ -262,52 +262,70 @@ def _get_lots_from_scan_data(self, input_data):\n             # search invoices first\n             invoice_ids = invoice.search([('number', '=', number_serial)])\n             element_searched = False\n-            if invoice_ids:\n \n+            if invoice_ids:\n+                # invoice line field to search lots with the\n+                # that field filled\n                 invoice_field = 'supplier_invoice_line_id'\n                 if customer_claim_type == current_claim_type:\n                     invoice_field = 'invoice_line_id'\n \n-                for inv in invoice_ids:\n-                    for inv_line in inv.invoice_line:\n-                        clw = claim_line_wizard.\\\n-                            search([('invoice_line_id', '=', inv_line.id)])\n-                        enter = False\n-                        lot_ids = lot.\\\n-                            search([(invoice_field, '=',\n-                                     inv_line.id)])\n-                        if len(clw) < int(inv_line.quantity):\n-                            for asd in clw:\n-                                if asd not in lot_set_ids:\n-                                    lot_set_ids.append(asd)\n-                                    lot_ids = lot_ids - asd.lot_id\n-                            num_to_create = int(inv_line.quantity) - len(clw)\n-                            num = 0\n-                            while num < num_to_create:\n-                                clw = \\\n-                                    claim_line_wizard.\\\n-                                    create({\n-                                        'product_id':\n-                                        inv_line.product_id.id,\n-                                        'invoice_line_id': inv_line.id,\n-                                    })\n-                                if lot_ids:\n-                                    lot = lot_ids[0]\n-                                    clw.write({'lot_id': lot.id})\n-                                    lot_ids = lot_ids - lot\n-                                for asd in clw:\n-                                    if asd not in lot_set_ids:\n-                                        lot_set_ids.append(asd)\n-                                num += 1\n-                            enter = True\n-                        if not enter:\n-                            for asd in clw:\n-                                if asd not in lot_set_ids:\n-                                    if lot_ids:\n-                                        lot = lot_ids[0]\n-                                        asd.write({'lot_id': lot.id})\n-                                        lot_ids = lot_ids - lot\n-                                    lot_set_ids.append(asd)\n+                invoice_lines = invoice_ids.mapped(\"invoice_line\")\n+                for inv_line in invoice_lines:\n+\n+                    enter = False\n+                    # Search items displayed with the current invoice line\n+                    current_items_on_the_wizard = claim_line_wizard.\\\n+                        search([('invoice_line_id', '=', inv_line.id)])\n+\n+                    # Search serial/lot numbers with that invoice line\n+                    lot_ids = lot.search([(invoice_field, '=', inv_line.id)])\n+\n+                    # The list of products to display should be the same\n+                    # quantity of total products in the invoice, that\n+                    # includes taking into account the quantities of each\n+                    # invoice line\n+\n+                    # Calculate the missing items to create\n+                    num_to_create = int(inv_line.quantity) - \\\n+                        len(current_items_on_the_wizard)\n+                    num = 0\n+                    while num < num_to_create:\n+\n+                        # Displays missing product of invoice line\n+                        # on the wizard\n+                        for item in current_items_on_the_wizard:\n+                            if item not in lot_set_ids:\n+                                lot_set_ids.append(item)\n+                                lot_ids -= item.lot_id\n+\n+                        new_item_on_the_wizard = \\\n+                            claim_line_wizard.create({\n+                                'product_id': inv_line.product_id.id,\n+                                'invoice_line_id': inv_line.id,\n+                            })\n+                        # If in the invoice line there are products with\n+                        # serial/lot numbers, displays serial/lot number\n+                        if lot_ids:\n+                            lot = lot_ids[0]\n+                            new_item_on_the_wizard.write({'lot_id': lot.id})\n+                            lot_ids -= lot\n+\n+                        if new_item_on_the_wizard not in lot_set_ids:\n+                            lot_set_ids.append(new_item_on_the_wizard)\n+                        num += 1\n+\n+                        enter = True\n+\n+                    # Si todavia hay productos pertencientes a la linea\n+                    # de factura sin lote y aun hay lotes por asignar\n+                    if not enter:\n+                        for asd in current_items_on_the_wizard:","path":"crm_rma_lot_mass_return/wizards/returned_lines_from_serial.py","position":103,"original_position":103,"commit_id":"e6277ff157059bcb39b8fa1975857c6220d5ba9c","original_commit_id":"e6277ff157059bcb39b8fa1975857c6220d5ba9c","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":"Better name for variables... By example asd to item_wizard","created_at":"2016-06-01T15:28:48Z","updated_at":"2016-06-01T15:28:48Z","html_url":"https://github.com/Vauxoo/rma/pull/130#discussion_r65383852","pull_request_url":"https://api.github.com/repos/Vauxoo/rma/pulls/130","_links":{"self":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/comments/65383852"},"html":{"href":"https://github.com/Vauxoo/rma/pull/130#discussion_r65383852"},"pull_request":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/Vauxoo/rma/pulls/130","id":72195260,"html_url":"https://github.com/Vauxoo/rma/pull/130","diff_url":"https://github.com/Vauxoo/rma/pull/130.diff","patch_url":"https://github.com/Vauxoo/rma/pull/130.patch","issue_url":"https://api.github.com/repos/Vauxoo/rma/issues/130","number":130,"state":"open","locked":false,"title":"[WIP][IMP] too many nested block in method of crm_rma_lot_mass_return","user":{"login":"osvalr","id":2961943,"avatar_url":"https://avatars.githubusercontent.com/u/2961943?v=3","gravatar_id":"","url":"https://api.github.com/users/osvalr","html_url":"https://github.com/osvalr","followers_url":"https://api.github.com/users/osvalr/followers","following_url":"https://api.github.com/users/osvalr/following{/other_user}","gists_url":"https://api.github.com/users/osvalr/gists{/gist_id}","starred_url":"https://api.github.com/users/osvalr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osvalr/subscriptions","organizations_url":"https://api.github.com/users/osvalr/orgs","repos_url":"https://api.github.com/users/osvalr/repos","events_url":"https://api.github.com/users/osvalr/events{/privacy}","received_events_url":"https://api.github.com/users/osvalr/received_events","type":"User","site_admin":false},"body":"## Get #113 solved\r\n\r\n","created_at":"2016-06-01T14:53:28Z","updated_at":"2016-06-01T15:28:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b175748f1ffa62075fe52cac24d3428c168babc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Vauxoo/rma/pulls/130/commits","review_comments_url":"https://api.github.com/repos/Vauxoo/rma/pulls/130/comments","review_comment_url":"https://api.github.com/repos/Vauxoo/rma/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Vauxoo/rma/issues/130/comments","statuses_url":"https://api.github.com/repos/Vauxoo/rma/statuses/e6277ff157059bcb39b8fa1975857c6220d5ba9c","head":{"label":"vauxoo-dev:8.0-too_many_nested_blocks_lot_mass_return-dev-yani","ref":"8.0-too_many_nested_blocks_lot_mass_return-dev-yani","sha":"e6277ff157059bcb39b8fa1975857c6220d5ba9c","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-31T21:04:55Z","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":2524,"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":"0aa7c09bcda830dd04376edbb81f424d12af645b","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-06-01T14:53:28Z","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":2367,"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":13,"forks":3,"open_issues":13,"watchers":1,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/130"},"html":{"href":"https://github.com/Vauxoo/rma/pull/130"},"issue":{"href":"https://api.github.com/repos/Vauxoo/rma/issues/130"},"comments":{"href":"https://api.github.com/repos/Vauxoo/rma/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Vauxoo/rma/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/Vauxoo/rma/statuses/e6277ff157059bcb39b8fa1975857c6220d5ba9c"}}}}
{"actor":{"display_login":"yaniaular"}}