콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hello friends,

I've created a search view:

 

        <recordid="action_view_sent_tasks"model="ir.actions.act_window">            <fieldname="name">Sent Tasksfield>            <fieldname="res_model">project.taskfield>            <fieldname="view_mode">tree,formfield>            <fieldname="domain">[('project_id', '!=', False), ('project_id.court', '!=', False), ('sender_court', '!=', False), ('sender_court', '=',  project_id.court)]field>                        <fieldname="search_view_id"ref="project.view_task_search_form_extended"/>        record>




 

 
But I got this error.

EvaluationError: Name 'project_id' is not defined at _evaluate (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:838:232) at _evaluate (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:845:21) at Array.map () at _evaluate (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:840:33) at Array.map () at _evaluate (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:840:33) at evaluate (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:849:8) at evaluateExpr (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:702:109) at _preprocessAction (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:2229:260) at doAction (http://localhost:8069/web/assets/1390-b817bdd/web.assets_backend.min.js:2309:170)

 

아바타
취소
베스트 답변

The error message suggests that the variable "project_id" is not defined in the domain for your search view.

It seems like you are using project_id.court in the domain, but "project_id" is not defined before, you should use self.project_id.court instead of project_id.court.

You should also check if the fields sender_court and project_id.court exist in the project.task model and that you have the right access rights to them.

Also, you may want to check if the field project_id is defined in the project.task model and if it's a many2one field to the project.project model.

Try updating your XML code to something like this:

It should work fine.

If the problem still persists, please provide more details about the error you are facing, such as the exact version of Odoo and the full stack trace of the error message, this will help me to understand the problem more clearly and provide an accurate solution.

아바타
취소
작성자 베스트 답변

[Edited] Hello Firoz,

I am using odoo v15, I tried to use the self keyword but I am getting this error " Name 'self' is not defined "


I fixed the issue by using a stored computed field. 

First:

I created a new field called is_sent_task

is_sent_task = fields.Boolean(default=False, compute='compute_is_sent_task', store=True



Second:

I created a compute method


@api.depends('project_id', 'sender_court')

def _compute_is_sent_task(self):

​for r in self:

​if r.sender_court and r.project_id:

​r.is_sent_task = r.sender_court_id == r.project_id.court.id


Third:

I used the is_sent_task in the domain field

[('is_sent_task', '=', True)]


Its work fine now 

아바타
취소
관련 게시물 답글 화면 활동
1
11월 22
4585
0
1월 18
4683
0
5월 16
3391
0
5월 23
2810
2
9월 16
8002