{"action":"created","comment":{"url":"https://api.github.com/repos/odoo/odoo/pulls/comments/232208722","pull_request_review_id":173355004,"id":232208722,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjIwODcyMg==","diff_hunk":"@@ -565,15 +565,23 @@ def _load_template(self, company, code_digits=None, account_ref=None, taxes_ref=\n \n     @api.multi\n     def create_record_with_xmlid(self, company, template, model, vals):\n-        # Create a record for the given model with the given vals and\n-        # also create an entry in ir_model_data to have an xmlid for the newly created record\n-        # xmlid is the concatenation of company_id and template_xml_id\n-        ir_model_data = self.env['ir.model.data']\n-        template_xmlid = ir_model_data.search([('model', '=', template._name), ('res_id', '=', template.id)])\n-        xml_id = \"%s.%s_%s\" % (template_xmlid.module, company.id, template_xmlid.name)\n-        data = dict(xml_id=xml_id, values=vals, noupdate=True)\n-        record = self.env[model]._load_records([data])\n-        return record.id\n+        return self._create_records_with_xmlid(model, [(template, vals)], company).id\n+\n+    def _create_records_with_xmlid(self, model, template_vals, company):\n+        \"\"\" Create records for the given model name with the given vals, and\n+            create xml ids based on each record's template and company id.\n+        \"\"\"\n+        if not template_vals:\n+            return self.env[model]\n+        template_model = template_vals[0][0]\n+        template_ids = [template.id for template, vals in template_vals]\n+        template_xmlids = template_model.browse(template_ids).get_external_id()","path":"addons/account/models/chart_template.py","position":23,"original_position":23,"commit_id":"896d0083b6e01ff08ae092c8c4c0ff1c8b1a1833","original_commit_id":"896d0083b6e01ff08ae092c8c4c0ff1c8b1a1833","user":{"login":"rco-odoo","id":7578141,"node_id":"MDQ6VXNlcjc1NzgxNDE=","avatar_url":"https://avatars2.githubusercontent.com/u/7578141?v=4","gravatar_id":"","url":"https://api.github.com/users/rco-odoo","html_url":"https://github.com/rco-odoo","followers_url":"https://api.github.com/users/rco-odoo/followers","following_url":"https://api.github.com/users/rco-odoo/following{/other_user}","gists_url":"https://api.github.com/users/rco-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/rco-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rco-odoo/subscriptions","organizations_url":"https://api.github.com/users/rco-odoo/orgs","repos_url":"https://api.github.com/users/rco-odoo/repos","events_url":"https://api.github.com/users/rco-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/rco-odoo/received_events","type":"User","site_admin":false},"body":"I did it that way because the method `get_external_id` is made for that purpose.\r\nIt avoids having to know the details of `ir.model.data` to understand your own code.","created_at":"2018-11-09T10:35:28Z","updated_at":"2018-11-09T10:35:28Z","html_url":"https://github.com/odoo/odoo/pull/28480#discussion_r232208722","pull_request_url":"https://api.github.com/repos/odoo/odoo/pulls/28480","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments/232208722"},"html":{"href":"https://github.com/odoo/odoo/pull/28480#discussion_r232208722"},"pull_request":{"href":"https://api.github.com/repos/odoo/odoo/pulls/28480"}},"in_reply_to_id":231918986},"pull_request":{"url":"https://api.github.com/repos/odoo/odoo/pulls/28480","id":229073064,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5MDczMDY0","html_url":"https://github.com/odoo/odoo/pull/28480","diff_url":"https://github.com/odoo/odoo/pull/28480.diff","patch_url":"https://github.com/odoo/odoo/pull/28480.patch","issue_url":"https://api.github.com/repos/odoo/odoo/issues/28480","number":28480,"state":"open","locked":false,"title":"[FIX] account: speedup the creation of the chart of accounts","user":{"login":"rco-odoo","id":7578141,"node_id":"MDQ6VXNlcjc1NzgxNDE=","avatar_url":"https://avatars2.githubusercontent.com/u/7578141?v=4","gravatar_id":"","url":"https://api.github.com/users/rco-odoo","html_url":"https://github.com/rco-odoo","followers_url":"https://api.github.com/users/rco-odoo/followers","following_url":"https://api.github.com/users/rco-odoo/following{/other_user}","gists_url":"https://api.github.com/users/rco-odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/rco-odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rco-odoo/subscriptions","organizations_url":"https://api.github.com/users/rco-odoo/orgs","repos_url":"https://api.github.com/users/rco-odoo/repos","events_url":"https://api.github.com/users/rco-odoo/events{/privacy}","received_events_url":"https://api.github.com/users/rco-odoo/received_events","type":"User","site_admin":false},"body":"Make the CoA template instantiates accounts and other records in batch.\r\nThe creation of the CoA is 4 to 5 times faster.","created_at":"2018-11-07T15:46:43Z","updated_at":"2018-11-09T10:35:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d71e5b4e96f4794210df9938c50f5da071c58bd","assignee":null,"assignees":[],"requested_reviewers":[{"login":"smetl","id":21679159,"node_id":"MDQ6VXNlcjIxNjc5MTU5","avatar_url":"https://avatars0.githubusercontent.com/u/21679159?v=4","gravatar_id":"","url":"https://api.github.com/users/smetl","html_url":"https://github.com/smetl","followers_url":"https://api.github.com/users/smetl/followers","following_url":"https://api.github.com/users/smetl/following{/other_user}","gists_url":"https://api.github.com/users/smetl/gists{/gist_id}","starred_url":"https://api.github.com/users/smetl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smetl/subscriptions","organizations_url":"https://api.github.com/users/smetl/orgs","repos_url":"https://api.github.com/users/smetl/repos","events_url":"https://api.github.com/users/smetl/events{/privacy}","received_events_url":"https://api.github.com/users/smetl/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1044840932,"node_id":"MDU6TGFiZWwxMDQ0ODQwOTMy","url":"https://api.github.com/repos/odoo/odoo/labels/CI%20%F0%9F%A4%96","name":"CI 🤖","color":"ededed","default":false},{"id":106173385,"node_id":"MDU6TGFiZWwxMDYxNzMzODU=","url":"https://api.github.com/repos/odoo/odoo/labels/RD","name":"RD","color":"5319e7","default":false},{"id":1044215768,"node_id":"MDU6TGFiZWwxMDQ0MjE1NzY4","url":"https://api.github.com/repos/odoo/odoo/labels/seen%20%F0%9F%99%82","name":"seen 🙂","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/odoo/odoo/pulls/28480/commits","review_comments_url":"https://api.github.com/repos/odoo/odoo/pulls/28480/comments","review_comment_url":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/28480/comments","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/896d0083b6e01ff08ae092c8c4c0ff1c8b1a1833","head":{"label":"odoo-dev:12.0-coa-speedup-rco","ref":"12.0-coa-speedup-rco","sha":"896d0083b6e01ff08ae092c8c4c0ff1c8b1a1833","user":{"login":"odoo-dev","id":7466976,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NjY5NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/7466976?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"repo":{"id":19853934,"node_id":"MDEwOlJlcG9zaXRvcnkxOTg1MzkzNA==","name":"odoo","full_name":"odoo-dev/odoo","private":false,"owner":{"login":"odoo-dev","id":7466976,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0NjY5NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/7466976?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo-dev","html_url":"https://github.com/odoo-dev","followers_url":"https://api.github.com/users/odoo-dev/followers","following_url":"https://api.github.com/users/odoo-dev/following{/other_user}","gists_url":"https://api.github.com/users/odoo-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo-dev/subscriptions","organizations_url":"https://api.github.com/users/odoo-dev/orgs","repos_url":"https://api.github.com/users/odoo-dev/repos","events_url":"https://api.github.com/users/odoo-dev/events{/privacy}","received_events_url":"https://api.github.com/users/odoo-dev/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/odoo-dev/odoo","description":"RD Dev Repository","fork":true,"url":"https://api.github.com/repos/odoo-dev/odoo","forks_url":"https://api.github.com/repos/odoo-dev/odoo/forks","keys_url":"https://api.github.com/repos/odoo-dev/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo-dev/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo-dev/odoo/teams","hooks_url":"https://api.github.com/repos/odoo-dev/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo-dev/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo-dev/odoo/events","assignees_url":"https://api.github.com/repos/odoo-dev/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo-dev/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo-dev/odoo/tags","blobs_url":"https://api.github.com/repos/odoo-dev/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo-dev/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo-dev/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo-dev/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo-dev/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo-dev/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo-dev/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo-dev/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo-dev/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo-dev/odoo/subscription","commits_url":"https://api.github.com/repos/odoo-dev/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo-dev/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo-dev/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo-dev/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo-dev/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo-dev/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo-dev/odoo/merges","archive_url":"https://api.github.com/repos/odoo-dev/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo-dev/odoo/downloads","issues_url":"https://api.github.com/repos/odoo-dev/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo-dev/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo-dev/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo-dev/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo-dev/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo-dev/odoo/releases{/id}","deployments_url":"https://api.github.com/repos/odoo-dev/odoo/deployments","created_at":"2014-05-16T11:16:19Z","updated_at":"2018-11-03T19:22:39Z","pushed_at":"2018-11-09T10:31:16Z","git_url":"git://github.com/odoo-dev/odoo.git","ssh_url":"git@github.com:odoo-dev/odoo.git","clone_url":"https://github.com/odoo-dev/odoo.git","svn_url":"https://github.com/odoo-dev/odoo","homepage":"https://www.odoo.com","size":2381843,"stargazers_count":82,"watchers_count":82,"language":null,"has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":40,"open_issues":0,"watchers":82,"default_branch":"master"}},"base":{"label":"odoo:12.0","ref":"12.0","sha":"0662a1948b71ebd46313cbe40774553594f1c9e0","user":{"login":"odoo","id":6368483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzNjg0ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/6368483?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"repo":{"id":19745004,"node_id":"MDEwOlJlcG9zaXRvcnkxOTc0NTAwNA==","name":"odoo","full_name":"odoo/odoo","private":false,"owner":{"login":"odoo","id":6368483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzNjg0ODM=","avatar_url":"https://avatars2.githubusercontent.com/u/6368483?v=4","gravatar_id":"","url":"https://api.github.com/users/odoo","html_url":"https://github.com/odoo","followers_url":"https://api.github.com/users/odoo/followers","following_url":"https://api.github.com/users/odoo/following{/other_user}","gists_url":"https://api.github.com/users/odoo/gists{/gist_id}","starred_url":"https://api.github.com/users/odoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odoo/subscriptions","organizations_url":"https://api.github.com/users/odoo/orgs","repos_url":"https://api.github.com/users/odoo/repos","events_url":"https://api.github.com/users/odoo/events{/privacy}","received_events_url":"https://api.github.com/users/odoo/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/odoo/odoo","description":"Odoo. Open Source Apps To Grow Your Business.","fork":false,"url":"https://api.github.com/repos/odoo/odoo","forks_url":"https://api.github.com/repos/odoo/odoo/forks","keys_url":"https://api.github.com/repos/odoo/odoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odoo/odoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odoo/odoo/teams","hooks_url":"https://api.github.com/repos/odoo/odoo/hooks","issue_events_url":"https://api.github.com/repos/odoo/odoo/issues/events{/number}","events_url":"https://api.github.com/repos/odoo/odoo/events","assignees_url":"https://api.github.com/repos/odoo/odoo/assignees{/user}","branches_url":"https://api.github.com/repos/odoo/odoo/branches{/branch}","tags_url":"https://api.github.com/repos/odoo/odoo/tags","blobs_url":"https://api.github.com/repos/odoo/odoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odoo/odoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odoo/odoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/odoo/odoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odoo/odoo/statuses/{sha}","languages_url":"https://api.github.com/repos/odoo/odoo/languages","stargazers_url":"https://api.github.com/repos/odoo/odoo/stargazers","contributors_url":"https://api.github.com/repos/odoo/odoo/contributors","subscribers_url":"https://api.github.com/repos/odoo/odoo/subscribers","subscription_url":"https://api.github.com/repos/odoo/odoo/subscription","commits_url":"https://api.github.com/repos/odoo/odoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/odoo/odoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/odoo/odoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/odoo/odoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/odoo/odoo/contents/{+path}","compare_url":"https://api.github.com/repos/odoo/odoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odoo/odoo/merges","archive_url":"https://api.github.com/repos/odoo/odoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odoo/odoo/downloads","issues_url":"https://api.github.com/repos/odoo/odoo/issues{/number}","pulls_url":"https://api.github.com/repos/odoo/odoo/pulls{/number}","milestones_url":"https://api.github.com/repos/odoo/odoo/milestones{/number}","notifications_url":"https://api.github.com/repos/odoo/odoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odoo/odoo/labels{/name}","releases_url":"https://api.github.com/repos/odoo/odoo/releases{/id}","deployments_url":"https://api.github.com/repos/odoo/odoo/deployments","created_at":"2014-05-13T15:38:58Z","updated_at":"2018-11-09T09:49:13Z","pushed_at":"2018-11-09T10:34:22Z","git_url":"git://github.com/odoo/odoo.git","ssh_url":"git@github.com:odoo/odoo.git","clone_url":"https://github.com/odoo/odoo.git","svn_url":"https://github.com/odoo/odoo","homepage":"https://www.odoo.com","size":2372917,"stargazers_count":11634,"watchers_count":11634,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9090,"mirror_url":null,"archived":false,"open_issues_count":1927,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":9090,"open_issues":1927,"watchers":11634,"default_branch":"12.0"}},"_links":{"self":{"href":"https://api.github.com/repos/odoo/odoo/pulls/28480"},"html":{"href":"https://github.com/odoo/odoo/pull/28480"},"issue":{"href":"https://api.github.com/repos/odoo/odoo/issues/28480"},"comments":{"href":"https://api.github.com/repos/odoo/odoo/issues/28480/comments"},"review_comments":{"href":"https://api.github.com/repos/odoo/odoo/pulls/28480/comments"},"review_comment":{"href":"https://api.github.com/repos/odoo/odoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odoo/odoo/pulls/28480/commits"},"statuses":{"href":"https://api.github.com/repos/odoo/odoo/statuses/896d0083b6e01ff08ae092c8c4c0ff1c8b1a1833"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rco-odoo"}}