跳至内容
菜单
此问题已终结
3629 查看
0

I have selected partner and I have field invoice_ids. when I click add object I want that only invoices of partner, parent and all his child_ids invoice would be loaded. I tried to add the domain as you see above but I get an error

Uncaught Error: AttributeError: object has no attribute 'parent_id'

and I tried it without domain but with onchange but problem is that when i create record and chose partner onchnage starts to work but the is no partner_id yet when i select partner it's still no partner because it is not saved.. so need some help here.

'invoice_ids': fields.many2many(
            'account.invoice', 'cash_receipt_invoce_rel',
            'cash_receipt_id', 'invoice_id', "Invoices", 
            domain="[('partner_id','in', partner_id.parent_id.child_ids)]",

def onchange_field_id(self, cr, uid, ids, name, context=None):
    cash_rep = self.browse(cr,uid, ids,context=context)
    relation_ids = [x.id for x in cash_rep.partner_id.child_ids]
    return {'domain': {'invoice_ids': [('partner_id', 'in', relation_ids)]}}
形象
丢弃
相关帖文 回复 查看 活动
1
5月 21
3081
0
7月 20
3447
2
1月 18
4242
1
8月 24
2940
1
2月 24
2130