{"action":"created","issue":{"url":"https://api.github.com/repos/OCA/contract/issues/124","repository_url":"https://api.github.com/repos/OCA/contract","labels_url":"https://api.github.com/repos/OCA/contract/issues/124/labels{/name}","comments_url":"https://api.github.com/repos/OCA/contract/issues/124/comments","events_url":"https://api.github.com/repos/OCA/contract/issues/124/events","html_url":"https://github.com/OCA/contract/issues/124","id":276333632,"number":124,"title":"[10.0] Overriding field analytic_account_id in account.analytic.contract.line breaks link between account.analytic.invoice.line and account.analytic.account.","user":{"login":"NL66278","id":6080487,"avatar_url":"https://avatars2.githubusercontent.com/u/6080487?v=4","gravatar_id":"","url":"https://api.github.com/users/NL66278","html_url":"https://github.com/NL66278","followers_url":"https://api.github.com/users/NL66278/followers","following_url":"https://api.github.com/users/NL66278/following{/other_user}","gists_url":"https://api.github.com/users/NL66278/gists{/gist_id}","starred_url":"https://api.github.com/users/NL66278/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NL66278/subscriptions","organizations_url":"https://api.github.com/users/NL66278/orgs","repos_url":"https://api.github.com/users/NL66278/repos","events_url":"https://api.github.com/users/NL66278/events{/privacy}","received_events_url":"https://api.github.com/users/NL66278/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-11-23T10:56:42Z","updated_at":"2017-12-02T15:37:46Z","closed_at":null,"author_association":"NONE","body":"I have a module where I need to have partner_id as a reference field in account.analytic.invoice.line. This should not pose any problem, as account.analytic.invoice.line refers with account_analytic_id to account.analytic.account, which has partner id.\r\n\r\nThis is my code:\r\n```python\r\n  1 # -*- coding: utf-8 -*-                                                        \r\n  2 # Copyright 2014-2017 Therp BV <https://therp.nl>.                             \r\n  3 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).                \r\n  4 from odoo import api, fields, models                                           \r\n  5                                                                                \r\n  6                                                                                \r\n  7 class AccountAnalyticInvoiceLine(models.Model):                                \r\n  8     _inherit = 'account.analytic.invoice.line'                                 \r\n  9                                                                                \r\n...                                                         \r\n 23     partner_id = fields.Many2one(                                              \r\n 24         comodel_name='res.partner',                                            \r\n 25         related='analytic_account_id.partner_id',                              \r\n 26         string='Partner') \r\n```\r\n\r\nUnfortunately the code in contract/models/account_analytic_contract_line.py breaks the original analytic_account_id:\r\n```python\r\n  1 # -*- coding: utf-8 -*-                                                        \r\n  2 # Copyright 2017 LasLabs Inc.                                                  \r\n  3 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).                \r\n  4                                                                                \r\n  5 from odoo import fields, models                                                \r\n  6                                                                                \r\n  7                                                                                \r\n  8 class AccountAnalyticContractLine(models.Model):                               \r\n  9                                                                                \r\n 10     _name = 'account.analytic.contract.line'                                   \r\n 11     _description = 'Contract Lines'                                            \r\n 12     _inherit = 'account.analytic.invoice.line'                                 \r\n 13                                                                                \r\n 14     analytic_account_id = fields.Many2one(                                     \r\n 15         string='Contract',                                                     \r\n 16         comodel_name='account.analytic.contract',                              \r\n 17         required=True,                                                         \r\n 18         ondelete='cascade',                                                    \r\n 19     )\r\n```\r\nThe result is this:\r\n```\r\n2017-11-23 10:41:23,674 13472 DEBUG odownbdem10 odoo.modules.loading: loading module publication (55/57)\r\n2017-11-23 10:41:23,721 13472 ERROR odownbdem10 odoo.fields: Problem setting up related field partner_id for model account.analytic.contract.line\r\n2017-11-23 10:41:23,721 13472 ERROR odownbdem10 odoo.modules.registry: Error setting up fields for model account.analytic.contract.line\r\n2017-11-23 10:41:23,721 13472 ERROR odownbdem10 odoo.modules.registry: Failed to load registry\r\nTraceback (most recent call last):\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/modules/registry.py\", line 82, in new\r\n    odoo.modules.load_modules(registry._db, force_demo, status, update_module)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/modules/loading.py\", line 344, in load_modules\r\n    loaded_modules, update_module)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/modules/loading.py\", line 243, in load_marked_modules\r\n    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/modules/loading.py\", line 141, in load_module_graph\r\n    registry.setup_models(cr, partial=True)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/modules/registry.py\", line 306, in setup_models\r\n    model._setup_fields(partial)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/models.py\", line 2850, in _setup_fields\r\n    field.setup_full(self)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/fields.py\", line 502, in setup_full\r\n    self._setup_related_full(model)\r\n  File \"/home/openeyedev/var/projects/oe_woonbond_10/odoo/parts/odoo/odoo/fields.py\", line 540, in _setup_related_full\r\n    field = target._fields[name]\r\nKeyError: 'partner_id'\r\n```"},"comment":{"url":"https://api.github.com/repos/OCA/contract/issues/comments/348699790","html_url":"https://github.com/OCA/contract/issues/124#issuecomment-348699790","issue_url":"https://api.github.com/repos/OCA/contract/issues/124","id":348699790,"user":{"login":"pedrobaeza","id":7165771,"avatar_url":"https://avatars2.githubusercontent.com/u/7165771?v=4","gravatar_id":"","url":"https://api.github.com/users/pedrobaeza","html_url":"https://github.com/pedrobaeza","followers_url":"https://api.github.com/users/pedrobaeza/followers","following_url":"https://api.github.com/users/pedrobaeza/following{/other_user}","gists_url":"https://api.github.com/users/pedrobaeza/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrobaeza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrobaeza/subscriptions","organizations_url":"https://api.github.com/users/pedrobaeza/orgs","repos_url":"https://api.github.com/users/pedrobaeza/repos","events_url":"https://api.github.com/users/pedrobaeza/events{/privacy}","received_events_url":"https://api.github.com/users/pedrobaeza/received_events","type":"User","site_admin":false},"created_at":"2017-12-02T15:37:46Z","updated_at":"2017-12-02T15:37:46Z","author_association":"CONTRIBUTOR","body":"What about depending on the module contract?"}}
{"actor":{"display_login":"pedrobaeza"}}