Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
3084 Ansichten

Hi,



I'm new to Odoo development and I'm trying to understand how I can access the fields of the parent model in a wizard. Let's say the wizard is opened by a button in the view of my model EstateProperty:



I understand that I can pass individual simple fields to the wizard model with the context tag. That works. However, I couldn't get it working for One2Many fields "offer_ids" in the parent model EstateProperty.

Or is it possible to access the fields of the parent model EstateProperty, e.g. One2Many "offer_ids" from within the wizard model in python itself:


class EstatePropertyWizard(models.TransientModel):
_name = "estate.property.wizard"
_description = "Estate Property Wizard"

name = fields.Char(required=True)
description = fields.Text()

Thanks in advance!



Avatar
Verwerfen
Beste Antwort

Hi,

From the default get method of the wizard model, you can get the parent record by browsing the active_id from the context, once you browse with the active_id, you will get recordset of the parent model.

Sample:

@api.model
def
default_get(self, fields):
res = super(StockImmediateTransfer, self).default_get(fields)
if not res.get('pick_id') and self._context.get('active_id'):
res['pick_id'] = self._context['active_id']
return res

See: https://www.youtube.com/watch?v=icl4IEWWmuU

Thanks

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Sept. 25
1982
1
Juni 25
2010
3
Juli 25
3587
1
Mai 25
1715
4
Mai 25
3059