Hello,
I'm trying to pass values and show the records from the form view of model_b.py into one2many field notebook in the form view of model_a.py by wizard.
model_b.py like this:
def accept(self):
lstd = {
'name': self.name.id,
'thamchieu': self.id,
'thoigian': self.thoigian,
'bhxh': self.bhxh,
'bhtn': self.bhtn,
'bhxh_mucdongnld': self.bhxh_mucdongnld,
'bhxh_mucdongcty': self.bhxh_mucdongcty,
'bhtn_mucdongnld': self.bhtn_mucdongnld,
'bhtn_mucdongcty': self.bhtn_mucdongcty,
'bhyt_mucdongnld': self.bhyt_mucdongnld,
'bhyt_mucdongcty': self.bhyt_mucdongcty
}
ls_dc = self.env['model.a']
ls_dc = ls_dc.write({'lstd_baohiem':[(0,0,{lstd})]})
XML of one2many tree view in the form view of an user's model_a.py like this:
<notebook>
<page name="bao_hiem_lich_su" string="Lịch Sử Thay Đổi">
<field name="lstd_baohiem">
<tree>
<field name="thoigian"/>
<field name="bhxh" string="M.Đ BHXH"/>
<field name="bhtn" string="M.Đ BHTN"/>
<field name="bhxh_mucdongnld"/>
<field name="bhxh_mucdongcty"/>
<field name="bhyt_mucdongnld"/>
<field name="bhyt_mucdongcty"/>
<field name="bhtn_mucdongnld"/>
<field name="bhtn_mucdongcty"/>
<field name="loai"/>
<field name="thamchieu"/>
</tree>
</field>
</page>
</notebook>
After clicking the button 'Accept'. I got the issue like that:
Odoo Server Error
Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/http.py", line 624, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/odoo/src/odoo/odoo/http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/home/odoo/src/odoo/odoo/tools/pycompat.py", line 14, in reraise raise value File "/home/odoo/src/odoo/odoo/http.py", line 669, in dispatch result = self._call_function(**self.params) File "/home/odoo/src/odoo/odoo/http.py", line 350, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper return f(dbname, *args, **kwargs) File "/home/odoo/src/odoo/odoo/http.py", line 339, in checked_call result = self.endpoint(*a, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 915, in __call__ return self.method(*args, **kw) File "/home/odoo/src/odoo/odoo/http.py", line 515, in response_wrap response = f(*args, **kw) File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1331, in call_button action = self._call_kw(model, method, args, kwargs) File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1319, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/odoo/src/odoo/odoo/api.py", line 387, in call_kw result = _call_kw_multi(method, model, args, kwargs) File "/home/odoo/src/odoo/odoo/api.py", line 374, in _call_kw_multi result = method(recs, *args, **kwargs) File "/home/odoo/src/odoo/addons/baohiem/models/dieu_chinh.py", line 128, in chapthuan ls_dc = ls_dc.write({'lstd_baohiem':[(0,0,{lstd})]}) TypeError: unhashable type: 'dict'
What am I doing wrong?
Please help!
Thank you!