{"action":"created","comment":{"url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments/77837634","id":77837634,"diff_hunk":"@@ -80,19 +80,22 @@ def _compute_period_locked(self):\n     @api.depends('week_start_date', 'week_end_date')\n     @api.multi\n     def _compute_demand_events(self):\n-        days_before_event = int(self.env['ir.config_parameter'].get_param(\n-            'crm_compassion.days_allocate_before_event'))\n         for week in self.filtered('week_start_date').filtered('week_end_date'):\n-            start_date = fields.Date.from_string(week.week_start_date) + \\\n-                timedelta(days=days_before_event)\n-            end_date = fields.Date.from_string(week.week_end_date) + \\\n-                timedelta(days=days_before_event)\n             events = self.env['crm.event.compassion'].search([\n-                ('start_date', '>=', fields.Date.to_string(start_date)),\n-                ('start_date', '<=', fields.Date.to_string(end_date)),\n+                ('hold_start_date', '>=', week.week_start_date),\n+                ('start_date', '<=', week.week_end_date)\n             ])\n-            allocate = sum(events.mapped('number_allocate_children'))\n-            resupply = allocate - sum(events.mapped('planned_sponsorships'))\n+            allocate = 0\n+            weeks_before_event = 0\n+            for event in events:\n+                weeks_before_event = (\n+                     fields.Date.from_string(event.hold_start_date) -\n+                     fields.Date.from_string(event.start_date)\n+                 ).days / 7\n+                allocate += event.number_allocate_children\n+            resupply = allocate","path":"crm_compassion/models/weekly_demand.py","position":27,"original_position":27,"commit_id":"d141d69b0f0968dc70be2275546bfb744cd48f56","original_commit_id":"d141d69b0f0968dc70be2275546bfb744cd48f56","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":"This is wrong. You should compute allocate and resupply for each event.\r\n```\r\nfor event in event:\r\n    event_allocate = event.number_allocate_children / weeks_before_event (if >1)\r\n    allocate += event_allocate\r\n```\r\nResupply is computed in another way. I will explain it another comment.","created_at":"2016-09-07T14:50:23Z","updated_at":"2016-09-07T14:50:23Z","html_url":"https://github.com/CompassionCH/compassion-modules/pull/323#discussion_r77837634","pull_request_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323","_links":{"self":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/comments/77837634"},"html":{"href":"https://github.com/CompassionCH/compassion-modules/pull/323#discussion_r77837634"},"pull_request":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323"}}},"pull_request":{"url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323","id":84003614,"html_url":"https://github.com/CompassionCH/compassion-modules/pull/323","diff_url":"https://github.com/CompassionCH/compassion-modules/pull/323.diff","patch_url":"https://github.com/CompassionCH/compassion-modules/pull/323.patch","issue_url":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/323","number":323,"state":"open","locked":false,"title":"CO-417 Add Hold Start Date field on Events","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-09-05T13:37:59Z","updated_at":"2016-09-07T14:50:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e9900993ae8c398a135fb4ba6844e1302ac6a45c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323/commits","review_comments_url":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323/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/323/comments","statuses_url":"https://api.github.com/repos/CompassionCH/compassion-modules/statuses/d141d69b0f0968dc70be2275546bfb744cd48f56","head":{"label":"maxime-beck:CO-417","ref":"CO-417","sha":"d141d69b0f0968dc70be2275546bfb744cd48f56","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":66821016,"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-08-29T07:20:15Z","updated_at":"2016-08-29T07:20:19Z","pushed_at":"2016-09-07T12:51:10Z","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":7406,"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":"03be401a92e25a1b21dd22f77bb4dc7d5ae54f95","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-09-07T14:18:48Z","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":8834,"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":5,"forks":11,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323"},"html":{"href":"https://github.com/CompassionCH/compassion-modules/pull/323"},"issue":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/323"},"comments":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/issues/323/comments"},"review_comments":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/pulls/323/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/323/commits"},"statuses":{"href":"https://api.github.com/repos/CompassionCH/compassion-modules/statuses/d141d69b0f0968dc70be2275546bfb744cd48f56"}}}}
{"actor":{"display_login":"ecino"}}