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 my page loads forever when changing value of custom field in supplier form ?

By
PY
on 12/2/13, 9:44 AM 1,089 views

Hi !

I'm creating a module called shipping. I created a custom field in res.partner to link the supplier with a specific shipping rule (a custom object, containing a name and an ID for now).

I've learned how to display the shipping "name" field in the res.partner form by linking, in fact, the ID. But since tha, my page just load forever when I want to change the value (in the web client).

What can causes that, and how to fix this ?

Here's my code :

shipping.py

class shipping_rule(osv.osv):
    _name = 'shipping_rule'
    _order = 'name asc'

    _columns = {
        'id': fields.one2many('res.partner', 'shipping_rule_id', required=True),
        'name': fields.char('Rule name', size=128, required=True)
    }

    _sql_constraints = [
        ('uniq_name', 'unique(name)', "A shipping rule already exists with this name. Shipping rule's name must be unique!"),
    ]


class inherit_res_partner_for_shipping_rule(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'

    _columns = {
        'shipping_rule_id': fields.many2one('shipping_rule', 'Shipping rule')
    }

shipping_partner_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>   
        <!-- form -->
        <record model="ir.ui.view" id="shipping_res_partner_form">
            <field name="name">view.inherit.res.partner.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                <field name="website" position="after">
                    <field name="shipping_rule_id" />
                </field>
            </field>
        </record>
    </data>
</openerp>
1

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 12/2/13, 10:09 AM

You don't have to create ID field. if you want to link it with res_partner you have to use another column to do it. For example: partner_id

class shipping_rule(osv.osv):
_name = 'shipping_rule'
_order = 'name asc'

_columns = {
    'partner_id': fields.one2many('res.partner', 'shipping_rule_id', required=True),
    'name': fields.char('Rule name', size=128, required=True)
}

_sql_constraints = [
    ('uniq_name', 'unique(name)', "A shipping rule already exists with this name. Shipping rule's name must be unique!"),
]

Thanks ! I updated my code as you suggested, and after uninstall/reinstall, that worked fine. Thanks again !

PY
on 12/2/13, 10:27 AM

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/2/13, 9:44 AM
Seen: 1089 times
Last updated: 3/16/15, 8:10 AM