I have a one2many field in a model. This model form view shows the one2many field as a tree view , where there are inline fields. I want the one2many field to be a selection list like a many2one field. I want the user to select from a list instead of typing. How can I do this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
If you want to select multiple records in a field, you can use the Many2many field in odoo.
Using the One2many field as a selection field is a false concept.
Thank you.
Let me explain better. As you can see at the bottom of the image, the one2many field is shown as a tree view. However when user clicks on "Add item" a new row show up with text fields to add. But instead of text field I want it to be a list of all items from database so that user can only select from the list instead of a empty field. I tried adding widget="selection" but then I get an empty selection box.
<record id="iventiva_invoice_parameter_location_form" model="ir.ui.view">
<field name="model">account.invoice.parameter</field>
<field name="inherit_id" ref="iventiva_account_invoicing.account_invoice_parameter_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="inside">
<group string="Assigned Locationsssrrr">
<field name="stock_location_ids" nolabel="1">
<tree editable="bottom">
<field name="name" widget="selection"/>
</tree>
</field>
</group>
</xpath>
</field>
</record>
Then name field should be a Many2one field. not a char field.
Here is the basic class structure:
class A(models.Model):
_name = 'class.A'
associated_id = fields.Many2one('class.B')
name = fields.Char("Some name")
class B(models.Model)
_name = 'class.B'
a_ids = fields.One2many('class.A', 'associated_id')
in class B view, I have:
<field name="a_ids" nolabel="1">
<tree editable="bottom">
<field name="name"/>
</tree>
</field>
I want the name field to be a selection field containing all records of class A instead of a char field so that user does not have to type, just select from the list of A record names.
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
apr. 15
|
3815 | ||
|
1
mrt. 15
|
9365 | ||
|
1
dec. 24
|
1392 | ||
|
0
jun. 19
|
3683 | ||
|
1
aug. 18
|
7916 |