Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
6900 Tampilan

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

Avatar
Buang

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

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

Penulis

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

Penulis

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

Penulis Jawaban Terbai

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>
Avatar
Buang

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

Penulis

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

@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

Penulis

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

Penulis

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

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

Jawaban Terbai
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()
Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Jun 21
4036
0
Des 17
4123
1
Des 17
6501
1
Apr 23
2481
2
Nov 21
33105