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

I try filter list of values in dropdown list of many2one field (this field is in tree). For this I've created functional field which return list of allowed ids. In xml file i used domain with in condition. Here's my code

In py file

class cm_order_line(osv.osv):
_name = 'cm.order.line'

def _get_order_ids(self, cr, uid, ids, field_names=None, arg=None, context=None):
task_order_ids = [5,9,10]    # only as simplification...
return task_order_ids

_columns = {
'order_id': fields.many2one('stock.picking', 'Order Name'),
'order_ids': fields.function(_get_order_ids, type='char', string='Orders IDs', store=False),

_defaults = {
'order_ids': _get_order_ids
}

In XML

<field name="order_ids" invisible="1"/>
<field name="order_id" on_change="onchange_order_id(order_id)" domain="[('type','=','out'),('id', 'in', order_ids)]"/>

Everything works fine when i create new record. Domain works normal but after save (or when i just want to open inserted records) it gives error

AttributeError: 'list' object has no attribute 'get'
อวตาร
ละทิ้ง

These are not the same, as Sahib needs to provide a list of IDs, not a single ID...

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

Hi,

Yor passing "order_ids" field domain xml file but its function field and not stored in data base thats why you facing this error.

Thank

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

change type='char', to type='many2one',
This will work

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 15
7595
1
มี.ค. 15
5343
0
มี.ค. 15
4033
6
พ.ค. 24
71123
1
ต.ค. 23
2152