Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

官方的 travel 你们能用吗?



  • [url=doc.openerp.com/developer/2_First_Module/2_module.html#changing-the-main-module-file][color=#0000ff]http://doc.openerp.com/developer/2_First_Module/2_module.html#changing-the-main-module-file[/color][/url]

    我按这个做的.

    建了个 terp.py

    [code]

    -- encoding: utf-8 --

    {
    "name" : "Travel agency module",
    "version" : "1.0",
    "author" : "Tiny",
    "category" : "Generic Modules/Others",
    "website": "www.openerp.com",
    "description": "A module to manage hotel bookings and a few other useful features.",
    "depends" : ["base"],
    "init_xml" : [],
    "update_xml" : ["custom_view.xml"],
    "active": True,
    "installable": True
    }
    [/code]

    init.py

    [code]

    -- encoding: utf-8 --

    import custom

    [/code]

    custom.py
    [code]

    -- encoding: utf-8 --

    from osv import osv, fields
    class travel_hostel(osv.osv):
    _name = 'travel.hostel'
    _inherit = 'res.partner'
    _columns = {
    'rooms_id': fields.one2many('travel.room', 'hostel_id', 'Rooms'),
    'quality': fields.char('Quality', size=16),
    }
    _defaults = {
    }
    travel_hostel()
    [/code]

    custom_view.xml
    [code]
    <openerp>
    <data>
    <record model="res.groups" id="group_compta_user">
    <field name="name">grcompta</field>
    </record>
    <record model="res.groups" id="group_compta_admin">
    <field name="name">grcomptaadmin</field>
    </record>
    <menuitem name="Administration" groups="admin,grcomptaadmin" icon="terp-stock" id="menu_admin_compta"/>
    </data>
    </openerp>
    [/code]

    traval_view.xml
    [code]
    <openerp>
    <data>
    <record model="ir.actions.act_window" id="action_travel_hostel_form">
    <field name="name">Hostel</field>
    <field name="res_model">travel.hostel</field>
    <field name="view_mode">form,tree</field>
    </record>
    <menuitem name="Travel Agency"
    id="menu_travel"/>
    <menuitem name="Hostels"
    id="menu_travel_hostel_form"
    action="action_travel_hostel_form" parent="menu_travel"/>
    <record model="ir.actions.act_window" id="action_travel_room_form">
    <field name="name">Room</field>
    <field name="res_model">travel.room</field>
    <field name="view_mode">form,tree</field>
    </record>
    <menuitem name="Rooms"
    id="menu_travel_room_form"
    action="action_travel_room_form" parent="menu_travel"/>
    <record model="ir.actions.act_window" id="action_travel_room_form1">
    <field name="name">Single Rooms</field>
    <field name="res_model">travel.room</field>
    <field name="domain">[('beds','=',1)]</field>
    <field name="view_mode">tree,form</field>
    </record>
    <menuitem name="Single rooms"
    id="menu_travel_room_form1"
    action="action_travel_room_form1" parent="menu_travel_room_form"/>
    <record model="ir.actions.act_window" id="action_travel_room_form2">
    <field name="name">Double Rooms</field>
    <field name="res_model">travel.room</field>
    <field name="domain">[('beds','=',2)]</field>
    <field name="view_mode">tree,form</field>
    </record>
    <menuitem name="Double rooms"
    id="menu_travel_room_form2"
    action="action_travel_room_form2" parent="menu_travel_room_form"/>
    </data>
    </openerp>
    [/code]

    然后 安装 该模块时. 出现错误.
    [code]
    Traceback (most recent call last):
    File "netsvc.pyo", line 231, in dispatch
    File "netsvc.pyo", line 74, in call
    File "serviceweb_services.pyo", line 537, in execute
    File "serviceweb_services.pyo", line 517, in execute
    File "wizard__init
    _.pyo", line 178, in execute
    File "wizard__init__.pyo", line 74, in execute_cr
    File "C:Program FilesOpenERP AllInOneServeraddonsbasemodulewizardwizard_module_upgrade.py", line 92, in upgrade_module
    File "pooler.pyo", line 61, in restart_pool
    File "pooler.pyo", line 40, in get_db_and_pool
    File "addons__init
    _.pyo", line 704, in load_modules
    File "addons__init__.pyo", line 605, in load_module_graph
    File "toolsconvert.pyo", line 881, in convert_xml_import
    File "toolsconvert.pyo", line 775, in parse
    File "toolsconvert.pyo", line 573, in _tag_menuitem
    File "toolsconvert.pyo", line 756, in id_get
    File "toolsmisc.pyo", line 640, in cached_result
    File "C:Program FilesOpenERP AllInOneServeraddonsbaseirir_model.py", line 416, in _get_id
    IndexError: list index out of range

    [/code]
    问下怎么解决? 谢谢大家.



  • [url=doc.openerp.com/developer/2_First_Module/2_module.html#changing-the-main-module-file][color=#0000ff]http://doc.openerp.com/developer/2_First_Module/2_module.html#changing-the-main-module-file[/color][/url]

    我按这个做的.

    建了个 terp.py

    [code]

    -- encoding: utf-8 --

    {
    "name" : "Travel agency module",
    "version" : "1.0",
    "author" : "Tiny",
    "category" : "Generic Modules/Others",
    "website": "www.openerp.com",
    "description": "A module to manage hotel bookings and a few other useful features.",
    "depends" : ["base"],
    "init_xml" : [],
    "update_xml" : ["custom_view.xml"],
    "active": True,
    "installable": True
    }
    [/code]

    init.py

    [code]

    -- encoding: utf-8 --

    import custom

    [/code]

    custom.py
    [code]

    -- encoding: utf-8 --

    from osv import osv, fields
    class travel_hostel(osv.osv):
    _name = 'travel.hostel'
    _inherit = 'res.partner'
    _columns = {
    'rooms_id': fields.one2many('travel.room', 'hostel_id', 'Rooms'),
    'quality': fields.char('Quality', size=16),
    }
    _defaults = {
    }
    travel_hostel()
    [/code]

    custom_view.xml
    [code]
    <openerp>
    <data>
    <record model="res.groups" id="group_compta_user">
    <field name="name">grcompta</field>
    </record>
    <record model="res.groups" id="group_compta_admin">
    <field name="name">grcomptaadmin</field>
    </record>
    <menuitem name="Administration" groups="admin,grcomptaadmin" icon="terp-stock" id="menu_admin_compta"/>
    </data>
    </openerp>
    [/code]

    traval_view.xml
    [code]
    <openerp>
    <data>
    <record model="ir.actions.act_window" id="action_travel_hostel_form">
    <field name="name">Hostel</field>
    <field name="res_model">travel.hostel</field>
    <field name="view_mode">form,tree</field>
    </record>
    <menuitem name="Travel Agency"
    id="menu_travel"/>
    <menuitem name="Hostels"
    id="menu_travel_hostel_form"
    action="action_travel_hostel_form" parent="menu_travel"/>
    <record model="ir.actions.act_window" id="action_travel_room_form">
    <field name="name">Room</field>
    <field name="res_model">travel.room</field>
    <field name="view_mode">form,tree</field>
    </record>
    <menuitem name="Rooms"
    id="menu_travel_room_form"
    action="action_travel_room_form" parent="menu_travel"/>
    <record model="ir.actions.act_window" id="action_travel_room_form1">
    <field name="name">Single Rooms</field>
    <field name="res_model">travel.room</field>
    <field name="domain">[('beds','=',1)]</field>
    <field name="view_mode">tree,form</field>
    </record>
    <menuitem name="Single rooms"
    id="menu_travel_room_form1"
    action="action_travel_room_form1" parent="menu_travel_room_form"/>
    <record model="ir.actions.act_window" id="action_travel_room_form2">
    <field name="name">Double Rooms</field>
    <field name="res_model">travel.room</field>
    <field name="domain">[('beds','=',2)]</field>
    <field name="view_mode">tree,form</field>
    </record>
    <menuitem name="Double rooms"
    id="menu_travel_room_form2"
    action="action_travel_room_form2" parent="menu_travel_room_form"/>
    </data>
    </openerp>
    [/code]

    然后 安装 该模块时. 出现错误.
    [code]
    Traceback (most recent call last):
    File "netsvc.pyo", line 231, in dispatch
    File "netsvc.pyo", line 74, in call
    File "serviceweb_services.pyo", line 537, in execute
    File "serviceweb_services.pyo", line 517, in execute
    File "wizard__init
    _.pyo", line 178, in execute
    File "wizard__init__.pyo", line 74, in execute_cr
    File "C:Program FilesOpenERP AllInOneServeraddonsbasemodulewizardwizard_module_upgrade.py", line 92, in upgrade_module
    File "pooler.pyo", line 61, in restart_pool
    File "pooler.pyo", line 40, in get_db_and_pool
    File "addons__init
    _.pyo", line 704, in load_modules
    File "addons__init__.pyo", line 605, in load_module_graph
    File "toolsconvert.pyo", line 881, in convert_xml_import
    File "toolsconvert.pyo", line 775, in parse
    File "toolsconvert.pyo", line 573, in _tag_menuitem
    File "toolsconvert.pyo", line 756, in id_get
    File "toolsmisc.pyo", line 640, in cached_result
    File "C:Program FilesOpenERP AllInOneServeraddonsbaseirir_model.py", line 416, in _get_id
    IndexError: list index out of range

    [/code]
    问下怎么解决? 谢谢大家.


  • 管理员

    把__terp__.py中的update_xml的值换成“traval_view.xml”

    [[i] 本帖最后由 digitalsatori 于 2009-3-24 21:42 编辑 [/i]]



  • 谢谢  [color=#666666][size=99px][color=#666666][size=99px]

    [color=#666666][size=99px]
    [color=#666666][size=99px]



  • 官方怎么没有一个比较完整的 模块呢? 好奇怪.


  • 管理员

    没仔细看你贴出来的代码,你的custom.py中少了好多类定义啊
    [code]from osv import osv, fields

    class travel_hostel(osv.osv):
    _name = 'travel.hostel'
    _inherit = 'res.partner'
    _table = 'res_partner'
    _columns = {
    'rooms_id': fields.one2many('travel.room', 'hostel_id', 'Rooms'),
    'quality': fields.char('Quality', size=16),
    }
    travel_hostel()

    class travel_airport(osv.osv):
    _name = 'travel.airport'
    _columns = {
    'name': fields.char('Airport name', size=16),
    'city': fields.char('City', size=16),
    'country': fields.many2one('res.country', 'Country')
    }
    travel_airport()

    class travel_room(osv.osv):
    _name = 'travel.room'
    _inherit = 'product.product'
    _table = 'product_product'
    _columns = {
    'beds': fields.integer('Nbr of Beds'),
    'view': fields.selection([('sea','Sea'),('street','Street')], 'Room View'),
    'hostel_id': fields.many2one('travel.hostel', 'Hostel'),
    }
    travel_room()
    class travel_flight(osv.osv):
    _name = 'travel.flight'
    _inherit = 'product.product'
    _table = 'product_product'
    _columns = {
    'partner_id': fields.many2one('res.partner', 'PArtner'),
    'date': fields.datetime('Departure Date'),
    'airport_from': fields.many2one('travel.airport', 'Airport Departure'),
    'airport_to': fields.many2one('travel.airport', 'Airport Arrival'),
    }
    travel_flight()[/code]

    以上是完整的例子,目前你至少要定义travel_hostel和travel_room这两个类。
    仔细看开发文档中是怎么说的,文档中说按照travel_hostel的类定义方法去定义其他需要的类。

    [code]bzr clone lp:~openerp/openobject-addons/trunk addons
    bzr clone lp:~openerp-commiter/openobject-addons/trunk-extra-addons extra-addons[/code]
    可以获取开发中所有模块



  • addons-extra 仓库里有可以运行的 travel



  • 我的模块内容 在上面都贴出来了.

    custom.py 的内容换为你提供的内容后, 安装后还是提示

    Object Error
    Object travel.room doesn't exist


  • 管理员

    停止openerp服务器,用以下命令重启服务器:
    [code]openerp-server.py --update=travel[/code]


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待