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

I have a one2many field in the model abc.classification.profile.level

level_ids = fields.One2many(
        comodel_name="abc.classification.profile.level", inverse_name="profile_id"
    )

My profile_id field is company_dependent. Also, in the model product.template i want to show a many2one field that contains the values of the one2many field.

abc_classification_level_id_aux = fields.Many2one(
        "abc.classification.profile.level",
        store=True,
        compute=domain_abc_classification_level_ids,
        readonly=False
    )

My problem is that I can't get the field to show the correct values, although when I do a print it tells me the values ​​I want to obtain. I have tried in the way indicated in the function and also with a write, however I do not get it in any of the ways.

@api.onchange('abc_classification_profile_id_aux')
    def domain_abc_classification_level_ids(self):
        company = self.env.company.id
        self.sudo().with_context(company_id = company, with_company = company)
        print(self.abc_classification_profile_id_aux.level_ids)

        return self.abc_classification_profile_id_aux.level_ids.ids

The field indicate in api.onchange is this:

abc_classification_profile_id_aux = fields.Many2one(
        "abc.classification.profile",
        company_dependent=True,
        store=True,
    )





Avatar
Hylkää
Paras vastaus

Hi, 

You can see following for this:

https://youtu.be/GkNgc-fZO-I

Hope it helps,

Thanks

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
jouluk. 20
3484
2
jouluk. 20
8250
2
huhtik. 23
2801
1
maalisk. 23
2302
2
helmik. 25
40487