{"action":"created","issue":{"url":"https://api.github.com/repos/odoo/odoo/issues/13082","repository_url":"https://api.github.com/repos/odoo/odoo","labels_url":"https://api.github.com/repos/odoo/odoo/issues/13082/labels{/name}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/13082/comments","events_url":"https://api.github.com/repos/odoo/odoo/issues/13082/events","html_url":"https://github.com/odoo/odoo/pull/13082","id":170132956,"number":13082,"title":"[9.0][test_new_api] Tests that show weaknesses of ORM one2many fields","user":{"login":"Yajo","id":973709,"avatar_url":"https://avatars.githubusercontent.com/u/973709?v=3","gravatar_id":"","url":"https://api.github.com/users/Yajo","html_url":"https://github.com/Yajo","followers_url":"https://api.github.com/users/Yajo/followers","following_url":"https://api.github.com/users/Yajo/following{/other_user}","gists_url":"https://api.github.com/users/Yajo/gists{/gist_id}","starred_url":"https://api.github.com/users/Yajo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yajo/subscriptions","organizations_url":"https://api.github.com/users/Yajo/orgs","repos_url":"https://api.github.com/users/Yajo/repos","events_url":"https://api.github.com/users/Yajo/events{/privacy}","received_events_url":"https://api.github.com/users/Yajo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-09T10:27:22Z","updated_at":"2016-09-16T09:35:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/odoo/odoo/pulls/13082","html_url":"https://github.com/odoo/odoo/pull/13082","diff_url":"https://github.com/odoo/odoo/pull/13082.diff","patch_url":"https://github.com/odoo/odoo/pull/13082.patch"},"body":"This is more an issue than a pull, but once fixed, tests could perfectly get pulled.\r\n\r\nCurrent Odoo ORM status gives no sane way to work with one2many fields, and these tests are written imitating several develop styles and situations:\r\n\r\n- Using `.new()` and adding those records with `|=` to a o2m field.\r\n- Same with `.create()`.\r\n- Using `[(5, 0, 0), (0, 0, {...}), ...]` style.\r\n\r\nIt is expected that these tests get :x:.\r\n\r\nMy wish is that you realize this is a real problem, and give some solution. Either improving the docs by saying what is the *correct* way of doing what these tests try to do, or actually making them pass.\r\n\r\n--\r\nI confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr\r\n\r\n@Tecnativa @pedrobaeza "},"comment":{"url":"https://api.github.com/repos/odoo/odoo/issues/comments/247558897","html_url":"https://github.com/odoo/odoo/pull/13082#issuecomment-247558897","issue_url":"https://api.github.com/repos/odoo/odoo/issues/13082","id":247558897,"user":{"login":"Yajo","id":973709,"avatar_url":"https://avatars.githubusercontent.com/u/973709?v=3","gravatar_id":"","url":"https://api.github.com/users/Yajo","html_url":"https://github.com/Yajo","followers_url":"https://api.github.com/users/Yajo/followers","following_url":"https://api.github.com/users/Yajo/following{/other_user}","gists_url":"https://api.github.com/users/Yajo/gists{/gist_id}","starred_url":"https://api.github.com/users/Yajo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yajo/subscriptions","organizations_url":"https://api.github.com/users/Yajo/orgs","repos_url":"https://api.github.com/users/Yajo/repos","events_url":"https://api.github.com/users/Yajo/events{/privacy}","received_events_url":"https://api.github.com/users/Yajo/received_events","type":"User","site_admin":false},"created_at":"2016-09-16T09:35:57Z","updated_at":"2016-09-16T09:35:57Z","body":"After all, the problem was in 2 places:\r\n\r\n1. When you assigned anything to a o2m field, it usually ended up calling `write` with `[(5), (4, someid), (0, 0, {...})]`, and it seems this was by design, but the main problem is that if the comodel had `ondelete=\"cascade\"`, then the `5` deleted the record that `4` wanted to relink, so... :boom: `MissingError` :exclamation: \r\n2. Cache was not being updated correctly.\r\n\r\nLast commits implement `[(6, 0, [ids])]` behavior for o2m (docs updated accordingly), uses that instead of the 5+4 combination, and invalidates cache of written fields. Suddenly it all works fine! :blush:\r\n\r\nBTW, I reviewed this bug for v8 and master, and I'm pretty sure it affects both versions, but in different forms. AFAICS v8 uses `6` instead of `5+4`, but its `6` implementation lacks a patch I'm pushing. In master, I think the patch can be forward-ported, but some parts will have to be rewritten to use the new api, given the old one is being removed there.\r\n\r\nSorry for not following the guidelines there (I know I should have patched 8 instead), but given the patches are so different (and v9 is more necessary), please Odoo backport to v8 this time. Thanks for your understanding."}}
{"actor":{"display_login":"Yajo"}}