İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1346 Görünümler

Hi,

I have created a form that has multiple items and I want to show that in a table format.
I created a table using  ET.Element() but don't know how to create multiple tables under one table.

Please help with this.







Avatar
Vazgeç
En İyi Yanıt

Hello Vikas Maharana,



from lxml import etree as ET


# Create the root element

root = ET.Element('root')


# Create the main table

main_table = ET.SubElement(root, 'table')


# Create the first sub-table under the main table

sub_table1 = ET.SubElement(main_table, 'table')


# Create the second sub-table under the main table

sub_table2 = ET.SubElement(main_table, 'table')


# Now you can add items to your sub-tables

item1 = ET.SubElement(sub_table1, 'item')

item1.text = 'Item 1'


item2 = ET.SubElement(sub_table2, 'item')

item2.text = 'Item 2'


In this example, sub_table1 and sub_table2 are both nested under main_table, which is nested under the root element. You can add as many sub-tables and items as you need in this way.


Please note that this is a generic example and you might need to adjust it according to your specific requirements in Odoo. If you’re dealing with relational fields like One2many or Many2many in Odoo, you might need to use different methods. For example, for a Many2many field, a list of tuples is expected. Here is the list of tuples that are accepted, with the corresponding semantics:

  • (0, 0, { values }) link to a new record that needs to be created with the given values dictionary
  • (1, ID, { values }) update the linked record with id = ID (write values on it)
  • (2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
  • (3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)
  • (4, ID) link to existing record with id = ID (adds a relationship)
  • (5) unlink all (like using (3,ID) for all linked records)
  • (6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Hope this helps!

Best regards,
Maciej

Avatar
Vazgeç
Üretici

Thanks

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ağu 24
1860
13
Mar 16
5319
1
Eyl 15
6017
0
Ağu 24
1449
2
Ağu 24
2202