Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2772 Weergaven

Hello ! 


Here's my problem, i'd like to create a liste of multiple text box like a one2many relation, with a button to add new row and i'd like to now if this is possible. I have no clues on how to do so. I've tried searching for a button with a creation function but i only find button that turn on invisible from an already existing field wich is not what i'm looking for.


Thank you for your responces.


Ewen JEZEQUEL

Avatar
Annuleer
Auteur Beste antwoord

Okay i realised i didn't specify it but i dont want neather a Many2One relation nor a One2Many, i want to be able to create new line of 3 text box not related to anything exepte my custom module. And i want to be able to add as much as i want. Thx for your response.

Regardes.


To close the subject i'll said what i did to dodge the problem:
instead of reinvented the weal i just euse what i was given and create a liste of one2many but i dont use the many2one relation so i have a liste of text box related to a module like the one i make (almost related to it self) but i juste don't use it or display it.
For help or details don't esitate to ask me.

Ewen JEZEQUEL


Avatar
Annuleer
Beste antwoord

I understand that you want to create a field array, similar to adding products to an order. You can refer to the following code snippet:

Avatar
Annuleer

from odoo import models, fields

class Order(models.Model):
_name = 'order.model'
_description = 'Order'

name = fields.Char(string='Order Name', required=True)
order_lines = fields.One2many('order.line.model', 'order_id', string='Order Lines')

class OrderLine(models.Model):
_name = 'order.line.model'
_description = 'Order Line'

order_id = fields.Many2one('order.model', string='Order')
product_id = fields.Many2one('product.model', string='Product')
quantity = fields.Float(string='Quantity', default=1.0)

and view
<odoo>
<data>
<record model="ir.ui.view" id="view_order_form">
<field name="name">order.model.form</field>
<field name="model">order.model</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name"/>
</group>
<notebook>
<page string="Order Lines">
<field name="order_lines" mode="tree">
<tree editable="bottom">
<field name="product_id"/>
<field name="quantity"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</data>
</odoo>

Gerelateerde posts Antwoorden Weergaven Activiteit
0
dec. 24
1465
2
sep. 22
8694
4
mrt. 19
9869
0
jun. 17
990
5
apr. 15
5670