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

I am inheriting the action_produce method from the class mrp_production.  I want to get the quants that are reserved for each of the moves.

The beginning of my method looks like this:

 

    @api.model
    @api.depends('move_created_ids')
    def action_produce(self, production_id, production_qty, production_mode, wiz=False, context=None):
        production = self.browse(production_id)
        domain = ['reservation_id', 'in', production.move_lines.ids]
        stock_quants_obj = self.env['stock.quant']
        pdb.set_trace()
        quants = stock_quants_obj.search(domain)

When I get to the last line above, I get:

ValueError: Invalid leaf reservation_id

I tried using other fields that exist in stock.quant (eg ['cost','>','0']) and they all say Invalid leaf [fieldname]

Is there something wrong with how I'm getting my stock_quants_obj?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try this:

domain = [('reservation_id', 'in', production.move_lines.ids)]

อวตาร
ละทิ้ง
ผู้เขียน

This works! Could you explain this to me? In looking at other domains and (obviously misreading the ORM documentation), I thought that my syntax was correct.

https://media.readthedocs.org/pdf/odoo-new-api-guide-line/latest/odoo-new-api-guide-line.pdf

ผู้เขียน

Ah, I see! Thank you.

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

This Works. for me

scores = results.search([('category', '=', 'Division 3')])
try this
domain =

domain = ([('reservation_id', 'in', production.move_lines.ids)])


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 23
31290
@api.depends not triggering function แก้ไขแล้ว
6
ม.ค. 18
33134
Error in new API name_get function? แก้ไขแล้ว
1
ส.ค. 15
6981
0
มี.ค. 15
6566
1
ส.ค. 25
763