跳至内容
菜单
此问题已终结
3519 查看

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?

形象
丢弃
编写者

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.

相关帖文 回复 查看 活动
1
8月 25
4989
0
12月 24
9996
3
9月 24
22347
5
12月 24
53979
4
7月 24
11169