0

I try to add the Add a line and Add a section in the notebook section in odoo13. how can I add these features in odoo13 in XML?

Python code:

class productline(models.Model):  
    _name = 'product.line'

    product_id = fields.Many2one('product.product', string='product')

View definition:

<notebook>
    <page string="Indent details">
        <field name="roni">
            <tree editable="bottom">
                <field name="product_id"/>
            </tree>
       </field>
   </page>
</notebook>
Kenly
  • 24,317
  • 7
  • 44
  • 60
  • I added an [answer](https://stackoverflow.com/questions/64520995/odoo-14-add-a-section-functionality-in-tree-view) for Odoo 14, which is also working for Odoo-13. – Kenly Dec 11 '20 at 14:38
  • I can't save the field value of add section field in my database. It will automatically pop up a field when click it then automatically close the field. How can i recover from it. Can you explain it? – Md. Redone Hassan Dec 26 '20 at 11:12
  • Did you add a `name` field next to the `display_type` field? – Kenly Dec 26 '20 at 12:35
  • I added the name field before display_type like as you declared in your script. can you please give me the full code of it. So that i can understand it properly. Thank you in advance! – Md. Redone Hassan Dec 27 '20 at 04:38
  • The full code is in my answer linked in the first comment, first, you need to set the widget attribute to `section_and_note_one2many` then, add the ``control`` section, and finally define the two special fields `display_type` and `name` and add them to the view definition inside the `tree`, the `display_type` should be hidden (``) and you can set two more options on the `name` field (``). The `display_type` and `name` fields should be defined next to the `product_id` field. – Kenly Dec 27 '20 at 11:16
  • Did you succeed to add the section and note? – Kenly Dec 28 '20 at 16:24
  • no. i follow your process but can't complete it.. – Md. Redone Hassan Jan 10 '21 at 08:58
  • Please update your code and I will test it. – Kenly Jan 10 '21 at 11:05
  • complete your process but not work. ORM code: class productline(models.Model): _name = 'product.line' name = fields.Char(required=True) display_type = fields.Selection([ ('line_section', "Section"), ('line_note', "Note")], default=False, help="Technical field for UX purpose.") product_id = fields.Many2one('product.product', string='product') – Md. Redone Hassan Jan 10 '21 at 11:53
  • when i open add section field and write something after that other module code will automatically save it. But in my code showing a pop up window then if click ok on it. then it automatically delete the add section value. So should i will do? – Md. Redone Hassan Jan 10 '21 at 12:01
  • I tested your code and there is no popup, your code works. – Kenly Jan 10 '21 at 14:14
  • Thanks a lot, sir for providing me your time. But I also check today by following this same code but it currently shows up the same error. is there any problem with my version code or ORM design? I don't know what I will do to recover this. – Md. Redone Hassan Jan 11 '21 at 03:40
  • What error? Try to check the error log. – Kenly Jan 11 '21 at 08:22

1 Answers1

0

Try this.

      <page string="Indent details">
                            <field name="roni" widget="section_and_note_one2many">

                                <tree editable="bottom">



                                    <field name="product_id"/>

                                    
                                </tree>

                            </field>


                    </page>

                </notebook>
Neural
  • 376
  • 3
  • 12