{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/operating-unit/pulls/comments/82070286","pull_request_review_id":3003649,"id":82070286,"diff_hunk":"@@ -3,14 +3,36 @@\n # Jordi Ballester Alomar\n # © 2015 Serpent Consulting Services Pvt. Ltd. - Sudhir Arya\n # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).\n-from openerp import fields, models\n+from openerp import api, fields, models, _\n+from openerp.exceptions import UserError\n \n \n class CRMLead(models.Model):\n \n     _inherit = 'crm.lead'\n \n+    @api.model\n+    def _get_default_operating_unit(self):\n+        if 'default_team_id' in self.env.context:\n+            team_id = self.env.context['default_team_id']\n+            team = self.env['crm.team'].browse(team_id)\n+            return team.operating_unit_id\n+        else:\n+            return self.env['res.users'].operating_unit_default_get(self._uid)\n+\n     operating_unit_id = fields.Many2one('operating.unit', 'Operating Unit',\n-                                        default=lambda self:\n-                                        self.env['res.users'].\n-                                        operating_unit_default_get(self._uid))\n+                                        default=_get_default_operating_unit)\n+\n+    @api.onchange('team_id')\n+    def onchange_team_id(self):\n+        self.operating_unit_id = self.team_id.operating_unit_id\n+\n+    @api.multi\n+    @api.constrains('team_id', 'operating_unit_id')\n+    def _check_team_operating_unit(self):\n+        for rec in self:","path":"crm_operating_unit/models/crm_lead.py","position":35,"original_position":35,"commit_id":"edbf82877df6859b72f90a70985f50bd1b732e39","original_commit_id":"edbf82877df6859b72f90a70985f50bd1b732e39","user":{"login":"jbeficent","id":7683926,"avatar_url":"https://avatars.githubusercontent.com/u/7683926?v=3","gravatar_id":"","url":"https://api.github.com/users/jbeficent","html_url":"https://github.com/jbeficent","followers_url":"https://api.github.com/users/jbeficent/followers","following_url":"https://api.github.com/users/jbeficent/following{/other_user}","gists_url":"https://api.github.com/users/jbeficent/gists{/gist_id}","starred_url":"https://api.github.com/users/jbeficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbeficent/subscriptions","organizations_url":"https://api.github.com/users/jbeficent/orgs","repos_url":"https://api.github.com/users/jbeficent/repos","events_url":"https://api.github.com/users/jbeficent/events{/privacy}","received_events_url":"https://api.github.com/users/jbeficent/received_events","type":"User","site_admin":false},"body":"The team_id is not a required field in the lead. You might have a lead for an operating unit not associated to a sales team. ","created_at":"2016-10-05T21:04:32Z","updated_at":"2016-10-05T21:04:32Z","html_url":"https://github.com/OCA/operating-unit/pull/35#discussion_r82070286","pull_request_url":"https://api.github.com/repos/OCA/operating-unit/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/comments/82070286"},"html":{"href":"https://github.com/OCA/operating-unit/pull/35#discussion_r82070286"},"pull_request":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/operating-unit/pulls/35","id":88130883,"html_url":"https://github.com/OCA/operating-unit/pull/35","diff_url":"https://github.com/OCA/operating-unit/pull/35.diff","patch_url":"https://github.com/OCA/operating-unit/pull/35.patch","issue_url":"https://api.github.com/repos/OCA/operating-unit/issues/35","number":35,"state":"open","locked":false,"title":"[9.0] sales_team_operating_unit","user":{"login":"jbeficent","id":7683926,"avatar_url":"https://avatars.githubusercontent.com/u/7683926?v=3","gravatar_id":"","url":"https://api.github.com/users/jbeficent","html_url":"https://github.com/jbeficent","followers_url":"https://api.github.com/users/jbeficent/followers","following_url":"https://api.github.com/users/jbeficent/following{/other_user}","gists_url":"https://api.github.com/users/jbeficent/gists{/gist_id}","starred_url":"https://api.github.com/users/jbeficent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbeficent/subscriptions","organizations_url":"https://api.github.com/users/jbeficent/orgs","repos_url":"https://api.github.com/users/jbeficent/repos","events_url":"https://api.github.com/users/jbeficent/events{/privacy}","received_events_url":"https://api.github.com/users/jbeficent/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-05T18:25:42Z","updated_at":"2016-10-05T21:04:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4254cf7bf49720e47717c697e9d5800b9a6905fb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OCA/operating-unit/pulls/35/commits","review_comments_url":"https://api.github.com/repos/OCA/operating-unit/pulls/35/comments","review_comment_url":"https://api.github.com/repos/OCA/operating-unit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/operating-unit/issues/35/comments","statuses_url":"https://api.github.com/repos/OCA/operating-unit/statuses/edbf82877df6859b72f90a70985f50bd1b732e39","head":{"label":"Eficent:9.0-sales_team_operating_unit","ref":"9.0-sales_team_operating_unit","sha":"edbf82877df6859b72f90a70985f50bd1b732e39","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":47545575,"name":"operating-unit","full_name":"Eficent/operating-unit","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/operating-unit","description":"Manage Operating Units in Odoo","fork":true,"url":"https://api.github.com/repos/Eficent/operating-unit","forks_url":"https://api.github.com/repos/Eficent/operating-unit/forks","keys_url":"https://api.github.com/repos/Eficent/operating-unit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Eficent/operating-unit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Eficent/operating-unit/teams","hooks_url":"https://api.github.com/repos/Eficent/operating-unit/hooks","issue_events_url":"https://api.github.com/repos/Eficent/operating-unit/issues/events{/number}","events_url":"https://api.github.com/repos/Eficent/operating-unit/events","assignees_url":"https://api.github.com/repos/Eficent/operating-unit/assignees{/user}","branches_url":"https://api.github.com/repos/Eficent/operating-unit/branches{/branch}","tags_url":"https://api.github.com/repos/Eficent/operating-unit/tags","blobs_url":"https://api.github.com/repos/Eficent/operating-unit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Eficent/operating-unit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Eficent/operating-unit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Eficent/operating-unit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Eficent/operating-unit/statuses/{sha}","languages_url":"https://api.github.com/repos/Eficent/operating-unit/languages","stargazers_url":"https://api.github.com/repos/Eficent/operating-unit/stargazers","contributors_url":"https://api.github.com/repos/Eficent/operating-unit/contributors","subscribers_url":"https://api.github.com/repos/Eficent/operating-unit/subscribers","subscription_url":"https://api.github.com/repos/Eficent/operating-unit/subscription","commits_url":"https://api.github.com/repos/Eficent/operating-unit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Eficent/operating-unit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Eficent/operating-unit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Eficent/operating-unit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Eficent/operating-unit/contents/{+path}","compare_url":"https://api.github.com/repos/Eficent/operating-unit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Eficent/operating-unit/merges","archive_url":"https://api.github.com/repos/Eficent/operating-unit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Eficent/operating-unit/downloads","issues_url":"https://api.github.com/repos/Eficent/operating-unit/issues{/number}","pulls_url":"https://api.github.com/repos/Eficent/operating-unit/pulls{/number}","milestones_url":"https://api.github.com/repos/Eficent/operating-unit/milestones{/number}","notifications_url":"https://api.github.com/repos/Eficent/operating-unit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Eficent/operating-unit/labels{/name}","releases_url":"https://api.github.com/repos/Eficent/operating-unit/releases{/id}","deployments_url":"https://api.github.com/repos/Eficent/operating-unit/deployments","created_at":"2015-12-07T10:33:38Z","updated_at":"2016-01-22T12:11:37Z","pushed_at":"2016-10-05T18:25:16Z","git_url":"git://github.com/Eficent/operating-unit.git","ssh_url":"git@github.com:Eficent/operating-unit.git","clone_url":"https://github.com/Eficent/operating-unit.git","svn_url":"https://github.com/Eficent/operating-unit","homepage":null,"size":496,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":11,"forks":9,"open_issues":11,"watchers":0,"default_branch":"9.0"}},"base":{"label":"OCA:9.0","ref":"9.0","sha":"3f79d64d4fd9636d09cd04aa49afa978d3f8cf1e","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":47409892,"name":"operating-unit","full_name":"OCA/operating-unit","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/operating-unit","description":"Manage Operating Units in Odoo","fork":false,"url":"https://api.github.com/repos/OCA/operating-unit","forks_url":"https://api.github.com/repos/OCA/operating-unit/forks","keys_url":"https://api.github.com/repos/OCA/operating-unit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/operating-unit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/operating-unit/teams","hooks_url":"https://api.github.com/repos/OCA/operating-unit/hooks","issue_events_url":"https://api.github.com/repos/OCA/operating-unit/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/operating-unit/events","assignees_url":"https://api.github.com/repos/OCA/operating-unit/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/operating-unit/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/operating-unit/tags","blobs_url":"https://api.github.com/repos/OCA/operating-unit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/operating-unit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/operating-unit/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/operating-unit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/operating-unit/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/operating-unit/languages","stargazers_url":"https://api.github.com/repos/OCA/operating-unit/stargazers","contributors_url":"https://api.github.com/repos/OCA/operating-unit/contributors","subscribers_url":"https://api.github.com/repos/OCA/operating-unit/subscribers","subscription_url":"https://api.github.com/repos/OCA/operating-unit/subscription","commits_url":"https://api.github.com/repos/OCA/operating-unit/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/operating-unit/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/operating-unit/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/operating-unit/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/operating-unit/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/operating-unit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/operating-unit/merges","archive_url":"https://api.github.com/repos/OCA/operating-unit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/operating-unit/downloads","issues_url":"https://api.github.com/repos/OCA/operating-unit/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/operating-unit/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/operating-unit/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/operating-unit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/operating-unit/labels{/name}","releases_url":"https://api.github.com/repos/OCA/operating-unit/releases{/id}","deployments_url":"https://api.github.com/repos/OCA/operating-unit/deployments","created_at":"2015-12-04T14:51:11Z","updated_at":"2016-09-29T05:59:55Z","pushed_at":"2016-10-05T18:25:42Z","git_url":"git://github.com/OCA/operating-unit.git","ssh_url":"git@github.com:OCA/operating-unit.git","clone_url":"https://github.com/OCA/operating-unit.git","svn_url":"https://github.com/OCA/operating-unit","homepage":null,"size":389,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":25,"forks":19,"open_issues":25,"watchers":3,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/35"},"html":{"href":"https://github.com/OCA/operating-unit/pull/35"},"issue":{"href":"https://api.github.com/repos/OCA/operating-unit/issues/35"},"comments":{"href":"https://api.github.com/repos/OCA/operating-unit/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/operating-unit/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/operating-unit/statuses/edbf82877df6859b72f90a70985f50bd1b732e39"}}}}
{"actor":{"display_login":"jbeficent"}}