Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2333 Lượt xem

I'm trying to inherit Many2one fields ("project and task") in sale.order form view. I can see the fields but I can choose all task in my task field. I want to related it to project field because when I choose a project, I must see only that project's task. Also I want to see  task field just when I choose a project. I tried to do it like this;


class SaleOder(models.Model):

_inherit = "sale.order"

project_id = fields.Many2one(comodel_name="project.project", string="Project")

task_id =fields.Many2one(comodel_name="project.task", related="project.task.name",  string="Task")

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,
Here you have to set domain for the task_id field to filter and show only task related to selected project.

project_id = fields.Many2one(comodel_name="project.project", string="Project")
task_id = fields.Many2one(comodel_name="project.task", string="Task", domain="[('project_id', '=', project_id)]")


Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for your answer

Câu trả lời hay nhất

Hi,

to be able to see only " that project's task ", you have to add a domain:

 


for your " Also I want to see  task field just when I choose a project ":


thanks.

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks, your answer is helpful

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 25
1667
3
thg 7 25
3293
1
thg 5 25
1433
1
thg 5 25
1689
4
thg 5 25
2846