Odoo Help

0

Why is my one2many field not showing in form view?

By
Anna
on 9/7/14, 11:58 PM 1,931 views

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"/>

0
deep
On 9/8/14, 3:49 AM

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

About This Community

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

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 9/7/14, 11:58 PM
Seen: 1931 times
Last updated: 3/16/15, 8:10 AM