{"action":"created","issue":{"url":"https://api.github.com/repos/odoo/odoo/issues/12889","repository_url":"https://api.github.com/repos/odoo/odoo","labels_url":"https://api.github.com/repos/odoo/odoo/issues/12889/labels{/name}","comments_url":"https://api.github.com/repos/odoo/odoo/issues/12889/comments","events_url":"https://api.github.com/repos/odoo/odoo/issues/12889/events","html_url":"https://github.com/odoo/odoo/issues/12889","id":167237027,"number":12889,"title":"[9.0] Error in template when prefetch empty compute field","user":{"login":"dansanti","id":2584240,"avatar_url":"https://avatars.githubusercontent.com/u/2584240?v=3","gravatar_id":"","url":"https://api.github.com/users/dansanti","html_url":"https://github.com/dansanti","followers_url":"https://api.github.com/users/dansanti/followers","following_url":"https://api.github.com/users/dansanti/following{/other_user}","gists_url":"https://api.github.com/users/dansanti/gists{/gist_id}","starred_url":"https://api.github.com/users/dansanti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dansanti/subscriptions","organizations_url":"https://api.github.com/users/dansanti/orgs","repos_url":"https://api.github.com/users/dansanti/repos","events_url":"https://api.github.com/users/dansanti/events{/privacy}","received_events_url":"https://api.github.com/users/dansanti/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/odoo/odoo/labels/blocked","name":"blocked","color":"FF0000"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-24T14:51:04Z","updated_at":"2016-07-26T09:10:02Z","closed_at":"2016-07-26T09:10:02Z","body":"Impacted versions:9.0\r\n\r\nSteps to reproduce:\r\n1.- Create  a module\r\n2.- Create a model inherited to account.invoice  with compute field \r\n```\r\n new_compute_filed = fields.many2one('relation\",string=\"name\" compute=_getcompute)\r\n\r\ndef _getcompute(self):\r\n   self.new_compute_field = compute_id\r\n\r\n```\r\n\r\n3.- create a template:\r\n``\r\n<template id=\"dte_external_layout_header\" inherit_id=\"report.external_layout_header\">\r\n        <xpath expr=\"//div[@class='header']\" position=\"inside\">\r\n               <t t-if=\"'new_compute_field' on o and o.new_compute_filed\"><span t-field=\"o.new_compute_field\"/></t>\r\n   </xpath>\r\n</template>\r\n``\r\n4.- create an invoice and fill field\r\n5.- click on print invoice, works fine \r\n6.- click on send email : get error\r\nCurrent behavior:\r\n\r\nError get : \r\nopenerp/models.py\", line 3295, in _prefetch_field\r\n    assert self in records and field in fs\r\nQWebException: \"\" while evaluating\r\n'o.new_compute_field'\r\n\r\nThis happens  too if you go to stock and click on print pdf some picking move\r\n\r\nExpected behavior:\r\n\r\ncan use if to print when field is false\r\n"},"comment":{"url":"https://api.github.com/repos/odoo/odoo/issues/comments/235207211","html_url":"https://github.com/odoo/odoo/issues/12889#issuecomment-235207211","issue_url":"https://api.github.com/repos/odoo/odoo/issues/12889","id":235207211,"user":{"login":"mart-e","id":564822,"avatar_url":"https://avatars.githubusercontent.com/u/564822?v=3","gravatar_id":"","url":"https://api.github.com/users/mart-e","html_url":"https://github.com/mart-e","followers_url":"https://api.github.com/users/mart-e/followers","following_url":"https://api.github.com/users/mart-e/following{/other_user}","gists_url":"https://api.github.com/users/mart-e/gists{/gist_id}","starred_url":"https://api.github.com/users/mart-e/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mart-e/subscriptions","organizations_url":"https://api.github.com/users/mart-e/orgs","repos_url":"https://api.github.com/users/mart-e/repos","events_url":"https://api.github.com/users/mart-e/events{/privacy}","received_events_url":"https://api.github.com/users/mart-e/received_events","type":"User","site_admin":false},"created_at":"2016-07-26T09:10:02Z","updated_at":"2016-07-26T09:10:02Z","body":"Thank you for the complete example, I think I understand the problem.\r\nThe expression `<span t-if=\"'turn_issuer' in o and o.turn_issuer\" t-field=\"o.turn_issuer.name\" style=\"color:black;\"/>` is not correct. Try instead something like:\r\n\r\n```xml\r\n<t t-if=\"'turn_issuer' in o and o.turn_issuer\">\r\n          <span t-field=\"o.turn_issuer.name\" style=\"color:black;\"/>\r\n</t>\r\n```\r\n\r\nAnyway, closing as it doesn't seem an issue in ORM but in the template customisation (I advise you to go to the forum for that).\r\n\r\nPS: I assume this is only a partial example but the decorator `api.model` is wrong and missing `api.depends`."}}
{"actor":{"display_login":"mart-e"}}