Skip to Content
Menu
This question has been flagged
3585 Views

I want to test an example from odoo develepoers cookbook. The example is about creating records. I use odoo 8.

The code is here:

# coding: utf-8

from openerp import models, api, fields


class SomeModel(models.Model):
_name = 'some.model'

@api.multi
def create_company(self):
today_str = fields.Date.contex_today()
val1 = {'name': u'Eric Idel',
'email': u'eric.idle@example.com',
'date': today_str,
}
val2 = {'name': u'John Cleese',
'email': u'john.cleese@example.com',
'date': today_str,
}
company_val = {'name': u'Flying Circus',
'email': u'm.python@example.com',
'date': today_str,
'is_company': True,
'child_ids': [(0, 0, val1),
(0, 0, val2),
],
}
record = self.env['res.company'].create(company_val)
return record

My rpc calls are the following:

import odoorpc
odoo = odoorpc.ODOO('localhost', port=8070)
odoo.login('db_name', 'user', 'pass')
Somemodel = odoo.env('some.model')
Somemodel.create_company()

after this I get the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-53eb2c5ffeaa> in <module>()
----> 1 Somemodel.create_company()

AttributeError: 'Environment' object has no attribute 'create_company'

What's wrong here? I can call more complex model's methods.

Avatar
Discard
Related Posts Replies Views Activity
0
Feb 24
371
1
Feb 24
574
2
Oct 23
643
2
Nov 24
1952
0
Feb 23
1046