コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
2779 ビュー

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

アバター
破棄
著作者 最善の回答

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


アバター
破棄
最善の回答

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:

アバター
破棄

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>

関連投稿 返信 ビュー 活動
0
12月 24
1476
2
9月 22
8737
4
3月 19
9888
0
6月 17
990
5
4月 15
5676