{"action":"created","comment":{"url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments/72806292","id":72806292,"diff_hunk":"@@ -33,43 +34,84 @@ class WeeklyDemand(models.Model):\n     ##########################################################################\n     @api.model\n     def create(self, vals):\n-        vals = self.update_vals(vals)\n+        self.update_vals(vals)\n         res = super(WeeklyDemand, self).create(vals)\n         return res\n \n     @api.multi\n     def write(self, vals):\n-        vals = self.update_vals(vals)\n+        self.update_vals(vals)\n         res = super(WeeklyDemand, self).write(vals)\n         return res\n \n     ##########################################################################\n     #                             PUBLIC METHODS                             #\n     ##########################################################################\n     def update_vals(self, vals):\n-        starting_date = datetime.strptime(vals.get('week_start_date'),\n-                                          \"%Y-%m-%d\")\n-        if self.check_is_date_in_next_8_weeks(starting_date):\n-            vals['period_locked'] = True\n-        return vals\n+        starting_date = vals.get('week_start_date')\n+        if starting_date:\n+            corrected_date = datetime.strptime(starting_date, \"%Y-%m-%d\")\n+            if self.check_is_date_in_next_8_weeks(corrected_date):\n+                vals['period_locked'] = True\n+            else:\n+                vals['period_locked'] = False\n+        # return vals\n \n     def check_is_date_in_next_8_weeks(self, date):\n         return date <= (datetime.today() + timedelta(weeks=8))\n \n \n class DemandPlanning(models.Model):\n-\n     _name = 'demand.planning'\n     _description = 'Demand Planning'\n \n     name = fields.Char(required=True)\n     date = fields.Date()\n     sent_date = fields.Datetime()\n     state = fields.Selection([\n-        ('new', 'New'),\n+        ('draft', 'Draft'),\n         ('sent', 'Sent'),\n         ('error', 'Error'),\n     ])\n     weekly_demand_ids = fields.Many2many(\n         'demand.weekly.demand', string='Weekly Demands'\n     )\n+\n+    ##########################################################################\n+    #                             ORM METHODS                                #\n+    ##########################################################################\n+    @api.model\n+    def create(self, vals):\n+        res = super(DemandPlanning, self).create(vals)\n+        res.state = 'draft'\n+        return res\n+\n+    @api.multi\n+    def write(self, vals):\n+        res = super(DemandPlanning, self).write(vals)\n+        if not isinstance(res, bool):\n+            res.state = 'draft'\n+        return res\n+\n+    ##########################################################################\n+    #                             PUBLIC METHODS                             #\n+    ##########################################################################\n+    @api.multi\n+    def send_planning(self):\n+        message_obj = self.env['gmc.message.pool']\n+\n+        action_id = self.env.ref(\n+            'crm_compassion.create_demand_planning').id\n+        object_id = self.id\n+        message_vals = {\n+            'action_id': action_id,\n+            'object_id': object_id\n+        }\n+        pool = message_obj.with_context(async_mode=False,\n+                                        creating=True).create(message_vals)","path":"crm_compassion/model/demand_planning.py","position":101,"original_position":101,"commit_id":"709bc6c35ff49c6fc9dd529e332fd55a51962089","original_commit_id":"709bc6c35ff49c6fc9dd529e332fd55a51962089","user":{"login":"ecino","id":8435180,"avatar_url":"https://avatars.githubusercontent.com/u/8435180?v=3","gravatar_id":"","url":"https://api.github.com/users/ecino","html_url":"https://github.com/ecino","followers_url":"https://api.github.com/users/ecino/followers","following_url":"https://api.github.com/users/ecino/following{/other_user}","gists_url":"https://api.github.com/users/ecino/gists{/gist_id}","starred_url":"https://api.github.com/users/ecino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ecino/subscriptions","organizations_url":"https://api.github.com/users/ecino/orgs","repos_url":"https://api.github.com/users/ecino/repos","events_url":"https://api.github.com/users/ecino/events{/privacy}","received_events_url":"https://api.github.com/users/ecino/received_events","type":"User","site_admin":false},"body":"what is creating=True? ","created_at":"2016-07-29T15:01:06Z","updated_at":"2016-07-29T15:01:06Z","html_url":"https://github.com/CompassionCH/compassion-modules/pull/289#discussion_r72806292","pull_request_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289","_links":{"self":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments/72806292"},"html":{"href":"https://github.com/CompassionCH/compassion-modules/pull/289#discussion_r72806292"},"pull_request":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289"}}},"pull_request":{"url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289","id":79212770,"html_url":"https://github.com/CompassionCH/compassion-modules/pull/289","diff_url":"https://github.com/CompassionCH/compassion-modules/pull/289.diff","patch_url":"https://github.com/CompassionCH/compassion-modules/pull/289.patch","issue_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/289","number":289,"state":"open","locked":false,"title":"CO-267 Add support for outcoming GlobalPartnerWeeklyDemandRequest","user":{"login":"maxime-beck","id":20071195,"avatar_url":"https://avatars.githubusercontent.com/u/20071195?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime-beck","html_url":"https://github.com/maxime-beck","followers_url":"https://api.github.com/users/maxime-beck/followers","following_url":"https://api.github.com/users/maxime-beck/following{/other_user}","gists_url":"https://api.github.com/users/maxime-beck/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime-beck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime-beck/subscriptions","organizations_url":"https://api.github.com/users/maxime-beck/orgs","repos_url":"https://api.github.com/users/maxime-beck/repos","events_url":"https://api.github.com/users/maxime-beck/events{/privacy}","received_events_url":"https://api.github.com/users/maxime-beck/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-28T15:05:47Z","updated_at":"2016-07-29T15:01:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b2851f2805610761944fc2ff95e0f8e8846ef25","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289/commits","review_comments_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289/comments","review_comment_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/289/comments","statuses_url":"https://api.github.com/repos/CompassionCH/compassion-modules/statuses/709bc6c35ff49c6fc9dd529e332fd55a51962089","head":{"label":"maxime-beck:master","ref":"master","sha":"709bc6c35ff49c6fc9dd529e332fd55a51962089","user":{"login":"maxime-beck","id":20071195,"avatar_url":"https://avatars.githubusercontent.com/u/20071195?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime-beck","html_url":"https://github.com/maxime-beck","followers_url":"https://api.github.com/users/maxime-beck/followers","following_url":"https://api.github.com/users/maxime-beck/following{/other_user}","gists_url":"https://api.github.com/users/maxime-beck/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime-beck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime-beck/subscriptions","organizations_url":"https://api.github.com/users/maxime-beck/orgs","repos_url":"https://api.github.com/users/maxime-beck/repos","events_url":"https://api.github.com/users/maxime-beck/events{/privacy}","received_events_url":"https://api.github.com/users/maxime-beck/received_events","type":"User","site_admin":false},"repo":{"id":63598948,"name":"compassion-modules","full_name":"maxime-beck/compassion-modules","owner":{"login":"maxime-beck","id":20071195,"avatar_url":"https://avatars.githubusercontent.com/u/20071195?v=3","gravatar_id":"","url":"https://api.github.com/users/maxime-beck","html_url":"https://github.com/maxime-beck","followers_url":"https://api.github.com/users/maxime-beck/followers","following_url":"https://api.github.com/users/maxime-beck/following{/other_user}","gists_url":"https://api.github.com/users/maxime-beck/gists{/gist_id}","starred_url":"https://api.github.com/users/maxime-beck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxime-beck/subscriptions","organizations_url":"https://api.github.com/users/maxime-beck/orgs","repos_url":"https://api.github.com/users/maxime-beck/repos","events_url":"https://api.github.com/users/maxime-beck/events{/privacy}","received_events_url":"https://api.github.com/users/maxime-beck/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maxime-beck/compassion-modules","description":"Odoo modules for Compassion","fork":true,"url":"https://api.github.com/repos/maxime-beck/compassion-modules","forks_url":"https://api.github.com/repos/maxime-beck/compassion-modules/forks","keys_url":"https://api.github.com/repos/maxime-beck/compassion-modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maxime-beck/compassion-modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maxime-beck/compassion-modules/teams","hooks_url":"https://api.github.com/repos/maxime-beck/compassion-modules/hooks","issue_events_url":"https://api.github.com/repos/maxime-beck/compassion-modules/issues/events{/number}","events_url":"https://api.github.com/repos/maxime-beck/compassion-modules/events","assignees_url":"https://api.github.com/repos/maxime-beck/compassion-modules/assignees{/user}","branches_url":"https://api.github.com/repos/maxime-beck/compassion-modules/branches{/branch}","tags_url":"https://api.github.com/repos/maxime-beck/compassion-modules/tags","blobs_url":"https://api.github.com/repos/maxime-beck/compassion-modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maxime-beck/compassion-modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maxime-beck/compassion-modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/maxime-beck/compassion-modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maxime-beck/compassion-modules/statuses/{sha}","languages_url":"https://api.github.com/repos/maxime-beck/compassion-modules/languages","stargazers_url":"https://api.github.com/repos/maxime-beck/compassion-modules/stargazers","contributors_url":"https://api.github.com/repos/maxime-beck/compassion-modules/contributors","subscribers_url":"https://api.github.com/repos/maxime-beck/compassion-modules/subscribers","subscription_url":"https://api.github.com/repos/maxime-beck/compassion-modules/subscription","commits_url":"https://api.github.com/repos/maxime-beck/compassion-modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/maxime-beck/compassion-modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/maxime-beck/compassion-modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/maxime-beck/compassion-modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/maxime-beck/compassion-modules/contents/{+path}","compare_url":"https://api.github.com/repos/maxime-beck/compassion-modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maxime-beck/compassion-modules/merges","archive_url":"https://api.github.com/repos/maxime-beck/compassion-modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maxime-beck/compassion-modules/downloads","issues_url":"https://api.github.com/repos/maxime-beck/compassion-modules/issues{/number}","pulls_url":"https://api.github.com/repos/maxime-beck/compassion-modules/pulls{/number}","milestones_url":"https://api.github.com/repos/maxime-beck/compassion-modules/milestones{/number}","notifications_url":"https://api.github.com/repos/maxime-beck/compassion-modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maxime-beck/compassion-modules/labels{/name}","releases_url":"https://api.github.com/repos/maxime-beck/compassion-modules/releases{/id}","deployments_url":"https://api.github.com/repos/maxime-beck/compassion-modules/deployments","created_at":"2016-07-18T11:52:23Z","updated_at":"2016-07-18T11:52:26Z","pushed_at":"2016-07-29T15:00:39Z","git_url":"git://github.com/maxime-beck/compassion-modules.git","ssh_url":"git@github.com:maxime-beck/compassion-modules.git","clone_url":"https://github.com/maxime-beck/compassion-modules.git","svn_url":"https://github.com/maxime-beck/compassion-modules","homepage":"","size":7141,"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":"master"}},"base":{"label":"CompassionCH:master","ref":"master","sha":"1d0fd193c4157067cb7d4c7d67c2cebb3c1fb6e2","user":{"login":"CompassionCH","id":8435213,"avatar_url":"https://avatars.githubusercontent.com/u/8435213?v=3","gravatar_id":"","url":"https://api.github.com/users/CompassionCH","html_url":"https://github.com/CompassionCH","followers_url":"https://api.github.com/users/CompassionCH/followers","following_url":"https://api.github.com/users/CompassionCH/following{/other_user}","gists_url":"https://api.github.com/users/CompassionCH/gists{/gist_id}","starred_url":"https://api.github.com/users/CompassionCH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CompassionCH/subscriptions","organizations_url":"https://api.github.com/users/CompassionCH/orgs","repos_url":"https://api.github.com/users/CompassionCH/repos","events_url":"https://api.github.com/users/CompassionCH/events{/privacy}","received_events_url":"https://api.github.com/users/CompassionCH/received_events","type":"Organization","site_admin":false},"repo":{"id":23073482,"name":"compassion-modules","full_name":"CompassionCH/compassion-modules","owner":{"login":"CompassionCH","id":8435213,"avatar_url":"https://avatars.githubusercontent.com/u/8435213?v=3","gravatar_id":"","url":"https://api.github.com/users/CompassionCH","html_url":"https://github.com/CompassionCH","followers_url":"https://api.github.com/users/CompassionCH/followers","following_url":"https://api.github.com/users/CompassionCH/following{/other_user}","gists_url":"https://api.github.com/users/CompassionCH/gists{/gist_id}","starred_url":"https://api.github.com/users/CompassionCH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CompassionCH/subscriptions","organizations_url":"https://api.github.com/users/CompassionCH/orgs","repos_url":"https://api.github.com/users/CompassionCH/repos","events_url":"https://api.github.com/users/CompassionCH/events{/privacy}","received_events_url":"https://api.github.com/users/CompassionCH/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CompassionCH/compassion-modules","description":"Odoo modules for Compassion","fork":false,"url":"https://api.github.com/repos/CompassionCH/compassion-modules","forks_url":"https://api.github.com/repos/CompassionCH/compassion-modules/forks","keys_url":"https://api.github.com/repos/CompassionCH/compassion-modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CompassionCH/compassion-modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CompassionCH/compassion-modules/teams","hooks_url":"https://api.github.com/repos/CompassionCH/compassion-modules/hooks","issue_events_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/events{/number}","events_url":"https://api.github.com/repos/CompassionCH/compassion-modules/events","assignees_url":"https://api.github.com/repos/CompassionCH/compassion-modules/assignees{/user}","branches_url":"https://api.github.com/repos/CompassionCH/compassion-modules/branches{/branch}","tags_url":"https://api.github.com/repos/CompassionCH/compassion-modules/tags","blobs_url":"https://api.github.com/repos/CompassionCH/compassion-modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CompassionCH/compassion-modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CompassionCH/compassion-modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/CompassionCH/compassion-modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CompassionCH/compassion-modules/statuses/{sha}","languages_url":"https://api.github.com/repos/CompassionCH/compassion-modules/languages","stargazers_url":"https://api.github.com/repos/CompassionCH/compassion-modules/stargazers","contributors_url":"https://api.github.com/repos/CompassionCH/compassion-modules/contributors","subscribers_url":"https://api.github.com/repos/CompassionCH/compassion-modules/subscribers","subscription_url":"https://api.github.com/repos/CompassionCH/compassion-modules/subscription","commits_url":"https://api.github.com/repos/CompassionCH/compassion-modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/CompassionCH/compassion-modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/CompassionCH/compassion-modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/CompassionCH/compassion-modules/contents/{+path}","compare_url":"https://api.github.com/repos/CompassionCH/compassion-modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CompassionCH/compassion-modules/merges","archive_url":"https://api.github.com/repos/CompassionCH/compassion-modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CompassionCH/compassion-modules/downloads","issues_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues{/number}","pulls_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls{/number}","milestones_url":"https://api.github.com/repos/CompassionCH/compassion-modules/milestones{/number}","notifications_url":"https://api.github.com/repos/CompassionCH/compassion-modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CompassionCH/compassion-modules/labels{/name}","releases_url":"https://api.github.com/repos/CompassionCH/compassion-modules/releases{/id}","deployments_url":"https://api.github.com/repos/CompassionCH/compassion-modules/deployments","created_at":"2014-08-18T14:08:09Z","updated_at":"2016-07-25T05:42:40Z","pushed_at":"2016-07-29T14:57:05Z","git_url":"git://github.com/CompassionCH/compassion-modules.git","ssh_url":"git@github.com:CompassionCH/compassion-modules.git","clone_url":"https://github.com/CompassionCH/compassion-modules.git","svn_url":"https://github.com/CompassionCH/compassion-modules","homepage":"","size":8605,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":8,"forks":11,"open_issues":8,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289"},"html":{"href":"https://github.com/CompassionCH/compassion-modules/pull/289"},"issue":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/289"},"comments":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/289/comments"},"review_comments":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289/comments"},"review_comment":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/289/commits"},"statuses":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/statuses/709bc6c35ff49c6fc9dd529e332fd55a51962089"}}}}
{"actor":{"display_login":"ecino"}}