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

Hey, I'm trying to relate the field number(its the code of helpdesk.ticket) of the model helpdesk.ticket but taking care that only the ones that "nombrecomercial" that is a field of my model is equal to partnergf_id that is a field i added to the helpdesk.ticket, but im missing something TY for your help
 ticket = fields.Many2one('helpdesk.ticket', string='Ticket vinculado', domain="[('nombrecomercial', '=', self.partnergf_id)]")

UPDATE:
I'm trying to make a relation between the model client.parte and the model  helpdesk.ticket so i can relate the tickets to a  report, to do that i create a field in mi client.parte called ticket that is a many2one, and i try to make that the domain is the name of the customer in the report is the same of many tickets and i can select one, but the problem is that the name is too a many2one field

client.parte_nombrecomercial=
 [ nombrecomercial = fields.Many2one('res.partner', string='Nombre comercial', domain=[('is_company', '=', True)]) ]
helpdesk.ticket_partnergf_id=
[partnergf_id = fields.Many2one('res.partner', string='Cliente', domain=[('is_company', '=', True)])]



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

Hi Marcos

Check these references to set the domain for many2one fields

Domain for Many2one field

Try this code

ticket=fields.Many2one('helpdesk.ticket,'Ticket vinculado',domain="[('nombrecomercial','=',partnergf_id)]")


Regards


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

Hi,

We can use partnergf_id directly in the domain instead of self.partnergf_id. The self reference is not valid in this context because you are defining the domain for the field itself. 

Here's the corrected code:
ticket = fields.Many2one('helpdesk.ticket', string='Ticket vinculado', domain="[('nombrecomercial', '=', partnergf_id)]")

Hope it helps,

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

Your description is a little bit confusing, but if the field partnergf_id is in helpdesk.ticket model then the domain should be something like this:
ticket = fields.Many2one('helpdesk.ticket', string='Ticket vinculado', domain="[('partnergf_id', '=', self.nombrecomercial)]")

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 23
2087
1
thg 9 25
2384
1
thg 6 25
2403
3
thg 7 25
3886
1
thg 5 25
2017