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.