1

I have these models

The model event.booth always has a halle_id The model order.wizard has an event_booth_id and event_booth_ids

Now, in the view form order.wizard in the many2many checkboxes widget from event_booth_ids I only want to show the records where the halle_id matches with the one from event_booth_id.halle_id

This is my current attempt (order wizard form):

<record id="rectanglemaps_create_order_view_form" model="ir.ui.view">
      <field name="name">rectanglemaps.order.wizard.form</field>
      <field name="model">rectanglemaps.order.wizard</field>
      <field name="arch" type="xml">
            <form>
                ...
                <field name="event_booth_ids" widget="many2many_checkboxes" domain="[('halle_id', '=', event_booth_id.halle_id)]"/>
            </form>
      </field>
</record>

As you can see i am trying to achieve this with the domain domain="[('halle_id', '=', self.event_booth_id.halle_id)]"

Unfortunately, I am getting the following error

Ungültiges zusammengesetztes Feld in domain="[('halle_id', '=', self.event_booth_id.halle_id)]"
unnamed-dev
  • 165
  • 8

2 Answers2

1

As the error states: You can not use dottet fields in the second part of the domain. Instead you should create a related field like this:

halle_id = self.Many2one(related='event_booth_id.halle_id')

and use it in the domain like this:

domain="[('halle_id', '=', halle_id)]"
Kampatrip
  • 91
  • 4
  • Thank you for the answer, how can i make halle_id present in wizard form? I get this error "Das Feld 'halle_id' , das in domain of ([('halle_id', '=', halle_id)]) verwendet wird, muss in der Ansicht vorhanden sein, fehlt jedoch" – unnamed-dev Oct 05 '22 at 16:10
  • nevermind, solved it – unnamed-dev Oct 05 '22 at 19:14
1

You can't use dotted field names in domain and by default, self is not available in the evaluation context

You can use a related field:

halle_id = fields.Many2one(related='event_booth_id.halle_id')

And use it in domain like following:

domain="[('halle_id', '=', halle_id)]"

The halle_id field must be present in wizard form

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • Thank you for the answer, how can i make halle_id present in wizard form? I get this error "Das Feld 'halle_id' , das in domain of ([('halle_id', '=', halle_id)]) verwendet wird, muss in der Ansicht vorhanden sein, fehlt jedoch" – unnamed-dev Oct 05 '22 at 16:09
  • nevermind, i solved it – unnamed-dev Oct 05 '22 at 19:14
  • 1
    You just need to add the field description in the wizard form view. Example: `` – Kenly Oct 06 '22 at 08:18