{"action":"created","comment":{"url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/comments/108740966","pull_request_review_id":29792745,"id":108740966,"diff_hunk":"@@ -0,0 +1,98 @@\n+# -*- coding: utf-8 -*-\n+# © 2017 Savoir-faire Linux\n+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).\n+\n+from openerp import api, fields, models\n+\n+tracked_fields = [\n+    'name', 'date', 'title', 'parent_id', 'parent_name', 'ref', 'lang',\n+    'tz', 'user_id', 'vat', 'website', 'comment', 'credit_limit', 'ean13',\n+    'active', 'customer', 'supplier', 'employee', 'function', 'type',\n+    'street', 'street2', 'zip', 'city', 'state_id', 'country_id', 'email',\n+    'phone', 'fax', 'mobile', 'birthdate', 'is_company',\n+    'use_parent_address', 'has_image', 'company_id', 'color'\n+]\n+\n+\n+class ResPartner(models.Model):\n+    _inherit = 'res.partner'\n+\n+    state = fields.Selection(\n+        string='Status',\n+        selection=[\n+            ('pending', 'To Validate'),\n+            ('controlled', 'Controlled'),\n+        ],\n+        default='controlled',\n+        readonly=True,\n+    )\n+\n+    name = fields.Char(track_visibility='onchange')\n+    date = fields.Date(track_visibility='onchange')\n+    title = fields.Many2one(track_visibility='onchange')\n+    parent_id = fields.Many2one(track_visibility='onchange')\n+    parent_name = fields.Char(track_visibility='onchange')\n+    ref = fields.Char(track_visibility='onchange')\n+    lang = fields.Selection(track_visibility='onchange')\n+    tz = fields.Selection(track_visibility='onchange')\n+    user_id = fields.Many2one(track_visibility='onchange')\n+    vat = fields.Char(track_visibility='onchange')\n+    website = fields.Char(track_visibility='onchange')\n+    comment = fields.Text(track_visibility='onchange')\n+    credit_limit = fields.Float(track_visibility='onchange')\n+    ean13 = fields.Char(track_visibility='onchange')\n+    active = fields.Boolean(track_visibility='onchange')\n+    customer = fields.Boolean(track_visibility='onchange')\n+    supplier = fields.Boolean(track_visibility='onchange')\n+    employee = fields.Boolean(track_visibility='onchange')\n+    function = fields.Char(track_visibility='onchange')\n+    type = fields.Selection(track_visibility='onchange')\n+    street = fields.Char(track_visibility='onchange')\n+    street2 = fields.Char(track_visibility='onchange')\n+    zip = fields.Char(track_visibility='onchange')\n+    city = fields.Char(track_visibility='onchange')\n+    state_id = fields.Many2one(track_visibility='onchange')\n+    country_id = fields.Many2one(track_visibility='onchange')\n+    email = fields.Char(track_visibility='onchange')\n+    phone = fields.Char(track_visibility='onchange')\n+    fax = fields.Char(track_visibility='onchange')\n+    mobile = fields.Char(track_visibility='onchange')\n+    birthdate = fields.Char(track_visibility='onchange')\n+    is_company = fields.Boolean(track_visibility='onchange')\n+    use_parent_address = fields.Boolean(track_visibility='onchange')\n+    has_image = fields.Boolean(track_visibility='onchange')\n+    company_id = fields.Many2one(track_visibility='onchange')\n+    color = fields.Integer(track_visibility='onchange')\n+\n+    @api.multi\n+    def action_set_controlled(self):\n+        \"\"\"\n+        Change the state to 'controlled'.\n+        \"\"\"\n+        for rec in self:\n+            rec.state = 'controlled'\n+\n+    @api.multi\n+    def write(self, vals):\n+        \"\"\"\n+        Change state to 'pending' if values have been updated by a user that\n+        is not part of the validation group\n+        \"\"\"\n+        if self.env.context.get('params'):\n+            user_preferences_action = self.env.ref('base.action_res_users_my')\n+            if (\n+                self.env.context.get('params').get('action') ==\n+                user_preferences_action.id\n+            ):  # write() is called from the user changing his preferences\n+                return super(ResPartner, self).write(vals)\n+        user = self.env['res.users'].browse(self.env.uid)\n+        if not user.has_group('partner_tracking.group_partner_validation'):\n+            for rec in self:\n+                if rec.state == 'controlled':\n+                    tracked_vals = [field for field in vals if (\n+                        field in tracked_fields\n+                    )]\n+                    if any(rec[field] != vals[field] for field in\n+                           tracked_vals):","path":"partner_tracking/models/res_partner.py","position":96,"original_position":96,"commit_id":"6ce6a9fab594b2e84f8d65e19ab8d499edf95b87","original_commit_id":"6ce6a9fab594b2e84f8d65e19ab8d499edf95b87","user":{"login":"dufresnedavid","id":8628981,"avatar_url":"https://avatars3.githubusercontent.com/u/8628981?v=3","gravatar_id":"","url":"https://api.github.com/users/dufresnedavid","html_url":"https://github.com/dufresnedavid","followers_url":"https://api.github.com/users/dufresnedavid/followers","following_url":"https://api.github.com/users/dufresnedavid/following{/other_user}","gists_url":"https://api.github.com/users/dufresnedavid/gists{/gist_id}","starred_url":"https://api.github.com/users/dufresnedavid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dufresnedavid/subscriptions","organizations_url":"https://api.github.com/users/dufresnedavid/orgs","repos_url":"https://api.github.com/users/dufresnedavid/repos","events_url":"https://api.github.com/users/dufresnedavid/events{/privacy}","received_events_url":"https://api.github.com/users/dufresnedavid/received_events","type":"User","site_admin":false},"body":"@JulieSFL You don't need to check if the value actually changed because this validation is already done on the client side. If you change a field's value and then set it back to its original value, when clicking on save, you are not actually sending a write to Odoo.","created_at":"2017-03-29T17:43:27Z","updated_at":"2017-03-29T17:43:27Z","html_url":"https://github.com/savoirfairelinux/partner-addons/pull/1#discussion_r108740966","pull_request_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/comments/108740966"},"html":{"href":"https://github.com/savoirfairelinux/partner-addons/pull/1#discussion_r108740966"},"pull_request":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1","id":111898262,"html_url":"https://github.com/savoirfairelinux/partner-addons/pull/1","diff_url":"https://github.com/savoirfairelinux/partner-addons/pull/1.diff","patch_url":"https://github.com/savoirfairelinux/partner-addons/pull/1.patch","issue_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/1","number":1,"state":"open","locked":false,"title":"Add partner tracking","user":{"login":"JulieSFL","id":18582938,"avatar_url":"https://avatars0.githubusercontent.com/u/18582938?v=3","gravatar_id":"","url":"https://api.github.com/users/JulieSFL","html_url":"https://github.com/JulieSFL","followers_url":"https://api.github.com/users/JulieSFL/followers","following_url":"https://api.github.com/users/JulieSFL/following{/other_user}","gists_url":"https://api.github.com/users/JulieSFL/gists{/gist_id}","starred_url":"https://api.github.com/users/JulieSFL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulieSFL/subscriptions","organizations_url":"https://api.github.com/users/JulieSFL/orgs","repos_url":"https://api.github.com/users/JulieSFL/repos","events_url":"https://api.github.com/users/JulieSFL/events{/privacy}","received_events_url":"https://api.github.com/users/JulieSFL/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-03-21T22:56:44Z","updated_at":"2017-03-29T17:43:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f652ccd77823cb75fe23c11bb162cec927427dec","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1/commits","review_comments_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1/comments","review_comment_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/comments{/number}","comments_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/1/comments","statuses_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/statuses/6ce6a9fab594b2e84f8d65e19ab8d499edf95b87","head":{"label":"JulieSFL:julie_partner_tracking","ref":"julie_partner_tracking","sha":"6ce6a9fab594b2e84f8d65e19ab8d499edf95b87","user":{"login":"JulieSFL","id":18582938,"avatar_url":"https://avatars0.githubusercontent.com/u/18582938?v=3","gravatar_id":"","url":"https://api.github.com/users/JulieSFL","html_url":"https://github.com/JulieSFL","followers_url":"https://api.github.com/users/JulieSFL/followers","following_url":"https://api.github.com/users/JulieSFL/following{/other_user}","gists_url":"https://api.github.com/users/JulieSFL/gists{/gist_id}","starred_url":"https://api.github.com/users/JulieSFL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulieSFL/subscriptions","organizations_url":"https://api.github.com/users/JulieSFL/orgs","repos_url":"https://api.github.com/users/JulieSFL/repos","events_url":"https://api.github.com/users/JulieSFL/events{/privacy}","received_events_url":"https://api.github.com/users/JulieSFL/received_events","type":"User","site_admin":false},"repo":{"id":85761654,"name":"partner-addons","full_name":"JulieSFL/partner-addons","owner":{"login":"JulieSFL","id":18582938,"avatar_url":"https://avatars0.githubusercontent.com/u/18582938?v=3","gravatar_id":"","url":"https://api.github.com/users/JulieSFL","html_url":"https://github.com/JulieSFL","followers_url":"https://api.github.com/users/JulieSFL/followers","following_url":"https://api.github.com/users/JulieSFL/following{/other_user}","gists_url":"https://api.github.com/users/JulieSFL/gists{/gist_id}","starred_url":"https://api.github.com/users/JulieSFL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulieSFL/subscriptions","organizations_url":"https://api.github.com/users/JulieSFL/orgs","repos_url":"https://api.github.com/users/JulieSFL/repos","events_url":"https://api.github.com/users/JulieSFL/events{/privacy}","received_events_url":"https://api.github.com/users/JulieSFL/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JulieSFL/partner-addons","description":"Partner related addons","fork":true,"url":"https://api.github.com/repos/JulieSFL/partner-addons","forks_url":"https://api.github.com/repos/JulieSFL/partner-addons/forks","keys_url":"https://api.github.com/repos/JulieSFL/partner-addons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JulieSFL/partner-addons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JulieSFL/partner-addons/teams","hooks_url":"https://api.github.com/repos/JulieSFL/partner-addons/hooks","issue_events_url":"https://api.github.com/repos/JulieSFL/partner-addons/issues/events{/number}","events_url":"https://api.github.com/repos/JulieSFL/partner-addons/events","assignees_url":"https://api.github.com/repos/JulieSFL/partner-addons/assignees{/user}","branches_url":"https://api.github.com/repos/JulieSFL/partner-addons/branches{/branch}","tags_url":"https://api.github.com/repos/JulieSFL/partner-addons/tags","blobs_url":"https://api.github.com/repos/JulieSFL/partner-addons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JulieSFL/partner-addons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JulieSFL/partner-addons/git/refs{/sha}","trees_url":"https://api.github.com/repos/JulieSFL/partner-addons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JulieSFL/partner-addons/statuses/{sha}","languages_url":"https://api.github.com/repos/JulieSFL/partner-addons/languages","stargazers_url":"https://api.github.com/repos/JulieSFL/partner-addons/stargazers","contributors_url":"https://api.github.com/repos/JulieSFL/partner-addons/contributors","subscribers_url":"https://api.github.com/repos/JulieSFL/partner-addons/subscribers","subscription_url":"https://api.github.com/repos/JulieSFL/partner-addons/subscription","commits_url":"https://api.github.com/repos/JulieSFL/partner-addons/commits{/sha}","git_commits_url":"https://api.github.com/repos/JulieSFL/partner-addons/git/commits{/sha}","comments_url":"https://api.github.com/repos/JulieSFL/partner-addons/comments{/number}","issue_comment_url":"https://api.github.com/repos/JulieSFL/partner-addons/issues/comments{/number}","contents_url":"https://api.github.com/repos/JulieSFL/partner-addons/contents/{+path}","compare_url":"https://api.github.com/repos/JulieSFL/partner-addons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JulieSFL/partner-addons/merges","archive_url":"https://api.github.com/repos/JulieSFL/partner-addons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JulieSFL/partner-addons/downloads","issues_url":"https://api.github.com/repos/JulieSFL/partner-addons/issues{/number}","pulls_url":"https://api.github.com/repos/JulieSFL/partner-addons/pulls{/number}","milestones_url":"https://api.github.com/repos/JulieSFL/partner-addons/milestones{/number}","notifications_url":"https://api.github.com/repos/JulieSFL/partner-addons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JulieSFL/partner-addons/labels{/name}","releases_url":"https://api.github.com/repos/JulieSFL/partner-addons/releases{/id}","deployments_url":"https://api.github.com/repos/JulieSFL/partner-addons/deployments","created_at":"2017-03-21T22:53:01Z","updated_at":"2017-03-21T21:43:42Z","pushed_at":"2017-03-27T15:12:56Z","git_url":"git://github.com/JulieSFL/partner-addons.git","ssh_url":"git@github.com:JulieSFL/partner-addons.git","clone_url":"https://github.com/JulieSFL/partner-addons.git","svn_url":"https://github.com/JulieSFL/partner-addons","homepage":null,"size":10,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"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":"savoirfairelinux:8.0","ref":"8.0","sha":"fee361206af685ed02e367c8387333c997144b18","user":{"login":"savoirfairelinux","id":2735545,"avatar_url":"https://avatars0.githubusercontent.com/u/2735545?v=3","gravatar_id":"","url":"https://api.github.com/users/savoirfairelinux","html_url":"https://github.com/savoirfairelinux","followers_url":"https://api.github.com/users/savoirfairelinux/followers","following_url":"https://api.github.com/users/savoirfairelinux/following{/other_user}","gists_url":"https://api.github.com/users/savoirfairelinux/gists{/gist_id}","starred_url":"https://api.github.com/users/savoirfairelinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/savoirfairelinux/subscriptions","organizations_url":"https://api.github.com/users/savoirfairelinux/orgs","repos_url":"https://api.github.com/users/savoirfairelinux/repos","events_url":"https://api.github.com/users/savoirfairelinux/events{/privacy}","received_events_url":"https://api.github.com/users/savoirfairelinux/received_events","type":"Organization","site_admin":false},"repo":{"id":85756598,"name":"partner-addons","full_name":"savoirfairelinux/partner-addons","owner":{"login":"savoirfairelinux","id":2735545,"avatar_url":"https://avatars0.githubusercontent.com/u/2735545?v=3","gravatar_id":"","url":"https://api.github.com/users/savoirfairelinux","html_url":"https://github.com/savoirfairelinux","followers_url":"https://api.github.com/users/savoirfairelinux/followers","following_url":"https://api.github.com/users/savoirfairelinux/following{/other_user}","gists_url":"https://api.github.com/users/savoirfairelinux/gists{/gist_id}","starred_url":"https://api.github.com/users/savoirfairelinux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/savoirfairelinux/subscriptions","organizations_url":"https://api.github.com/users/savoirfairelinux/orgs","repos_url":"https://api.github.com/users/savoirfairelinux/repos","events_url":"https://api.github.com/users/savoirfairelinux/events{/privacy}","received_events_url":"https://api.github.com/users/savoirfairelinux/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/savoirfairelinux/partner-addons","description":"Partner related addons","fork":false,"url":"https://api.github.com/repos/savoirfairelinux/partner-addons","forks_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/forks","keys_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/keys{/key_id}","collaborators_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/teams","hooks_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/hooks","issue_events_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/events{/number}","events_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/events","assignees_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/assignees{/user}","branches_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/branches{/branch}","tags_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/tags","blobs_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/git/refs{/sha}","trees_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/git/trees{/sha}","statuses_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/statuses/{sha}","languages_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/languages","stargazers_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/stargazers","contributors_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/contributors","subscribers_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/subscribers","subscription_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/subscription","commits_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/commits{/sha}","git_commits_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/git/commits{/sha}","comments_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/comments{/number}","issue_comment_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/comments{/number}","contents_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/contents/{+path}","compare_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/compare/{base}...{head}","merges_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/merges","archive_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/downloads","issues_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues{/number}","pulls_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls{/number}","milestones_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/milestones{/number}","notifications_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/labels{/name}","releases_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/releases{/id}","deployments_url":"https://api.github.com/repos/savoirfairelinux/partner-addons/deployments","created_at":"2017-03-21T21:43:42Z","updated_at":"2017-03-21T21:43:42Z","pushed_at":"2017-03-27T15:12:57Z","git_url":"git://github.com/savoirfairelinux/partner-addons.git","ssh_url":"git@github.com:savoirfairelinux/partner-addons.git","clone_url":"https://github.com/savoirfairelinux/partner-addons.git","svn_url":"https://github.com/savoirfairelinux/partner-addons","homepage":null,"size":3,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"8.0"}},"_links":{"self":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1"},"html":{"href":"https://github.com/savoirfairelinux/partner-addons/pull/1"},"issue":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/1"},"comments":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/savoirfairelinux/partner-addons/statuses/6ce6a9fab594b2e84f8d65e19ab8d499edf95b87"}}}}
{"actor":{"display_login":"dufresnedavid"}}