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

How to display a one2many field as a one2many_list properly ?

By
PY
on 12/19/13, 12:00 PM 1,145 views

Hi !

I've an object called shipping_rule, with the following definition :

class shipping_rule(osv.osv):
    _name = 'shipping_rule'

    _columns = {
        'name': fields.char('Rule name', size=128, required=True),
        'rule_priority': fields.integer('Priority', required=True),
        'partner_id': fields.many2one('res.partner', 'Company', required=True),
        'cost': fields.float('Shipping cost', required=True)
    }

Now, I've inherited res.partner like this :

class res_partner(osv.osv):
    _inherit = 'res.partner'

    _columns = {
        'shipping_rules_list': fields.one2many('shipping_rule', 'partner_id', 'Shipping rules')
    }

Finally, I've tried to display a list of shipping rules related to the partner:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="shipping_partner">
            <field name="name">res.partner.form.shipping</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Shipping rules">
                        <field name="shipping_rules_list" colspan="4" nolabel="1" widget="one2many_list" mode="tree" >
                            <tree>
                                <field name="name" />
                                <field name="cost" />
                                <field name="rule_priority" />
                            </tree>
                        </field>
                    </page>
                </notebook>
            </field>
        </record>
    </data>
</openerp>

But, I always get an XML invalid architecture :/

I don't want the list to be editable for now, just display the tree.

Thanks for your help !

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: 12/19/13, 12:00 PM
Seen: 1145 times
Last updated: 3/16/15, 8:10 AM