This question has been flagged
2 Replies
3341 Views

At the moment i can only have single note available by using field.text('Note') but i want to add multiple notes , How to achieve this functionality?

Thanks

Shazz

Avatar
Discard
Best Answer

You need something like that in your xml that would create two Note tab.

                <page string="First Note">
                    <separator string="'Comment1'" colspan="4"/>
                    <field name="your_field" colspan="4" nolabel="1"/>
                </page>
                <page string="Second Note">
                    <separator string="'Comment2'" colspan="4"/>
                    <field name="your_field_2" colspan="4" nolabel="1"/>
                </page>

New update Something like this but you will have to create a one2many field for the notes this XML below should work.

                <page string="Notes">
                    <field colspan="4" mode="form,tree" name="notess" select="1" height="260"> 
                        <form string="User Note">

                            <field name="notes"/>
                            <field name="note_description" />
                        </form>
                        <tree string="User Note">
                            <field name="notes_id" />
                            <field name="note_description" />                         
                        </tree>
                    </field>
                </page>

and in your python add something like this

class lab_product(osv.osv):
_name = 'lab.product'
_columns = {
    'name': fields.char('Field Name',size=x'),
    'notess': fields.one2many('lab.product.notess','notes_id','User Comment'),
    'note_description': fields.related('notess','note_description',type='char', string='Short Description'),
    'notid': fields.related('notess','notes',type='text', string='Work Note'),
}
 lab_product()

class lab_product_notess(osv.osv):
_name = 'lab.product.notess'
_columns = {
    'notes_id': fields.many2one('lab.product','Product', select=True, required=True),
    'note_description': fields.char('Short Description', size=100),
    'notes': fields.text('Work Note', size=10000),
}
lab_product_notess()

Hope this is helpful. You can always improve on it but that will do what you wanted You can see I created two classes and made one one to many and the other many to one. The lab product class can have many notes and many note class can have one lab product. Relate the field and that should do it. When you run this, you will be able to make lots of notes under Notes tab (as many as you want) you can then set to readonly as you wish.

Avatar
Discard
Author

It will be depending on user how much notes he can add. suppose on same form i want to add 20 notes today and 30 new notes tomorrow so for this i need to add 50tabs!!!! If i want everything on single tab, how it can be done?

Interesting. That would be a nice feature actually give me some minutes. what you will need is a create note that allows you to create the notes you want. I think you will need a one to many connection.

Best Answer
            <page string="First Note">
                <separator string="'Comment1'" colspan="4"/>
                <field name="your_field" colspan="4" nolabel="1"/>
            </page>
            <page string="Second Note">
                <separator string="'Comment2'" colspan="4"/>
                <field name="your_field_2" colspan="4" nolabel="1"/>
            </page>
Avatar
Discard