Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

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)

 

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

[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 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 22
4556
0
sty 18
4665
0
maj 16
3369
0
maj 23
2771
2
wrz 16
7984