Odoo Help

Welcome!

This community 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.

0

Regarding one2many field

By
Krishna
on 9/11/13, 4:52 AM 1,879 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

Krishna
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'),

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

in .py file

class hotel_sale_line(osv.osv):
    _name = 'hotel.sale.line'
    _description = "Sale Line"
    _columns ={          
       'folio_id':fields.many2one('hotel.folio'),
        '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"/>
 </tree>
 </field>

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.

Krishna
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?

Krishna
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???

Krishna
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
0
Abhishek H Menon
On 9/13/13, 4:15 AM
from osv import fields,osv
    class hotel_sale_line(osv.osv):
        _name='hotel.sale.line'
        _description='Hotel Sale'
        _columns= {
             'folio_id':fields.many2one('hotel.folio'),
             'order_lines':fields.one2many('sale.order','order_line','Sales Order'),
             }
    hotel_sale_line()

    class sale_order(osv.osv):
        _inherit='sale.order'
        _columns={
            'order_line': fields.many2one('hotel.sale.line','Order')
            }   
    sale_order()

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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