Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
3879 Näkymät

I have a Many2one field I am adding a domain to through the onchange but I would like the domain to also be applied when the record is first created since the onchange isn't necessarily called then.


This is the domain I am currently returning, and the partner_id is often set through the vals dictionary in the create method.

res["domain"] = {
            "contact_id": [
                ("type", "not in", ["invoice", "delivery"]),
                ("parent_id", "in", [self.partner_id.id]),
            ]
        }

I have also tried doing the following but it does not seem to work.


contact_id = fields.Many2one(
        "res.partner",
        domain="[('type', 'not in', ['invoice', 'delivery']),"
        + "('parent_id', '=', partner_id),]",
    )
Avatar
Hylkää
Tekijä Paras vastaus

I was testing the domain with a local version of Odoo and it looks like it wasn't updating the domain of the field properly. So now that I restored my database and loaded in the module again it looks like this is working properly.

contact_id = fields.Many2one(
        "res.partner",
        domain="[('type', 'not in', ['invoice', 'delivery']),"
        + "('parent_id', '=', partner_id),]",
    )
Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
syysk. 19
4368
7
maalisk. 25
10428
3
toukok. 24
5292
3
marrask. 24
45396
1
huhtik. 23
5137