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

Why is my one2many field not showing in form view?

By
Anna
on 9/7/14, 11:58 PM 1,470 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

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

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

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

1 follower(s)

Stats

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