Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
2776 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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


Awatar
Odrzuć
Najlepsza odpowiedź

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:

Awatar
Odrzuć

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>

Powiązane posty Odpowiedzi Widoki Czynność
0
gru 24
1476
2
wrz 22
8737
4
mar 19
9888
0
cze 17
990
5
kwi 15
5676