コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5526 ビュー

Hi, i am creating a module which has a model with a one2many relation. There was no error installing, but when i hit the create button to go to form view, i only get the name button for input, show's nothing to take input for one2many field.

I am not quite sure of how the one2many field works in xml, so if anyone can help me continue  i would really appreciate it

Here is my .py definition:

class account_invoice(osv.osv):
    _name = 'account.invoice'
    _inherit = 'account.invoice'
    _columns = {
        'route_id' : fields.many2one('best.route', 'Ruta', readonly=False, required=True, ondelete='cascade',change_default=True, select=True,
            track_visibility='always'),
        'has_route' : fields.boolean('Tiene Ruta Asignada', readonly=True)
    }
    _defaults = {
        'has_route' : False
    }
account_invoice()

class fleet_vehicle(osv.osv):
    _name = 'fleet.vehicle'
    _inherit = 'fleet.vehicle'
    _columns = {
        'route_id' : fields.many2one('best.route', 'Ruta', readonly=False, required=True, ondelete='cascade',change_default=True, select=True,
            track_visibility='always')
    }
fleet_vehicle()

class best_route(osv.osv):
    _name = 'best.route'
    _columns = {
        'name': fields.char('Nombre', required=True, size=100),
        'invoices' : fields.one2many('account.invoice', 'route_id', 'Facturas', readonly=False, required=True, select=True),
        'fleets' : fields.one2many('fleet.vehicle', 'route_id', 'Flotas', readonly=False, required=True, select=True)
    }
best_route()

Here is my xml code to show the view:

        <record id="view_best_rutas_tree" model="ir.ui.view">
                    <field name="name">best.route</field>
                    <field name="model">best.route</field>
                    <field name="priority">1</field>
                    <field name="arch" type="xml">
                        <tree string="Mejores Rutas">
                            <field name="id" string="Id"/>
                            <field name="name" string="Nombre"/>
                            <field name="invoices" string="Facturas para Enviar" widget="one2many" domain="[('has_route','=',False)]" colspan="4" nolabel="1">
                                <tree editable='bottom'>
                                    <field name="name"/>                          
                                </tree>

                                <form>
                                    <field name="id"/>
                                    <field name="name"/>
                                </form>
                            </field>
                        </tree>
                    </field>
        </record>

        <record model="ir.actions.act_window" id="action_tree_rutas">

                    <field name="name">Mejores Rutas</field>

                    <field name="res_model">best.route</field>
                    
                    <field name="view_id" ref="view_best_rutas_tree"/>

                    <field name="view_type">form</field>

                    <field name="view_mode">tree,form</field>

        </record>

        <menuitem id="main_menu_ruta" name="Rutas"/>
            <menuitem id="Rutas" parent="main_menu_ruta" name="Rutas"/>
            <menuitem id="Destinos" parent="Rutas" action="action_tree_destination" name="Destinos" sequence="1"/>
            <menuitem id="Mejores Rutas" parent="Rutas" action="action_tree_rutas" name="Mejores Rutas" sequence="2"/>

アバター
破棄
最善の回答

you have defined only tree view and not form view for object "best.route"

So either add form view or make your tree view as editable by setting editable property

アバター
破棄
関連投稿 返信 ビュー 活動
1
5月 19
9169
1
8月 15
4293
1
4月 20
2845
2
1月 24
16214
1
7月 15
4504