{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/web/pulls/comments/33660907","id":33660907,"diff_hunk":"@@ -0,0 +1,39 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+#\n+#    Author: Damien Crier\n+#    Copyright 2015 Camptocamp SA\n+#\n+#    This program is free software: you can redistribute it and/or modify\n+#    it under the terms of the GNU Affero General Public License as\n+#    published by the Free Software Foundation, either version 3 of the\n+#    License, or (at your option) any later version.\n+#\n+#    This program is distributed in the hope that it will be useful,\n+#    but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+#    GNU Affero General Public License for more details.\n+#\n+#    You should have received a copy of the GNU Affero General Public License\n+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+#\n+##############################################################################\n+\n+import openerp\n+\n+\n+class WarningOnSaveController(openerp.addons.web.http.Controller):\n+    _cp_path = \"/web/warning_on_save\"\n+\n+    @openerp.addons.web.http.jsonrequest\n+    def check_warning_on_save(self, req, model, id):\n+        \"\"\"\n+         try to call a method on the model given in parameter\n+         if method does not exist in the model, do nothing\n+        \"\"\"\n+        m = req.session.model(model)\n+        try:\n+            return getattr(m, 'check_warning_on_save')(id, req.context)","path":"web_warning_on_save/controller.py","position":37,"original_position":36,"commit_id":"cc1422efb8d51313690a623207e2a089902e0414","original_commit_id":"f93e6022ac1249146008d5aac4c8a0badcf61b31","user":{"login":"guewen","id":417223,"avatar_url":"https://avatars.githubusercontent.com/u/417223?v=3","gravatar_id":"","url":"https://api.github.com/users/guewen","html_url":"https://github.com/guewen","followers_url":"https://api.github.com/users/guewen/followers","following_url":"https://api.github.com/users/guewen/following{/other_user}","gists_url":"https://api.github.com/users/guewen/gists{/gist_id}","starred_url":"https://api.github.com/users/guewen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guewen/subscriptions","organizations_url":"https://api.github.com/users/guewen/orgs","repos_url":"https://api.github.com/users/guewen/repos","events_url":"https://api.github.com/users/guewen/events{/privacy}","received_events_url":"https://api.github.com/users/guewen/received_events","type":"User","site_admin":false},"body":"hasattr is not possible because the model here is not aware of the methods of the model because it passes over RPC (https://github.com/odoo/odoo/blob/7.0/addons/web/session.py#L40). `getattr` always returns something so it is equivalent to `m.check_warning_on_save(id, req.context)` which should be preferred so.\r\n\r\nRemains one big issue: the server issues a traceback with `AttributeError: 'any.model' object has no attribute 'check_warning_on_save'` every time we save a record, and we must find a way to avoid that.\r\n\r\nThe only poor way I found is by doing something such as:\r\n```python\r\nfrom openerp.osv import orm\r\n\r\n\r\ndef check_warning_on_save(self, cr, uid, id, context=None):\r\n    return False\r\n\r\norm.BaseModel.check_warning_on_save = check_warning_on_save\r\n```","created_at":"2015-07-01T09:11:28Z","updated_at":"2015-07-01T09:11:28Z","html_url":"https://github.com/OCA/web/pull/144#discussion_r33660907","pull_request_url":"https://api.github.com/repos/OCA/web/pulls/144","_links":{"self":{"href":"https://api.github.com/repos/OCA/web/pulls/comments/33660907"},"html":{"href":"https://github.com/OCA/web/pull/144#discussion_r33660907"},"pull_request":{"href":"https://api.github.com/repos/OCA/web/pulls/144"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/web/pulls/144","id":37002961,"html_url":"https://github.com/OCA/web/pull/144","diff_url":"https://github.com/OCA/web/pull/144.diff","patch_url":"https://github.com/OCA/web/pull/144.patch","issue_url":"https://api.github.com/repos/OCA/web/issues/144","number":144,"state":"open","locked":false,"title":"[ADD] add module 'web_warning_on_save'","user":{"login":"damdam-s","id":8102312,"avatar_url":"https://avatars.githubusercontent.com/u/8102312?v=3","gravatar_id":"","url":"https://api.github.com/users/damdam-s","html_url":"https://github.com/damdam-s","followers_url":"https://api.github.com/users/damdam-s/followers","following_url":"https://api.github.com/users/damdam-s/following{/other_user}","gists_url":"https://api.github.com/users/damdam-s/gists{/gist_id}","starred_url":"https://api.github.com/users/damdam-s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damdam-s/subscriptions","organizations_url":"https://api.github.com/users/damdam-s/orgs","repos_url":"https://api.github.com/users/damdam-s/repos","events_url":"https://api.github.com/users/damdam-s/events{/privacy}","received_events_url":"https://api.github.com/users/damdam-s/received_events","type":"User","site_admin":false},"body":"allow to display a message concerning the current record (create or write) after it has been saved.","created_at":"2015-06-05T05:55:37Z","updated_at":"2015-07-01T09:11:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1bf2bb63fc75f2d64daa0d432e75ec27aeb98ca","assignee":null,"milestone":{"url":"https://api.github.com/repos/OCA/web/milestones/2","html_url":"https://github.com/OCA/web/milestones/7.0","labels_url":"https://api.github.com/repos/OCA/web/milestones/2/labels","id":819640,"number":2,"title":"7.0","description":"","creator":{"login":"legalsylvain","id":3407482,"avatar_url":"https://avatars.githubusercontent.com/u/3407482?v=3","gravatar_id":"","url":"https://api.github.com/users/legalsylvain","html_url":"https://github.com/legalsylvain","followers_url":"https://api.github.com/users/legalsylvain/followers","following_url":"https://api.github.com/users/legalsylvain/following{/other_user}","gists_url":"https://api.github.com/users/legalsylvain/gists{/gist_id}","starred_url":"https://api.github.com/users/legalsylvain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/legalsylvain/subscriptions","organizations_url":"https://api.github.com/users/legalsylvain/orgs","repos_url":"https://api.github.com/users/legalsylvain/repos","events_url":"https://api.github.com/users/legalsylvain/events{/privacy}","received_events_url":"https://api.github.com/users/legalsylvain/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":19,"state":"open","created_at":"2014-10-09T10:16:24Z","updated_at":"2015-06-30T06:50:16Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/OCA/web/pulls/144/commits","review_comments_url":"https://api.github.com/repos/OCA/web/pulls/144/comments","review_comment_url":"https://api.github.com/repos/OCA/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/web/issues/144/comments","statuses_url":"https://api.github.com/repos/OCA/web/statuses/cc1422efb8d51313690a623207e2a089902e0414","head":{"label":"damdam-s:7.0","ref":"7.0","sha":"cc1422efb8d51313690a623207e2a089902e0414","user":{"login":"damdam-s","id":8102312,"avatar_url":"https://avatars.githubusercontent.com/u/8102312?v=3","gravatar_id":"","url":"https://api.github.com/users/damdam-s","html_url":"https://github.com/damdam-s","followers_url":"https://api.github.com/users/damdam-s/followers","following_url":"https://api.github.com/users/damdam-s/following{/other_user}","gists_url":"https://api.github.com/users/damdam-s/gists{/gist_id}","starred_url":"https://api.github.com/users/damdam-s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damdam-s/subscriptions","organizations_url":"https://api.github.com/users/damdam-s/orgs","repos_url":"https://api.github.com/users/damdam-s/repos","events_url":"https://api.github.com/users/damdam-s/events{/privacy}","received_events_url":"https://api.github.com/users/damdam-s/received_events","type":"User","site_admin":false},"repo":{"id":36914436,"name":"web","full_name":"damdam-s/web","owner":{"login":"damdam-s","id":8102312,"avatar_url":"https://avatars.githubusercontent.com/u/8102312?v=3","gravatar_id":"","url":"https://api.github.com/users/damdam-s","html_url":"https://github.com/damdam-s","followers_url":"https://api.github.com/users/damdam-s/followers","following_url":"https://api.github.com/users/damdam-s/following{/other_user}","gists_url":"https://api.github.com/users/damdam-s/gists{/gist_id}","starred_url":"https://api.github.com/users/damdam-s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damdam-s/subscriptions","organizations_url":"https://api.github.com/users/damdam-s/orgs","repos_url":"https://api.github.com/users/damdam-s/repos","events_url":"https://api.github.com/users/damdam-s/events{/privacy}","received_events_url":"https://api.github.com/users/damdam-s/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/damdam-s/web","description":"Odoo web client UI related addons","fork":true,"url":"https://api.github.com/repos/damdam-s/web","forks_url":"https://api.github.com/repos/damdam-s/web/forks","keys_url":"https://api.github.com/repos/damdam-s/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/damdam-s/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/damdam-s/web/teams","hooks_url":"https://api.github.com/repos/damdam-s/web/hooks","issue_events_url":"https://api.github.com/repos/damdam-s/web/issues/events{/number}","events_url":"https://api.github.com/repos/damdam-s/web/events","assignees_url":"https://api.github.com/repos/damdam-s/web/assignees{/user}","branches_url":"https://api.github.com/repos/damdam-s/web/branches{/branch}","tags_url":"https://api.github.com/repos/damdam-s/web/tags","blobs_url":"https://api.github.com/repos/damdam-s/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/damdam-s/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/damdam-s/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/damdam-s/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/damdam-s/web/statuses/{sha}","languages_url":"https://api.github.com/repos/damdam-s/web/languages","stargazers_url":"https://api.github.com/repos/damdam-s/web/stargazers","contributors_url":"https://api.github.com/repos/damdam-s/web/contributors","subscribers_url":"https://api.github.com/repos/damdam-s/web/subscribers","subscription_url":"https://api.github.com/repos/damdam-s/web/subscription","commits_url":"https://api.github.com/repos/damdam-s/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/damdam-s/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/damdam-s/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/damdam-s/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/damdam-s/web/contents/{+path}","compare_url":"https://api.github.com/repos/damdam-s/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/damdam-s/web/merges","archive_url":"https://api.github.com/repos/damdam-s/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/damdam-s/web/downloads","issues_url":"https://api.github.com/repos/damdam-s/web/issues{/number}","pulls_url":"https://api.github.com/repos/damdam-s/web/pulls{/number}","milestones_url":"https://api.github.com/repos/damdam-s/web/milestones{/number}","notifications_url":"https://api.github.com/repos/damdam-s/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/damdam-s/web/labels{/name}","releases_url":"https://api.github.com/repos/damdam-s/web/releases{/id}","created_at":"2015-06-05T05:49:23Z","updated_at":"2015-06-05T05:49:24Z","pushed_at":"2015-06-29T08:01:16Z","git_url":"git://github.com/damdam-s/web.git","ssh_url":"git@github.com:damdam-s/web.git","clone_url":"https://github.com/damdam-s/web.git","svn_url":"https://github.com/damdam-s/web","homepage":"","size":4282,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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:7.0","ref":"7.0","sha":"8bb39ea98ce2954792e65857017777595c2d84c3","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":20895915,"name":"web","full_name":"OCA/web","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/web","description":"Odoo web client UI related addons","fork":false,"url":"https://api.github.com/repos/OCA/web","forks_url":"https://api.github.com/repos/OCA/web/forks","keys_url":"https://api.github.com/repos/OCA/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/web/teams","hooks_url":"https://api.github.com/repos/OCA/web/hooks","issue_events_url":"https://api.github.com/repos/OCA/web/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/web/events","assignees_url":"https://api.github.com/repos/OCA/web/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/web/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/web/tags","blobs_url":"https://api.github.com/repos/OCA/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/web/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/web/languages","stargazers_url":"https://api.github.com/repos/OCA/web/stargazers","contributors_url":"https://api.github.com/repos/OCA/web/contributors","subscribers_url":"https://api.github.com/repos/OCA/web/subscribers","subscription_url":"https://api.github.com/repos/OCA/web/subscription","commits_url":"https://api.github.com/repos/OCA/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/web/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/web/merges","archive_url":"https://api.github.com/repos/OCA/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/web/downloads","issues_url":"https://api.github.com/repos/OCA/web/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/web/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/web/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/web/labels{/name}","releases_url":"https://api.github.com/repos/OCA/web/releases{/id}","created_at":"2014-06-16T18:34:12Z","updated_at":"2015-06-20T20:52:00Z","pushed_at":"2015-07-01T09:10:30Z","git_url":"git://github.com/OCA/web.git","ssh_url":"git@github.com:OCA/web.git","clone_url":"https://github.com/OCA/web.git","svn_url":"https://github.com/OCA/web","homepage":"","size":6675,"stargazers_count":42,"watchers_count":42,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"open_issues_count":42,"forks":118,"open_issues":42,"watchers":42,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/web/pulls/144"},"html":{"href":"https://github.com/OCA/web/pull/144"},"issue":{"href":"https://api.github.com/repos/OCA/web/issues/144"},"comments":{"href":"https://api.github.com/repos/OCA/web/issues/144/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/web/pulls/144/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/web/pulls/144/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/web/statuses/cc1422efb8d51313690a623207e2a089902e0414"}}}}