{"action":"created","comment":{"url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments/30389341","id":30389341,"diff_hunk":"@@ -0,0 +1,186 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+# For copyright and license notices, see __openerp__.py file in root directory\n+##############################################################################\n+from openerp import models, fields, api, exceptions, _\n+\n+\n+class ProcurementPlan(models.Model):\n+\n+    _name = 'procurement.plan'\n+    _description = 'Procurement Plan'\n+    _rec_name = 'sequence'\n+\n+    @api.one\n+    @api.depends('procurement_ids', 'procurement_ids.state')\n+    def _get_state(self):\n+        self.state = 'running'\n+        if not self.procurement_ids:\n+            self.state = 'draft'\n+        elif (len(self.procurement_ids.filtered(\n+                lambda x: x.state == 'draft')) == len(self.procurement_ids)):\n+            self.state = 'draft'\n+        elif (len(self.procurement_ids.filtered(\n+                lambda x: x.state == 'done')) == len(self.procurement_ids)):\n+            self.state = 'done'\n+        elif (len(self.procurement_ids.filtered(\n+                lambda x: x.state == 'cancel')) == len(self.procurement_ids)):\n+            self.state = 'cancel'\n+\n+    @api.multi\n+    def _get_plan_sequence(self):\n+        sequence = self.env['ir.sequence'].next_by_code('procurement.plan')\n+        return sequence\n+\n+    @api.one\n+    def _count_num_procurements(self):\n+        self.num_procurements = len(self.procurement_ids)\n+\n+    name = fields.Char(string='Description', required=True, readonly=True,\n+                       states={'draft': [('readonly', False)]},\n+                       default=\"/\")\n+    sequence = fields.Char(string='Sequence', readonly=True,\n+                           default=_get_plan_sequence)\n+    from_date = fields.Date(\n+        string='From Date', readonly=True,\n+        states={'draft': [('readonly', False)]})\n+    to_date = fields.Date(\n+        string='to Date', readonly=True,\n+        states={'draft': [('readonly', False)]})\n+    project_id = fields.Many2one('project.project', string='Project',\n+                                 required=True)\n+    procurement_ids = fields.One2many(\n+        'procurement.order', 'plan', string='Procurements', readonly=True)\n+    num_procurements = fields.Integer(\n+        compute=\"_count_num_procurements\", string=\"Procurements\")\n+    purchase_ids = fields.Many2many(\n+        comodel_name='purchase.order',\n+        relation='rel_procurement_plan_purchase_order', column1='plan_id',\n+        column2='purchase_id', string='Purchase Orders', copy=False)\n+    state = fields.Selection(\n+        [('draft', 'Draft'),\n+         ('running', 'Running'),\n+         ('cancel', 'Cancelled'),\n+         ('done', 'Done')],\n+        string='Status', compute='_get_state', index=True, store=True,\n+        track_visibility='onchange', )\n+\n+    @api.multi\n+    def action_import(self):\n+        self.ensure_one()\n+        proc_obj = self.env['procurement.order']\n+        cond = [('state', '!=', 'done'),\n+                ('plan', '=', False)]\n+        if self.from_date:\n+            cond.append(('date_planned', '>=', self.from_date))\n+        if self.to_date:\n+            cond.append(('date_planned', '<=', self.to_date))\n+        procurements = proc_obj.search(cond)\n+        procurements.write({'plan': self.id})\n+        return True\n+\n+    @api.multi\n+    def button_load_sales(self):\n+        self.ensure_one()\n+        if not self.from_date:\n+            raise exceptions.Warning(\n+                _('Error!: You must enter from date.'))\n+        if not self.to_date:\n+            raise exceptions.Warning(\n+                _('Error!: You must enter to date.'))\n+        if self.from_date > self.to_date:","path":"procurement_plan/models/procurement_plan.py","position":91,"original_position":91,"commit_id":"495e56c739a1628b49d8e70a95284ae28c24ae0e","original_commit_id":"e429d6c070e38a2734d17ff402929a641108601c","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":"Entiendo que esto debe ser un constraint del plan","created_at":"2015-05-15T07:16:07Z","updated_at":"2015-05-15T07:16:07Z","html_url":"https://github.com/odoomrp/odoomrp-wip/pull/799#discussion_r30389341","pull_request_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799","_links":{"self":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/comments/30389341"},"html":{"href":"https://github.com/odoomrp/odoomrp-wip/pull/799#discussion_r30389341"},"pull_request":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799"}}},"pull_request":{"url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799","id":34396643,"html_url":"https://github.com/odoomrp/odoomrp-wip/pull/799","diff_url":"https://github.com/odoomrp/odoomrp-wip/pull/799.diff","patch_url":"https://github.com/odoomrp/odoomrp-wip/pull/799.patch","issue_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/799","number":799,"state":"open","locked":false,"title":"[IMP] procurements_plan, mrp_procurements_plan: Modified modules per cla...","user":{"login":"alfredoavanzosc","id":8257820,"avatar_url":"https://avatars.githubusercontent.com/u/8257820?v=3","gravatar_id":"","url":"https://api.github.com/users/alfredoavanzosc","html_url":"https://github.com/alfredoavanzosc","followers_url":"https://api.github.com/users/alfredoavanzosc/followers","following_url":"https://api.github.com/users/alfredoavanzosc/following{/other_user}","gists_url":"https://api.github.com/users/alfredoavanzosc/gists{/gist_id}","starred_url":"https://api.github.com/users/alfredoavanzosc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfredoavanzosc/subscriptions","organizations_url":"https://api.github.com/users/alfredoavanzosc/orgs","repos_url":"https://api.github.com/users/alfredoavanzosc/repos","events_url":"https://api.github.com/users/alfredoavanzosc/events{/privacy}","received_events_url":"https://api.github.com/users/alfredoavanzosc/received_events","type":"User","site_admin":false},"body":"...im CLM0285-MPS y planificación.\r\n\r\n\"procurements_plan\", y \"mrp_procurements_plan\" modificados de arriba a abajo, a petición de Ana, en reclamación CLM0285-MPS y planificación.","created_at":"2015-04-29T19:21:39Z","updated_at":"2015-05-15T07:16:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"447602f57805b6aff2182159ae16e7624b301a6b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799/commits","review_comments_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799/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/799/comments","statuses_url":"https://api.github.com/repos/odoomrp/odoomrp-wip/statuses/495e56c739a1628b49d8e70a95284ae28c24ae0e","head":{"label":"alfredoavanzosc:odoomrp-procurements_plan","ref":"odoomrp-procurements_plan","sha":"495e56c739a1628b49d8e70a95284ae28c24ae0e","user":{"login":"alfredoavanzosc","id":8257820,"avatar_url":"https://avatars.githubusercontent.com/u/8257820?v=3","gravatar_id":"","url":"https://api.github.com/users/alfredoavanzosc","html_url":"https://github.com/alfredoavanzosc","followers_url":"https://api.github.com/users/alfredoavanzosc/followers","following_url":"https://api.github.com/users/alfredoavanzosc/following{/other_user}","gists_url":"https://api.github.com/users/alfredoavanzosc/gists{/gist_id}","starred_url":"https://api.github.com/users/alfredoavanzosc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfredoavanzosc/subscriptions","organizations_url":"https://api.github.com/users/alfredoavanzosc/orgs","repos_url":"https://api.github.com/users/alfredoavanzosc/repos","events_url":"https://api.github.com/users/alfredoavanzosc/events{/privacy}","received_events_url":"https://api.github.com/users/alfredoavanzosc/received_events","type":"User","site_admin":false},"repo":{"id":34321725,"name":"odoomrp-wip-1","full_name":"alfredoavanzosc/odoomrp-wip-1","owner":{"login":"alfredoavanzosc","id":8257820,"avatar_url":"https://avatars.githubusercontent.com/u/8257820?v=3","gravatar_id":"","url":"https://api.github.com/users/alfredoavanzosc","html_url":"https://github.com/alfredoavanzosc","followers_url":"https://api.github.com/users/alfredoavanzosc/followers","following_url":"https://api.github.com/users/alfredoavanzosc/following{/other_user}","gists_url":"https://api.github.com/users/alfredoavanzosc/gists{/gist_id}","starred_url":"https://api.github.com/users/alfredoavanzosc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alfredoavanzosc/subscriptions","organizations_url":"https://api.github.com/users/alfredoavanzosc/orgs","repos_url":"https://api.github.com/users/alfredoavanzosc/repos","events_url":"https://api.github.com/users/alfredoavanzosc/events{/privacy}","received_events_url":"https://api.github.com/users/alfredoavanzosc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alfredoavanzosc/odoomrp-wip-1","description":"WIP of OdooMRP","fork":true,"url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1","forks_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/forks","keys_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/teams","hooks_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/hooks","issue_events_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/issues/events{/number}","events_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/events","assignees_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/assignees{/user}","branches_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/branches{/branch}","tags_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/tags","blobs_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/statuses/{sha}","languages_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/languages","stargazers_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/stargazers","contributors_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/contributors","subscribers_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/subscribers","subscription_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/subscription","commits_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/contents/{+path}","compare_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/merges","archive_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/downloads","issues_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/issues{/number}","pulls_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/pulls{/number}","milestones_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/milestones{/number}","notifications_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/labels{/name}","releases_url":"https://api.github.com/repos/alfredoavanzosc/odoomrp-wip-1/releases{/id}","created_at":"2015-04-21T10:59:59Z","updated_at":"2015-04-21T11:00:01Z","pushed_at":"2015-05-15T06:38:45Z","git_url":"git://github.com/alfredoavanzosc/odoomrp-wip-1.git","ssh_url":"git@github.com:alfredoavanzosc/odoomrp-wip-1.git","clone_url":"https://github.com/alfredoavanzosc/odoomrp-wip-1.git","svn_url":"https://github.com/alfredoavanzosc/odoomrp-wip-1","homepage":"http://www.odoomrp.com","size":3526,"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":"eb868f0225a63b1561c7e3a741c823329a037530","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-05-11T13:11:20Z","pushed_at":"2015-05-15T06:38:45Z","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":10706,"stargazers_count":34,"watchers_count":34,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":39,"forks":62,"open_issues":39,"watchers":34,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799"},"html":{"href":"https://github.com/odoomrp/odoomrp-wip/pull/799"},"issue":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/799"},"comments":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/issues/799/comments"},"review_comments":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/pulls/799/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/799/commits"},"statuses":{"href":"https://api.github.com/repos/odoomrp/odoomrp-wip/statuses/495e56c739a1628b49d8e70a95284ae28c24ae0e"}}}}