Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3596 Zobrazení
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šit
Related Posts Odpovědi Zobrazení Aktivita
1
kvě 21
3047
0
čvc 20
3370
2
led 18
4217
1
srp 24
2819
1
úno 24
2070