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

TypeError: 'long' object is not iterable .....when i add one2many field

By
Krishna
on 9/12/13, 7:52 AM 2,731 views

in .py file--

class hotel_folio(osv.osv):


         _name = 'hotel.folio'
        _description = 'hotel folio new'
        _columns = {
            'sale_lines':fields.one2many('hotel.sale.line', 'folio_id', ondelete='cascade'),
            }

hotel_folio()

    class hotel_sale_line(osv.osv):

        _name = 'hotel.sale.line'
        _description = "Sale Line"
        _columns = {
                'order_line': fields.one2many('sale.order', 'order_line', 'Order Lines'),
                'folio_id':fields.many2one('hotel.folio'),
                }

hotel_sale_line()

And in .xml file--

                        <field name="sale_lines" colspan="4" nolabel="1">
                            <form string="Sale Order Line">
                            <separator string="Sale Order"/>
                            <field name="order_line" select="1" colspan="4" nolabel="1"/>                               
                            </form>
                            <tree string="Sale Order Line">
                            <field name="order_line" select="1"/>                               
                            </tree>
                        </field>

the error is---

File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server.\openerp\osv\orm.py", line 4469, in create File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server.\openerp\osv\fields.py", line 557, in set File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\openerp\addons\sale_stock\sale_stock.py", line 75, in create File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\openerp\addons\sale\sale.py", line 337, in create File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server\openerp\addons\mail\mail_thread.py", line 242, in create File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server.\openerp\osv\orm.py", line 4469, in create File "C:\Program Files\OpenERP 7.0-20130627-231102\Server\server.\openerp\osv\fields.py", line 554, in set TypeError: 'long' object is not iterable

0

saad

--saad--
1008
| 5 4 8
Casablanca, Morocco
--saad--
saad
On 9/12/13, 1:55 PM

Hi,

  1. the ondelete attribure isn't in the right place
  2. we don't use select="1" in one2many fields
  3. You should create the relation id field (order_line) in sale.order object

Try this for your python file:

class hotel_folio(osv.osv):
         _name = 'hotel.folio'
        _description = 'hotel folio new'
        _columns = {
            'sale_lines':fields.one2many('hotel.sale.line', 'folio_id','Lines' ),
            }

hotel_folio()

class hotel_sale_line(osv.osv):

        _name = 'hotel.sale.line'
        _description = "Sale Line"
        _columns = {
                'order_line': fields.one2many('sale.order', 'order_line', 'Order Lines'),
                'folio_id':fields.many2one('hotel.folio','Related Folio', ondelete='cascade'),
                }
hotel_sale_line()

in sale.order, the relation was established already like this--------------------------- 'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),

Krishna
on 9/13/13, 3:50 AM

This relation is between sale.order and sale.order.line. Your need is not clear, you may want that your 'hotel.folio' has many sale.order.line !!

saad
on 9/13/13, 5:56 AM

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/12/13, 7:52 AM
Seen: 2731 times
Last updated: 3/16/15, 8:10 AM