{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/hr/pulls/comments/73274074","id":73274074,"diff_hunk":"@@ -0,0 +1,77 @@\n+# -*- coding: utf-8 -*-\n+# © 2016 - Eficent http://www.eficent.com/\n+# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).\n+from openerp import models, fields, api\n+from openerp.tools.translate import _\n+from openerp.exceptions import Warning as UserError\n+from openerp import netsvc\n+\n+\n+class HrPaySlipChangeState(models.TransientModel):\n+\n+    _name = \"hr.payslip.change.state\"\n+    _description = \"Change state of a payslip\"\n+\n+    state = fields.Selection([('draft', 'Set to Draft'),\n+                              ('verify', 'Compute Sheet'),\n+                              ('done', 'Confirm'),\n+                              ('cancel', 'Cancel Payslip'),\n+                              ],\n+                             'Action',\n+            help='* When the payslip is created the status is \\'Draft\\'.\\\n+            \\n* If the payslip is under verification, the status is '\n+                 '\\'Compute Sheet\\'. \\\n+            \\n* If the payslip is confirmed then status is set to \\'Done\\'.\\\n+            \\n* When user cancel payslip the status is \\'Rejected\\'.')\n+\n+    @api.multi\n+    def change_state_confirm(self):\n+        record_ids = self.env.context.get('active_ids', False)\n+        payslip_obj = self.env['hr.payslip']\n+        new_state = self.state\n+        records = payslip_obj.browse(record_ids)\n+        wf_service = netsvc.LocalService(\"workflow\")\n+\n+        for rec in records:\n+            if new_state == 'draft':\n+                if rec.state == 'cancel':\n+                    wf_service.trg_validate(self.env.uid, 'hr.payslip',\n+                                            rec.id, 'draft', self.env.cr)\n+                else:\n+                    raise UserError(_(\"Only rejected payslips can be reset to \"\n+                                    \"draft, the payslip %s is in \"\n+                                    \"%s state\" % (rec.name, rec.state)))\n+            elif new_state == 'verify':\n+                if rec.state == 'draft':\n+                    rec.compute_sheet()\n+                else:\n+                    raise UserError(_(\"Only draft payslips can be verified,\"\n+                                    \"the payslip %s is in \"\n+                                    \"%s state\" % (rec.name, rec.state)))\n+            elif new_state == 'done':\n+                if rec.state in ('verify', 'draft'):\n+                    wf_service.trg_validate(self.env.uid, 'hr.payslip',\n+                                            rec.id, 'hr_verify_sheet',\n+                                            self.env.cr)\n+                else:\n+                    raise UserError(_(\"Only payslips in states verify or draft\"\n+                                    \" can be confirmed, the payslip %s is in \"\n+                                    \"%s state\" % (rec.name, rec.state)))\n+            elif new_state == 'cancel':\n+                if rec.state != 'cancel':\n+                    wf_service.trg_validate(self.env.uid, 'hr.payslip',rec.id,\n+                                            'cancel_sheet', self.env.cr)","path":"hr_payslip_change_state/wizard/hr_payslip_change_state.py","position":63,"original_position":63,"commit_id":"4211e5f70f3bf47cf41fb6867089824e7bb6c806","original_commit_id":"4211e5f70f3bf47cf41fb6867089824e7bb6c806","user":{"login":"andhit-r","id":1947376,"avatar_url":"https://avatars.githubusercontent.com/u/1947376?v=3","gravatar_id":"","url":"https://api.github.com/users/andhit-r","html_url":"https://github.com/andhit-r","followers_url":"https://api.github.com/users/andhit-r/followers","following_url":"https://api.github.com/users/andhit-r/following{/other_user}","gists_url":"https://api.github.com/users/andhit-r/gists{/gist_id}","starred_url":"https://api.github.com/users/andhit-r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andhit-r/subscriptions","organizations_url":"https://api.github.com/users/andhit-r/orgs","repos_url":"https://api.github.com/users/andhit-r/repos","events_url":"https://api.github.com/users/andhit-r/events{/privacy}","received_events_url":"https://api.github.com/users/andhit-r/received_events","type":"User","site_admin":false},"body":"use new API","created_at":"2016-08-03T03:00:15Z","updated_at":"2016-08-03T03:00:15Z","html_url":"https://github.com/OCA/hr/pull/249#discussion_r73274074","pull_request_url":"https://api.github.com/repos/OCA/hr/pulls/249","_links":{"self":{"href":"https://api.github.com/repos/OCA/hr/pulls/comments/73274074"},"html":{"href":"https://github.com/OCA/hr/pull/249#discussion_r73274074"},"pull_request":{"href":"https://api.github.com/repos/OCA/hr/pulls/249"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/hr/pulls/249","id":79322938,"html_url":"https://github.com/OCA/hr/pull/249","diff_url":"https://github.com/OCA/hr/pull/249.diff","patch_url":"https://github.com/OCA/hr/pull/249.patch","issue_url":"https://api.github.com/repos/OCA/hr/issues/249","number":249,"state":"open","locked":false,"title":"8.0 hr payslip change state","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":"# HR Payslip Change State\r\n\r\nThis module introduces the following features:\r\n\r\n- This module allows to execute the actions that buttons inside a form do for many payslips at a time.\r\n- The module checks if the required action is allowed for each payslip\r\n- If any of the payslips are not in a suitable state a warning message will pop up and no changes will be made\r\n- If the action succeed a new tree view with the affected records will show\r\n\r\n### Installation\r\n\r\nTo install this module, you need to:\r\n\r\n1. Clone the branch 8.0 of the repository https://github.com/OCA/hr\r\n2. Add the path to this repository in your configuration (addons-path)\r\n3. Update the module list\r\n4. Go to menu *Setting -> Modules -> Local Modules*\r\n5. Search For *HR Payslip Change State*\r\n6. Install the module\r\n\r\nIt depends on hr_payroll_cancel. There is a pull request here:\r\nhttps://github.com/OCA/hr/pull/248\r\n\r\n### Configuration\r\n\r\nNo needed.\r\n\r\n### Usage\r\n\r\n1. Go to the payslip list view and select the ones you want to .\r\n2. Unfold the \"More\" menu on the top and click on \"Change state\"\r\n3. Select the action to execute","created_at":"2016-07-29T08:20:03Z","updated_at":"2016-08-03T03:00:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64c66bb8ccda30319883fd90f9bb135404221f75","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OCA/hr/pulls/249/commits","review_comments_url":"https://api.github.com/repos/OCA/hr/pulls/249/comments","review_comment_url":"https://api.github.com/repos/OCA/hr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/hr/issues/249/comments","statuses_url":"https://api.github.com/repos/OCA/hr/statuses/4211e5f70f3bf47cf41fb6867089824e7bb6c806","head":{"label":"Eficent:8.0-hr_payslip_change_state","ref":"8.0-hr_payslip_change_state","sha":"4211e5f70f3bf47cf41fb6867089824e7bb6c806","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":40491276,"name":"hr","full_name":"Eficent/hr","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/hr","description":"Odoo Human Ressources Addons","fork":true,"url":"https://api.github.com/repos/Eficent/hr","forks_url":"https://api.github.com/repos/Eficent/hr/forks","keys_url":"https://api.github.com/repos/Eficent/hr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eficent/hr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eficent/hr/teams","hooks_url":"https://api.github.com/repos/Eficent/hr/hooks","issue_events_url":"https://api.github.com/repos/Eficent/hr/issues/events{/number}","events_url":"https://api.github.com/repos/Eficent/hr/events","assignees_url":"https://api.github.com/repos/Eficent/hr/assignees{/user}","branches_url":"https://api.github.com/repos/Eficent/hr/branches{/branch}","tags_url":"https://api.github.com/repos/Eficent/hr/tags","blobs_url":"https://api.github.com/repos/Eficent/hr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eficent/hr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eficent/hr/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eficent/hr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eficent/hr/statuses/{sha}","languages_url":"https://api.github.com/repos/Eficent/hr/languages","stargazers_url":"https://api.github.com/repos/Eficent/hr/stargazers","contributors_url":"https://api.github.com/repos/Eficent/hr/contributors","subscribers_url":"https://api.github.com/repos/Eficent/hr/subscribers","subscription_url":"https://api.github.com/repos/Eficent/hr/subscription","commits_url":"https://api.github.com/repos/Eficent/hr/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eficent/hr/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eficent/hr/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eficent/hr/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eficent/hr/contents/{+path}","compare_url":"https://api.github.com/repos/Eficent/hr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eficent/hr/merges","archive_url":"https://api.github.com/repos/Eficent/hr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eficent/hr/downloads","issues_url":"https://api.github.com/repos/Eficent/hr/issues{/number}","pulls_url":"https://api.github.com/repos/Eficent/hr/pulls{/number}","milestones_url":"https://api.github.com/repos/Eficent/hr/milestones{/number}","notifications_url":"https://api.github.com/repos/Eficent/hr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eficent/hr/labels{/name}","releases_url":"https://api.github.com/repos/Eficent/hr/releases{/id}","deployments_url":"https://api.github.com/repos/Eficent/hr/deployments","created_at":"2015-08-10T15:51:09Z","updated_at":"2016-07-18T17:57:14Z","pushed_at":"2016-08-01T08:21:58Z","git_url":"git://github.com/Eficent/hr.git","ssh_url":"git@github.com:Eficent/hr.git","clone_url":"https://github.com/Eficent/hr.git","svn_url":"https://github.com/Eficent/hr","homepage":"","size":4746,"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":"OCA:8.0","ref":"8.0","sha":"7c3c735b40ef2d029ab26d01466e98c48f5f4a6b","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":20891607,"name":"hr","full_name":"OCA/hr","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/hr","description":"Odoo Human Ressources Addons","fork":false,"url":"https://api.github.com/repos/OCA/hr","forks_url":"https://api.github.com/repos/OCA/hr/forks","keys_url":"https://api.github.com/repos/OCA/hr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/hr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/hr/teams","hooks_url":"https://api.github.com/repos/OCA/hr/hooks","issue_events_url":"https://api.github.com/repos/OCA/hr/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/hr/events","assignees_url":"https://api.github.com/repos/OCA/hr/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/hr/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/hr/tags","blobs_url":"https://api.github.com/repos/OCA/hr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/hr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/hr/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/hr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/hr/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/hr/languages","stargazers_url":"https://api.github.com/repos/OCA/hr/stargazers","contributors_url":"https://api.github.com/repos/OCA/hr/contributors","subscribers_url":"https://api.github.com/repos/OCA/hr/subscribers","subscription_url":"https://api.github.com/repos/OCA/hr/subscription","commits_url":"https://api.github.com/repos/OCA/hr/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/hr/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/hr/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/hr/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/hr/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/hr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/hr/merges","archive_url":"https://api.github.com/repos/OCA/hr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/hr/downloads","issues_url":"https://api.github.com/repos/OCA/hr/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/hr/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/hr/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/hr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/hr/labels{/name}","releases_url":"https://api.github.com/repos/OCA/hr/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/hr/deployments","created_at":"2014-06-16T16:15:34Z","updated_at":"2016-08-02T10:00:30Z","pushed_at":"2016-08-01T09:01:27Z","git_url":"git://github.com/OCA/hr.git","ssh_url":"git@github.com:OCA/hr.git","clone_url":"https://github.com/OCA/hr.git","svn_url":"https://github.com/OCA/hr","homepage":"","size":6026,"stargazers_count":29,"watchers_count":29,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":110,"mirror_url":null,"open_issues_count":55,"forks":110,"open_issues":55,"watchers":29,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/hr/pulls/249"},"html":{"href":"https://github.com/OCA/hr/pull/249"},"issue":{"href":"https://api.github.com/repos/OCA/hr/issues/249"},"comments":{"href":"https://api.github.com/repos/OCA/hr/issues/249/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/hr/pulls/249/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/hr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/hr/pulls/249/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/hr/statuses/4211e5f70f3bf47cf41fb6867089824e7bb6c806"}}}}
{"actor":{"display_login":"andhit-r"}}