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

How can I read from a related field, all sale.order objects which are on 'draft' state?


I've tried this:


class account_budget_bsi(models.Model):

    _name = 'account.budget.bsi'

    _inherit = ['crossovered.budget', 'sale.order', 'stock.location', 'stock.move', 'purchase.order']

    sale_order = fields.Many2one('sale.order')

    sales_bsi = fields.Many2one('sale.order' , related="sale_order.state.draft", string="Sales Planned")


But it's not working as it seems.


Any idea on how to achieve this?


I mean, the issue is that all the sale orders must be on 'draft' state, I know that maybe the Many2one related field isn't working because 'state' is a Selection one, but can't figure out how to load it like that.

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

Hi,

Related fields are used to show value of a field in a many2one.

If you want to filter many2one according to value set domain for your many2one field

sales_bsi = fields.Many2one('sale.order', string='Sales Planned', domain=[('state', '=', 'draft')])

Or if you are trying to view all sale order in draft state you can add it as a many2many field and give default value for that field.


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
What is `state` in Many2one field? แก้ไขแล้ว
1
ก.พ. 24
1526
3
มี.ค. 18
5842
1
เม.ย. 20
5032
2
พ.ย. 18
14658
1
มิ.ย. 18
3818