Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7540 มุมมอง

Hey i have a custom module which i have embed into maintenance. There i create roles lets say i have "mason" in occupation and in  line view i add five lines relationg to masons works. Now that is a Char field. What i want is that in my maintenance request when i select mason from a field i want another field which must show all the values in line so that i be able to select one of them based on the nature of work. I dont want to use selection fields here, 

This is how i am getting data from that model


occupation = fields.Many2one('my.model', string ='Trade')
But how to make a field which must fetch all the lines related to the occupation selected.
Thanks in advance
อวตาร
ละทิ้ง

By reading it, not understand what exactly you need, does a compute function or writing values to a character field in onchange will solve your issue ?

ผู้เขียน

Lets suppose that you have 5 lines in sale order line and from these lines you want to fetch all 5 five products from these lines in one field? You getting it now?

คำตอบที่ดีที่สุด

If I take your example with sale.order.line, you can do something like this:

First, declare in sale.ordera many2many field that will get product, let's say:

product_ids = fields.Many2many("product.product", compute="_compute_product_ids")

Then in your compute function

@api.depends('order_line')
def _compute_product_ids(self):
for rec in self:
rec.product_ids = [(6, 0, rec.order_line.mapped('product_id').ids)]


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ธ.ค. 19
5058
1
พ.ค. 18
3633
Many2one related field แก้ไขแล้ว
3
ก.ย. 21
9569
Representation of Many2one in view แก้ไขแล้ว
4
ม.ค. 20
3365
0
พ.ย. 18
4606