{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/comments/82074526","pull_request_review_id":3004970,"id":82074526,"diff_hunk":"@@ -0,0 +1,146 @@\n+# -*- coding: utf-8 -*-\n+# Copyright 2016 Eficent Business and IT Consulting Services S.L.\n+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).\n+\n+from datetime import datetime\n+\n+from dateutil.relativedelta import relativedelta\n+\n+from openerp import _, api, exceptions, fields, models\n+\n+_PURCHASE_ORDER_LINE_STATE = [\n+    ('none', 'No Purchase'),\n+    ('draft', 'RFQ'),\n+    ('sent', 'RFQ Sent'),\n+    ('to approve', 'To Approve'),\n+    ('purchase', 'Purchase Order'),\n+    ('done', 'Done'),\n+    ('cancel', 'Cancelled')\n+]\n+\n+\n+class PurchaseRequestLine(models.Model):\n+\n+    _inherit = \"purchase.request.line\"\n+\n+    @api.multi\n+    @api.depends('purchase_lines')\n+    def _compute_is_editable(self):\n+        super(PurchaseRequestLine, self)._compute_is_editable()\n+        for rec in self:\n+            if rec.purchase_lines:\n+                rec.is_editable = False\n+\n+    @api.multi\n+    def _compute_purchased_qty(self):\n+        for rec in self:\n+            purchased_qty = 0.0\n+            for purchase_line in rec.purchase_lines:\n+                if purchase_line.state != 'cancel':\n+                    purchased_qty += purchase_line.product_qty\n+            rec.purchased_qty = purchased_qty\n+\n+    @api.multi\n+    @api.depends('purchase_lines.state', 'purchase_lines.order_id.state')\n+    def _compute_purchase_state(self):\n+        for rec in self:\n+            temp_purchase_state = 'none'\n+            if rec.purchase_lines:\n+                if any([po_line.state == 'done' for po_line in\n+                        rec.purchase_lines]):\n+                    temp_purchase_state = 'done'\n+                elif all([po_line.state == 'cancel' for po_line in\n+                          rec.purchase_lines]):\n+                    temp_purchase_state = 'cancel'\n+                elif any([po_line.state == 'purchase' for po_line in\n+                          rec.purchase_lines]):\n+                    temp_purchase_state = 'purchase'\n+                elif any([po_line.state == 'to approve' for po_line in\n+                          rec.purchase_lines]):\n+                    temp_purchase_state = 'to approve'\n+                elif any([po_line.state == 'sent' for po_line in\n+                          rec.purchase_lines]):\n+                    temp_purchase_state = 'sent'\n+                elif all([po_line.state in ('draft', 'cancel') for po_line in\n+                          rec.purchase_lines]):\n+                    temp_purchase_state = 'draft'\n+            rec.purchase_state = temp_purchase_state\n+\n+    purchased_qty = fields.Float(string='Quantity in RFQ or PO',\n+                                 compute=\"_compute_purchased_qty\")\n+    purchase_lines = fields.Many2many(\n+        'purchase.order.line', 'purchase_request_purchase_order_line_rel',\n+        'purchase_request_line_id',\n+        'purchase_order_line_id', 'Purchase Order Lines',\n+        readonly=True, copy=False)\n+    purchase_state = fields.Selection(compute=\"_compute_purchase_state\",\n+                                      string=\"Purchase Status\",\n+                                      selection=_PURCHASE_ORDER_LINE_STATE,\n+                                      store=True,\n+                                      default='none')\n+\n+    @api.model\n+    def _planned_date(self, request_line, delay=0.0):\n+        company = request_line.company_id\n+        date_planned = datetime.strptime(\n+            request_line.date_required, '%Y-%m-%d') - \\\n+            relativedelta(days=company.po_lead)\n+        if delay:\n+            date_planned -= relativedelta(days=delay)\n+        return date_planned and date_planned.strftime('%Y-%m-%d') \\\n+            or False\n+\n+    @api.model\n+    def _calc_new_qty_price(self, request_line, po_line=None, cancel=False):\n+        uom_obj = self.env['product.uom']\n+        qty = uom_obj._compute_qty(request_line.product_uom_id.id,\n+                                   request_line.product_qty,\n+                                   request_line.product_id.uom_po_id.id)\n+        # Make sure we use the minimum quantity of the partner corresponding\n+        # to the PO. This does not apply in case of dropshipping\n+        supplierinfo_min_qty = 0.0\n+        if not po_line.order_id.dest_address_id:\n+            if po_line.product_id.seller_ids and \\\n+                po_line.product_id.seller_ids[0].id == \\\n+                    po_line.order_id.partner_id.id:\n+                supplierinfo_min_qty = po_line.product_id.seller_ids[0].min_qty\n+            else:\n+                supplierinfo_obj = self.env['product.supplierinfo']\n+                supplierinfos = supplierinfo_obj.search(\n+                    [('name', '=', po_line.order_id.partner_id.id),\n+                     ('product_tmpl_id', '=',\n+                      po_line.product_id.product_tmpl_id.id)])\n+                if supplierinfos:\n+                    supplierinfo_min_qty = supplierinfos[0].min_qty\n+\n+        if supplierinfo_min_qty == 0.0:\n+            qty += po_line.product_qty\n+        else:\n+            # Recompute quantity by adding existing running procurements.\n+            for rl in po_line.purchase_request_lines:\n+                qty += uom_obj._compute_qty(rl.product_uom_id.id,\n+                                            rl.product_qty,\n+                                            rl.product_id.uom_po_id.id)\n+            qty = max(qty, supplierinfo_min_qty) if qty > 0.0 else 0.0\n+\n+        price = po_line.price_unit\n+        if qty != po_line.product_qty:\n+            pricelist_obj = self.pool['product.pricelist']\n+            pricelist_id = po_line.order_id.partner_id.\\\n+                property_product_pricelist.id\n+            price = pricelist_obj.price_get(\n+                self.env.cr, self.env.uid, [pricelist_id],\n+                request_line.product_id.id, qty,\n+                po_line.order_id.partner_id.id,\n+                {'uom': request_line.product_id.uom_po_id.id})[pricelist_id]\n+\n+        return qty, price\n+\n+    @api.multi\n+    def unlink(self):\n+        for line in self:","path":"purchase_request_to_rfq/models/purchase_request.py","position":141,"original_position":141,"commit_id":"d6d2cc7662ce66f0714fd43275db71568d8da364","original_commit_id":"d6d2cc7662ce66f0714fd43275db71568d8da364","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":"`if self.mapped('purchase_lines'):`","created_at":"2016-10-05T21:26:45Z","updated_at":"2016-10-05T21:29:02Z","html_url":"https://github.com/OCA/purchase-workflow/pull/276#discussion_r82074526","pull_request_url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276","_links":{"self":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/comments/82074526"},"html":{"href":"https://github.com/OCA/purchase-workflow/pull/276#discussion_r82074526"},"pull_request":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276","id":87511119,"html_url":"https://github.com/OCA/purchase-workflow/pull/276","diff_url":"https://github.com/OCA/purchase-workflow/pull/276.diff","patch_url":"https://github.com/OCA/purchase-workflow/pull/276.patch","issue_url":"https://api.github.com/repos/OCA/purchase-workflow/issues/276","number":276,"state":"open","locked":false,"title":"[9.0][ADD]purchase request to rfq ","user":{"login":"aheficent","id":19620251,"avatar_url":"https://avatars.githubusercontent.com/u/19620251?v=3","gravatar_id":"","url":"https://api.github.com/users/aheficent","html_url":"https://github.com/aheficent","followers_url":"https://api.github.com/users/aheficent/followers","following_url":"https://api.github.com/users/aheficent/following{/other_user}","gists_url":"https://api.github.com/users/aheficent/gists{/gist_id}","starred_url":"https://api.github.com/users/aheficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aheficent/subscriptions","organizations_url":"https://api.github.com/users/aheficent/orgs","repos_url":"https://api.github.com/users/aheficent/repos","events_url":"https://api.github.com/users/aheficent/events{/privacy}","received_events_url":"https://api.github.com/users/aheficent/received_events","type":"User","site_admin":false},"body":"This module adds the possibility to create or update Requests for Quotation (RFQ) from Purchase Request Lines. This module depends on purchase request, which is used to give notification of requirements of materials . The previuos PR had commits from other modules. It is https://github.com/OCA/purchase-workflow/pull/263","created_at":"2016-09-30T15:07:49Z","updated_at":"2016-10-05T21:29:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b42f0f654b11d57b42bf1a034983120a9aaeb21b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276/commits","review_comments_url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276/comments","review_comment_url":"https://api.github.com/repos/OCA/purchase-workflow/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/purchase-workflow/issues/276/comments","statuses_url":"https://api.github.com/repos/OCA/purchase-workflow/statuses/d6d2cc7662ce66f0714fd43275db71568d8da364","head":{"label":"Eficent:9.0-add-purchase_request_to_rfq","ref":"9.0-add-purchase_request_to_rfq","sha":"d6d2cc7662ce66f0714fd43275db71568d8da364","user":{"login":"Eficent","id":7718403,"avatar_url":"https://avatars.githubusercontent.com/u/7718403?v=3","gravatar_id":"","url":"https://api.github.com/users/Eficent","html_url":"https://github.com/Eficent","followers_url":"https://api.github.com/users/Eficent/followers","following_url":"https://api.github.com/users/Eficent/following{/other_user}","gists_url":"https://api.github.com/users/Eficent/gists{/gist_id}","starred_url":"https://api.github.com/users/Eficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eficent/subscriptions","organizations_url":"https://api.github.com/users/Eficent/orgs","repos_url":"https://api.github.com/users/Eficent/repos","events_url":"https://api.github.com/users/Eficent/events{/privacy}","received_events_url":"https://api.github.com/users/Eficent/received_events","type":"Organization","site_admin":false},"repo":{"id":34731354,"name":"purchase-workflow","full_name":"Eficent/purchase-workflow","owner":{"login":"Eficent","id":7718403,"avatar_url":"https://avatars.githubusercontent.com/u/7718403?v=3","gravatar_id":"","url":"https://api.github.com/users/Eficent","html_url":"https://github.com/Eficent","followers_url":"https://api.github.com/users/Eficent/followers","following_url":"https://api.github.com/users/Eficent/following{/other_user}","gists_url":"https://api.github.com/users/Eficent/gists{/gist_id}","starred_url":"https://api.github.com/users/Eficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eficent/subscriptions","organizations_url":"https://api.github.com/users/Eficent/orgs","repos_url":"https://api.github.com/users/Eficent/repos","events_url":"https://api.github.com/users/Eficent/events{/privacy}","received_events_url":"https://api.github.com/users/Eficent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Eficent/purchase-workflow","description":"Odoo Purchases, Workflow and Organization","fork":true,"url":"https://api.github.com/repos/Eficent/purchase-workflow","forks_url":"https://api.github.com/repos/Eficent/purchase-workflow/forks","keys_url":"https://api.github.com/repos/Eficent/purchase-workflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eficent/purchase-workflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eficent/purchase-workflow/teams","hooks_url":"https://api.github.com/repos/Eficent/purchase-workflow/hooks","issue_events_url":"https://api.github.com/repos/Eficent/purchase-workflow/issues/events{/number}","events_url":"https://api.github.com/repos/Eficent/purchase-workflow/events","assignees_url":"https://api.github.com/repos/Eficent/purchase-workflow/assignees{/user}","branches_url":"https://api.github.com/repos/Eficent/purchase-workflow/branches{/branch}","tags_url":"https://api.github.com/repos/Eficent/purchase-workflow/tags","blobs_url":"https://api.github.com/repos/Eficent/purchase-workflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eficent/purchase-workflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eficent/purchase-workflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eficent/purchase-workflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eficent/purchase-workflow/statuses/{sha}","languages_url":"https://api.github.com/repos/Eficent/purchase-workflow/languages","stargazers_url":"https://api.github.com/repos/Eficent/purchase-workflow/stargazers","contributors_url":"https://api.github.com/repos/Eficent/purchase-workflow/contributors","subscribers_url":"https://api.github.com/repos/Eficent/purchase-workflow/subscribers","subscription_url":"https://api.github.com/repos/Eficent/purchase-workflow/subscription","commits_url":"https://api.github.com/repos/Eficent/purchase-workflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eficent/purchase-workflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eficent/purchase-workflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eficent/purchase-workflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eficent/purchase-workflow/contents/{+path}","compare_url":"https://api.github.com/repos/Eficent/purchase-workflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eficent/purchase-workflow/merges","archive_url":"https://api.github.com/repos/Eficent/purchase-workflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eficent/purchase-workflow/downloads","issues_url":"https://api.github.com/repos/Eficent/purchase-workflow/issues{/number}","pulls_url":"https://api.github.com/repos/Eficent/purchase-workflow/pulls{/number}","milestones_url":"https://api.github.com/repos/Eficent/purchase-workflow/milestones{/number}","notifications_url":"https://api.github.com/repos/Eficent/purchase-workflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eficent/purchase-workflow/labels{/name}","releases_url":"https://api.github.com/repos/Eficent/purchase-workflow/releases{/id}","deployments_url":"https://api.github.com/repos/Eficent/purchase-workflow/deployments","created_at":"2015-04-28T13:14:23Z","updated_at":"2015-05-04T14:55:35Z","pushed_at":"2016-10-05T04:37:19Z","git_url":"git://github.com/Eficent/purchase-workflow.git","ssh_url":"git@github.com:Eficent/purchase-workflow.git","clone_url":"https://github.com/Eficent/purchase-workflow.git","svn_url":"https://github.com/Eficent/purchase-workflow","homepage":"","size":3276,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"7.0-procurement_group_purchase_orders"}},"base":{"label":"OCA:9.0","ref":"9.0","sha":"0a016be6f58367a3b0a05191cae9c41c68275249","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":20882845,"name":"purchase-workflow","full_name":"OCA/purchase-workflow","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/purchase-workflow","description":"Odoo Purchases, Workflow and Organization","fork":false,"url":"https://api.github.com/repos/OCA/purchase-workflow","forks_url":"https://api.github.com/repos/OCA/purchase-workflow/forks","keys_url":"https://api.github.com/repos/OCA/purchase-workflow/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/purchase-workflow/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/purchase-workflow/teams","hooks_url":"https://api.github.com/repos/OCA/purchase-workflow/hooks","issue_events_url":"https://api.github.com/repos/OCA/purchase-workflow/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/purchase-workflow/events","assignees_url":"https://api.github.com/repos/OCA/purchase-workflow/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/purchase-workflow/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/purchase-workflow/tags","blobs_url":"https://api.github.com/repos/OCA/purchase-workflow/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/purchase-workflow/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/purchase-workflow/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/purchase-workflow/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/purchase-workflow/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/purchase-workflow/languages","stargazers_url":"https://api.github.com/repos/OCA/purchase-workflow/stargazers","contributors_url":"https://api.github.com/repos/OCA/purchase-workflow/contributors","subscribers_url":"https://api.github.com/repos/OCA/purchase-workflow/subscribers","subscription_url":"https://api.github.com/repos/OCA/purchase-workflow/subscription","commits_url":"https://api.github.com/repos/OCA/purchase-workflow/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/purchase-workflow/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/purchase-workflow/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/purchase-workflow/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/purchase-workflow/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/purchase-workflow/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/purchase-workflow/merges","archive_url":"https://api.github.com/repos/OCA/purchase-workflow/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/purchase-workflow/downloads","issues_url":"https://api.github.com/repos/OCA/purchase-workflow/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/purchase-workflow/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/purchase-workflow/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/purchase-workflow/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/purchase-workflow/labels{/name}","releases_url":"https://api.github.com/repos/OCA/purchase-workflow/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/purchase-workflow/deployments","created_at":"2014-06-16T11:44:14Z","updated_at":"2016-09-23T04:08:18Z","pushed_at":"2016-10-05T04:37:20Z","git_url":"git://github.com/OCA/purchase-workflow.git","ssh_url":"git@github.com:OCA/purchase-workflow.git","clone_url":"https://github.com/OCA/purchase-workflow.git","svn_url":"https://github.com/OCA/purchase-workflow","homepage":"","size":5294,"stargazers_count":19,"watchers_count":19,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":124,"mirror_url":null,"open_issues_count":79,"forks":124,"open_issues":79,"watchers":19,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276"},"html":{"href":"https://github.com/OCA/purchase-workflow/pull/276"},"issue":{"href":"https://api.github.com/repos/OCA/purchase-workflow/issues/276"},"comments":{"href":"https://api.github.com/repos/OCA/purchase-workflow/issues/276/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/purchase-workflow/pulls/276/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/purchase-workflow/statuses/d6d2cc7662ce66f0714fd43275db71568d8da364"}}}}
{"actor":{"display_login":"pedrobaeza"}}