I have 2 models which are related with Many2Many.
When I create Model Halle, I want to automatically create 1 Model Block with it. This is my current attempt
@api.model
def create(self, values):
vals = {
'halle_id': values['id'],
}
record = self.env['rectanglemaps.block'].create(vals)
values['block_ids'] = [(4, record.id)]
return super(Halle, self).create(values)
I also tried this
@api.model
def create(self, values):
vals = {
'halle_id': self.id,
}
record = self.env['rectanglemaps.block'].create(vals)
values['block_ids'] = [(4, record.id)]
return super(Halle, self).create(values)
With my current attempt I get this error:
Traceback (most recent call last): File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch result = request.dispatch() File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/http.py", line 687, in dispatch result = self._call_function(**self.params) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/http.py", line 359, in _call_function return checked_call(self.db, *args, **kwargs) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/http.py", line 348, in checked_call result = self.endpoint(*a, **kw) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/http.py", line 916, in __call__ return self.method(*args, **kw) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/http.py", line 535, in response_wrap response = f(*args, **kw) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/addons/web/controllers/main.py", line 1347, in call_kw return self._call_kw(model, method, args, kwargs) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/addons/web/controllers/main.py", line 1339, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/api.py", line 462, in call_kw result = _call_kw_model_create(method, model, args, kwargs) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/api.py", line 442, in _call_kw_model_create result = method(recs, *args, **kwargs) File "", line 2, in create File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/odoo/api.py", line 391, in _model_create_single return create(self, arg) File "/Users/jgs/jgs/Coding/Projects/odoo15/odoo/addons/rectanglemaps/models/halle.py", line 85, in create 'halle_id': values['id'], Exception
What am i doing wrong?