Odoo Help


Regarding one2many field

on 9/11/13, 4:52 AM 2,945 views

I was trying to add a one2many field..but its giving the following error.

Server Traceback (most recent call last):
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\openerp\addons\web\session.py", line 89, in send
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\osv.py", line 131, in wrapper
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\osv.py", line 197, in execute
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\osv.py", line 185, in execute_cr
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\orm.py", line 3604, in read
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\orm.py", line 3724, in _read_flat
 File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\.\openerp\osv\fields.py", line 538, in get
TypeError: unhashable type: 'list'

any idea??? Please answer..

hello, can you put some lines of the code ...

Ahmed M.Elmubarak
on 9/11/13, 8:55 AM

is the sale.order model inherited or customized, if customized, if it contains m2o field called 'order_line' from 'hotel.sale.line'?

Ahmed M.Elmubarak
on 9/11/13, 9:39 AM

yaah..I have added m2o field in sale.order model

on 9/11/13, 11:59 AM

code is....'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}), 'sale_line':fields.many2one('hotel.sale.line','order_lines'),

on 9/11/13, 11:59 AM
On 9/11/13, 9:37 AM

in .py file

class hotel_sale_line(osv.osv):
    _name = 'hotel.sale.line'
    _description = "Sale Line"
    _columns ={          
        'order_lines':fields.one2many('sale.order','order_line','Sales Order'),

and in .xml file---

<separator string="Sale Order Lines" colspan="4"/> 
<field name="sale_lines" colspan="4" nolabel="1"> 
<form string="Sales Order">
 <separator string="Sales Order"/>
 <field name="order_lines" select="1" colspan="4" nolabel="1"/>
 </form> <tree string="Sales Order Lines" editable="bottom"> 
 <field name="order_lines"/>

I am not sure what you want to do, but all the concept is wrong. If you are inheriting the sales.order then you don't have to create another model, you have to add some fields to sale.order. If you are creating a new model then you can't have the order.lines because sale.order is already using that. If you want to add sale.order to your model you have to have 2 fields that relate them. a many2one and one2many, then its going to work

GH Mediacloud, Grover Menacho
on 9/11/13, 7:20 PM

I am new to openerp. So, Please can you post one example for that.Thanks for your help.

on 9/12/13, 3:43 AM

@Krishna please check this like https://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/field_type.html/ for one2many field, and as @Grover said please tell us what do you aim to do, is it your own customized module , or you want to inherit the sale module

Ahmed M.Elmubarak
on 9/12/13, 4:54 AM

ok..i want to add the sale order line in my custom module then what should I have to do for that?

on 9/12/13, 4:59 AM

using my code..i can see the sale order form from sales module..everything is working fine..but when i confirm my whole form then it gives error of such type.that i have shown you..So where is problem i can't undestand???

on 9/12/13, 5:07 AM

Please don't put direct link to the existing models in openerp, it is a bad practise. Instead of that inherit an existing class here it is sale.order, and add your required fields you want to display additionally and along with that, give a many2one id inorder to create an inverse relationship with the former model that is here it is hotel.sale.line. then onlye you can create a one2many relationship. But at first you have to define the inherited hotel.sale.line after that define sale.order in your custom module, Thanks

Abhishek H Menon
on 9/13/13, 4:10 AM
Abhishek H Menon
On 9/13/13, 4:15 AM
from osv import fields,osv
    class hotel_sale_line(osv.osv):
        _description='Hotel Sale'
        _columns= {
             'order_lines':fields.one2many('sale.order','order_line','Sales Order'),

    class sale_order(osv.osv):
            'order_line': fields.many2one('hotel.sale.line','Order')

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 9/11/13, 4:52 AM
Seen: 2945 times
Last updated: 3/16/15, 8:10 AM