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

Hello everyone


I've created a model, that relationates two models in a many2many relation like this:

class ticeting_dashboard_priority(models.Model):
_name="ticketing.dashboard.priority"
dashboard_id = fields.Many2one('service.dashboard', 'Dashboard', domain="[('type','=', 'dashboard')]", required=True)
priority_id = fields.Many2one('ticketing.priority', 'Priority', required=True)


Now i have the service.queue model like this :

class Queue(models.Model):
_name = 'service.queue'
dashboard_id = fields.Many2one('service.dashboard', 'Dashboard', required=True,
domain="[('type','=', 'dashboard')]")
name = fields.Char(String='Queue', required=True)
code = fields.Char(String='Code', required=True)
post = fields.Char(String='Post', required=True)
current_ticket = fields.Char(default='N/A')
next_ticket = fields.Char(default='N/A')
users = fields.One2many('service.users.queue.rel', 'queue_id', 'Users')
queue_ids = fields.One2many('service.ticket', 'queue_id', 'Users', domain="[('type','=', 'dashboard')]")
priority = fields.Many2one('ticketing.priority', 'Priority', required=True, default=lambda self: self.env['ticketing.dashboard.priority'].search([('dashboard_id','=',self.dashboard_id)]))


as you can see i have a dashboard_id field.


So i've a a table that relationates dashboard with priorities but now i have the queues that are related to the dashboard and i want to select only the priorities that belong to the dashboard for that queue, and thus i have the priorities field in that are related to the service.priorities field, but i want to filter it based on the dashboard id from the relation table.


thanks in the advance








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

Works! tx

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

In my understanding you want records in second field on the basis (onchange) of first field, if yes than try this:

1    @api.onchange('first_field')
2    def _first_field_onchange(self):
3        res = {}
4        res['domain']={'second_field':[('first_field', '=', self.first_field.id)]}
5        return res

To get detailed info visit: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 15
4767
0
thg 3 15
4148
1
thg 8 23
2512
1
thg 1 21
4045
3
thg 9 20
71871