I am trying to get a function field in model and using it in action of view To filter the displayed data
But odoo doesn't accept that I use the function field in the domain
see the code:
model ...
gerant_structure_id = fields.Integer('Structure id', compute='_getStructureIdForCurrentUser')
@api.one
def _getStructureIdForCurrentUser(self):
structure_id = self.env['afya.structure.sante'].search([('gerant_id', '=', self.env.uid )]).id
self.gerant_structure_id = structure_id
view ...
<record model="ir.actions.act_window" id="compte_wallet_list_action">
<field name="name">Compte_Wallet</field>
<field name="domain">[('structure_sante_id', '=', gerant_structure_id)]</field>
<field name="res_model">afya.compte.wallet</field>
<field name="view_mode">tree</field>
</record>
Error: NameError: name 'gerant_structure_id' is not defined
http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1326 Retraçage : PY_ensurepy@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1326:65 py.evaluate@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1441:8 py.evaluate@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1447:108 py.evaluate@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1449:96 py.eval@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1454:281 eval_domains/<@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1596:120 _.forEach@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:12:558 _.mixin/</_.prototype[name]@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:69:521 eval_domains@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1595:136 pyeval@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1606:24 do_action@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1652:33 on_menu_action/</<@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1719:35 Mutex.prototype.exec/<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:3201:136 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:678 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 add@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:542:467 then/</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:631 each@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:370:758 then/<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:553 Deferred@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:548:189 then@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:518 Mutex.prototype.exec@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:3201:98 on_menu_action/<@http://localhost:8069/web/content/312-e09ffdb/web.assets_backend.js:1718:279 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:678 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 Deferred/</deferred[tuple[0]]@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:548:31 add/<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:3217:259 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:849 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:849 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 Deferred/</deferred[tuple[0]]@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:548:31 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:849 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 then/</</<@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:547:849 fire@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:541:281 fireWith@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:546:198 done@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:937:86 callback@http://localhost:8069/web/content/251-dd1bc0a/web.assets_common.js:957:15