Skip to Content
Menu
This question has been flagged
3643 Zobrazenia
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)]}}
Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
1
máj 21
3096
0
júl 20
3464
2
jan 18
4265
1
aug 24
2959
1
feb 24
2148