This question has been flagged
2804 Views

I have a table that looks like this:

class fnx_sr_shipping(osv.Model):
    _name = 'fnx.sr.shipping'
    _description = 'shipping & receiving entries'
    _inherits = {
       'res.partner': 'partner_id',
       }
    _order = 'appointment_date desc, appointment_time asc'

    _columns = {

       .
       .
       .
       'partner_id': fields.many2one(
            'res.partner',
            'Partner',
            required=True,
            ondelete='restrict'),
       .
       .
       .

The required=True is required by OpenERP (if it's not there, OE adds it).

When I use the web interface I am able to create a new shipping record and pick existing partners; however, if I try the same thing using XML-RPC (supplying the partner_ids in the shipping record create call) OpenERP tries to create a new record in res.partner using default settings, which of course fails because some required fields have no default (such as the name).

Here's the XML-RPC code I'm using:

import openerplib
OE = PropertyDict()          # allows attribute-style access for keys
OE.conn = openerplib.get_connection(
        hostname='xxx',
        database='yyy',
        login='zzz',
        password='...'
OE.res_partner = conn.get_model('res.partner')
.
.
.
values['partner_id'] = 77     # or whatever it actually is ;)
OE.fnx_shipping.create(values)

I have verified that the ids being passed are correct.

Is this a bug in my code, or in OpenERP?

Avatar
Discard
Author

In case anyone is curious, I worked around the problem by removing the _inherits and using functional fields to get the res.partner fields I was interested in.