{"action":"created","comment":{"url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments/42856729","id":42856729,"diff_hunk":"@@ -28,82 +28,70 @@ def create_produce_cost_line(self, amount):\n         task_obj = self.env['project.task']\n         analytic_line_obj = self.env['account.analytic.line']\n         for record in self:\n-            if amount > 0.0:\n-                if record.production_id:\n-                    product = record.product_id\n-                    production = record.production_id\n-                    journal_id = self.env.ref(\n-                        'mrp.analytic_journal_materials', False)\n-                    name = ('Final product - ' + (production.name or '') +\n-                            '-' + (product.default_code or ''))\n-                    vals = production._prepare_real_cost_analytic_line(\n-                        journal_id, name, production, product,\n-                        qty=record.product_qty, amount=amount)\n-                    task = task_obj.search(\n-                        [('mrp_production_id', '=', production.id),\n-                         ('wk_order', '=', False)])\n-                    vals['task_id'] = task and task[0].id or False\n-                    analytic_line_obj.create(vals)\n+            if amount <= 0.0 or not record.production_id:\n+                continue\n+            production = record.production_id\n+            journal_id = self.env.ref('mrp.analytic_journal_materials', False)\n+            name = ('Final product - ' + (production.name or '') +\n+                    '-' + (record.product_id.default_code or ''))\n+            vals = production._prepare_real_cost_analytic_line(\n+                journal_id, name, production, record.product_id,\n+                qty=record.product_qty, amount=amount)\n+            task = task_obj.search([('mrp_production_id', '=', production.id),\n+                                    ('wk_order', '=', False)])\n+            vals['task_id'] = task and task[0].id or False\n+            analytic_line_obj.create(vals)\n \n     @api.multi\n-    def action_consume(self, product_qty, location_id=False,\n-                       restrict_lot_id=False, restrict_partner_id=False,\n-                       consumed_for=False):\n+    def action_done(self):\n         task_obj = self.env['project.task']\n         analytic_line_obj = self.env['account.analytic.line']\n-        result = super(StockMove, self).action_consume(\n-            product_qty, location_id=location_id,\n-            restrict_lot_id=restrict_lot_id,\n-            restrict_partner_id=restrict_partner_id, consumed_for=consumed_for)\n+        result = super(StockMove, self).action_done()\n         for record in self:\n-            price = record.product_id.cost_price\n-            if price > 0.0:\n-                if record.raw_material_production_id:\n-                    product = record.product_id\n-                    journal_id = self.env.ref(\n-                        'mrp.analytic_journal_materials', False)\n-                    production = record.raw_material_production_id\n-                    name = (\n-                        (production.name or '') + '-' +\n-                        (record.work_order.routing_wc_line.operation.code or\n-                         '') + '-' + (product.default_code or ''))\n-                    analytic_vals = (\n-                        production._prepare_real_cost_analytic_line(\n-                            journal_id, name, production, product,\n-                            workorder=record.work_order,\n-                            qty=record.product_qty,\n-                            amount=(-price * record.product_qty)))\n-                    task = task_obj.search(\n-                        [('mrp_production_id', '=', production.id),\n-                         ('wk_order', '=', False)])\n-                    analytic_vals['task_id'] = task and task[0].id or False\n-                    analytic_line_obj.create(analytic_vals)\n+            if not record.raw_material_production_id:\n+                continue\n+            if not record.product_id.cost_price:\n+                continue\n+            journal_id = self.env.ref('mrp.analytic_journal_materials', False)\n+            production = record.raw_material_production_id\n+            name = ((production.name or '') + '-' +\n+                    (record.work_order.routing_wc_line.operation.code or '') +\n+                    '-' + (record.product_id.default_code or ''))\n+            analytic_vals = (production._prepare_real_cost_analytic_line(\n+                journal_id, name, production, record.product_id,\n+                workorder=record.work_order, qty=record.product_qty,\n+                amount=(-record.product_id.cost_price * record.product_qty)))\n+            task = task_obj.search([('mrp_production_id', '=', production.id),\n+                                    ('wk_order', '=', False)])\n+            analytic_vals['task_id'] = task and task[0].id or False\n+            analytic_line_obj.create(analytic_vals)\n         return result\n \n     @api.multi\n     def product_price_update_production_done(self):\n         for move in self:\n-            if (move.production_id) and (move.product_id.cost_method ==\n-                                         'average'):\n-                prod_total_cost = move.production_id.calc_mrp_real_cost()\n-                product = move.product_id\n-                product_avail = product.qty_available\n-                amount_unit = product.cost_price\n-                template_avail = product.product_tmpl_id.qty_available\n-                template_price = product.standard_price\n-                if move.state == 'done':\n-                    product_avail -= move.product_qty\n-                    template_avail -= move.product_qty\n-                new_cost_price = ((amount_unit * product_avail +\n-                                  prod_total_cost) /\n-                                  ((product_avail >= 0.0 and product_avail or\n-                                    0.0) + move.product_qty))\n-                new_std_price = ((template_price * template_avail +\n-                                  prod_total_cost) /\n-                                 ((template_avail >= 0.0 and template_avail or\n-                                   0.0) + move.product_qty))\n-                product.sudo().write({'cost_price': new_cost_price,\n-                                      'standard_price': new_std_price})\n+            if not move.production_id:","path":"mrp_production_real_costs/models/stock_move.py","position":112,"original_position":112,"commit_id":"3c4e3ac9b994d97a41d3e5f253bf36b50f1c159b","original_commit_id":"3c4e3ac9b994d97a41d3e5f253bf36b50f1c159b","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":"Ídem","created_at":"2015-10-23T11:52:15Z","updated_at":"2015-10-23T11:52:15Z","html_url":"https://github.com/odoomrp/odoomrp-wip/pull/1023#discussion_r42856729","pull_request_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023","_links":{"self":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments/42856729"},"html":{"href":"https://github.com/odoomrp/odoomrp-wip/pull/1023#discussion_r42856729"},"pull_request":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023"}}},"pull_request":{"url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023","id":47252710,"html_url":"https://github.com/odoomrp/odoomrp-wip/pull/1023","diff_url":"https://github.com/odoomrp/odoomrp-wip/pull/1023.diff","patch_url":"https://github.com/odoomrp/odoomrp-wip/pull/1023.patch","issue_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/1023","number":1023,"state":"open","locked":false,"title":"[IMP] mrp_production ajustes en costes","user":{"login":"agaldona","id":8297237,"avatar_url":"https://avatars.githubusercontent.com/u/8297237?v=3","gravatar_id":"","url":"https://api.github.com/users/agaldona","html_url":"https://github.com/agaldona","followers_url":"https://api.github.com/users/agaldona/followers","following_url":"https://api.github.com/users/agaldona/following{/other_user}","gists_url":"https://api.github.com/users/agaldona/gists{/gist_id}","starred_url":"https://api.github.com/users/agaldona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agaldona/subscriptions","organizations_url":"https://api.github.com/users/agaldona/orgs","repos_url":"https://api.github.com/users/agaldona/repos","events_url":"https://api.github.com/users/agaldona/events{/privacy}","received_events_url":"https://api.github.com/users/agaldona/received_events","type":"User","site_admin":false},"body":"[IMP] mrp_production_project_estimated_cost: cargar siempre el coste en producto en positivo\r\n[IMP] mrp_production_real_costs: cargar coste unitario en quant finalizado cada vez que se produce y al finalizar la OF\r\nCloses #1001 #1010","created_at":"2015-10-09T09:48:44Z","updated_at":"2015-10-23T11:52:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a99c884d6be3ad52eadb8d78a1b0dd663167fb32","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023/commits","review_comments_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023/comments","review_comment_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/1023/comments","statuses_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/statuses/3c4e3ac9b994d97a41d3e5f253bf36b50f1c159b","head":{"label":"agaldona:8.0-costes","ref":"8.0-costes","sha":"3c4e3ac9b994d97a41d3e5f253bf36b50f1c159b","user":{"login":"agaldona","id":8297237,"avatar_url":"https://avatars.githubusercontent.com/u/8297237?v=3","gravatar_id":"","url":"https://api.github.com/users/agaldona","html_url":"https://github.com/agaldona","followers_url":"https://api.github.com/users/agaldona/followers","following_url":"https://api.github.com/users/agaldona/following{/other_user}","gists_url":"https://api.github.com/users/agaldona/gists{/gist_id}","starred_url":"https://api.github.com/users/agaldona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agaldona/subscriptions","organizations_url":"https://api.github.com/users/agaldona/orgs","repos_url":"https://api.github.com/users/agaldona/repos","events_url":"https://api.github.com/users/agaldona/events{/privacy}","received_events_url":"https://api.github.com/users/agaldona/received_events","type":"User","site_admin":false},"repo":{"id":24679974,"name":"odoomrp-wip-1","full_name":"agaldona/odoomrp-wip-1","owner":{"login":"agaldona","id":8297237,"avatar_url":"https://avatars.githubusercontent.com/u/8297237?v=3","gravatar_id":"","url":"https://api.github.com/users/agaldona","html_url":"https://github.com/agaldona","followers_url":"https://api.github.com/users/agaldona/followers","following_url":"https://api.github.com/users/agaldona/following{/other_user}","gists_url":"https://api.github.com/users/agaldona/gists{/gist_id}","starred_url":"https://api.github.com/users/agaldona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agaldona/subscriptions","organizations_url":"https://api.github.com/users/agaldona/orgs","repos_url":"https://api.github.com/users/agaldona/repos","events_url":"https://api.github.com/users/agaldona/events{/privacy}","received_events_url":"https://api.github.com/users/agaldona/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/agaldona/odoomrp-wip-1","description":"WIP of OdooMRP","fork":true,"url":"https://api.github.com/repos/agaldona/odoomrp-wip-1","forks_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/forks","keys_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/teams","hooks_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/hooks","issue_events_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/issues/events{/number}","events_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/events","assignees_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/assignees{/user}","branches_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/branches{/branch}","tags_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/tags","blobs_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/statuses/{sha}","languages_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/languages","stargazers_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/stargazers","contributors_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/contributors","subscribers_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/subscribers","subscription_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/subscription","commits_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/contents/{+path}","compare_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/merges","archive_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/downloads","issues_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/issues{/number}","pulls_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/pulls{/number}","milestones_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/milestones{/number}","notifications_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/labels{/name}","releases_url":"https://api.github.com/repos/agaldona/odoomrp-wip-1/releases{/id}","created_at":"2014-10-01T13:44:53Z","updated_at":"2015-04-14T08:56:22Z","pushed_at":"2015-10-23T11:37:16Z","git_url":"git://github.com/agaldona/odoomrp-wip-1.git","ssh_url":"git@github.com:agaldona/odoomrp-wip-1.git","clone_url":"https://github.com/agaldona/odoomrp-wip-1.git","svn_url":"https://github.com/agaldona/odoomrp-wip-1","homepage":"http://www.odoomrp.com","size":4681,"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":"odoomrp:8.0","ref":"8.0","sha":"f7e52019939c133e13b179cb30597ca4d4266990","user":{"login":"odoomrp","id":7858947,"avatar_url":"https://avatars.githubusercontent.com/u/7858947?v=3","gravatar_id":"","url":"https://api.github.com/users/odoomrp","html_url":"https://github.com/odoomrp","followers_url":"https://api.github.com/users/odoomrp/followers","following_url":"https://api.github.com/users/odoomrp/following{/other_user}","gists_url":"https://api.github.com/users/odoomrp/gists{/gist_id}","starred_url":"https://api.github.com/users/odoomrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoomrp/subscriptions","organizations_url":"https://api.github.com/users/odoomrp/orgs","repos_url":"https://api.github.com/users/odoomrp/repos","events_url":"https://api.github.com/users/odoomrp/events{/privacy}","received_events_url":"https://api.github.com/users/odoomrp/received_events","type":"Organization","site_admin":false},"repo":{"id":22124768,"name":"odoomrp-wip","full_name":"odoomrp/odoomrp-wip","owner":{"login":"odoomrp","id":7858947,"avatar_url":"https://avatars.githubusercontent.com/u/7858947?v=3","gravatar_id":"","url":"https://api.github.com/users/odoomrp","html_url":"https://github.com/odoomrp","followers_url":"https://api.github.com/users/odoomrp/followers","following_url":"https://api.github.com/users/odoomrp/following{/other_user}","gists_url":"https://api.github.com/users/odoomrp/gists{/gist_id}","starred_url":"https://api.github.com/users/odoomrp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoomrp/subscriptions","organizations_url":"https://api.github.com/users/odoomrp/orgs","repos_url":"https://api.github.com/users/odoomrp/repos","events_url":"https://api.github.com/users/odoomrp/events{/privacy}","received_events_url":"https://api.github.com/users/odoomrp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odoomrp/odoomrp-wip","description":"WIP of OdooMRP","fork":false,"url":"https://api.github.com/repos/odoomrp/odoomrp-wip","forks_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/forks","keys_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/teams","hooks_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/hooks","issue_events_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/events{/number}","events_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/events","assignees_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/assignees{/user}","branches_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/branches{/branch}","tags_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/tags","blobs_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/statuses/{sha}","languages_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/languages","stargazers_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/stargazers","contributors_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/contributors","subscribers_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/subscribers","subscription_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/subscription","commits_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/contents/{+path}","compare_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/merges","archive_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/downloads","issues_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues{/number}","pulls_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls{/number}","milestones_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/milestones{/number}","notifications_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/labels{/name}","releases_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/releases{/id}","created_at":"2014-07-22T23:29:59Z","updated_at":"2015-10-13T08:05:19Z","pushed_at":"2015-10-23T11:41:19Z","git_url":"git://github.com/odoomrp/odoomrp-wip.git","ssh_url":"git@github.com:odoomrp/odoomrp-wip.git","clone_url":"https://github.com/odoomrp/odoomrp-wip.git","svn_url":"https://github.com/odoomrp/odoomrp-wip","homepage":"http://www.odoomrp.com","size":11092,"stargazers_count":50,"watchers_count":50,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":121,"mirror_url":null,"open_issues_count":40,"forks":121,"open_issues":40,"watchers":50,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023"},"html":{"href":"https://github.com/odoomrp/odoomrp-wip/pull/1023"},"issue":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/1023"},"comments":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/1023/comments"},"review_comments":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023/comments"},"review_comment":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/1023/commits"},"statuses":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/statuses/3c4e3ac9b994d97a41d3e5f253bf36b50f1c159b"}}}}