Navigation Menu

Skip to content

Commit

Permalink
🚑 model_record vanishing on the form saving (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
KolushovAlexandr authored and Ivan Yelizariev committed Sep 21, 2018
1 parent e2976e5 commit d8b3a7f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base_details/__manifest__.py
Expand Up @@ -8,7 +8,7 @@
"summary": """Allows to add reference in any models""",
"category": "Hidden",
"images": ["static/description/icon.png"],
"version": "11.0.1.0.1",
"version": "11.0.1.0.2",
"application": False,

"author": "IT-Projects LLC, Ivan Yelizariev",
Expand Down
6 changes: 6 additions & 0 deletions base_details/doc/changelog.rst
@@ -1,3 +1,9 @@
`1.0.2`
------

- **FIX** Vanishing of the record field on form saving
- **NEW** Default value for the record field is set automatically

`1.0.1`
------

Expand Down
4 changes: 3 additions & 1 deletion base_details/models/base_details.py
Expand Up @@ -29,7 +29,7 @@ def details(self):
details_record = None
return details_record

details_model = fields.Selection(selection="_model_selection", string='Model', store=True)
details_model = fields.Selection(selection="_model_selection", string='Model')
details_model_record = fields.Reference(selection="_details_model_record_selection", string='Record')
details_model_exists = fields.Boolean(compute="_compute_existence", string='Details Model Exists', store=True)
details_res_id = fields.Integer(compute="_compute_res_id", string='Record', store=True)
Expand All @@ -42,8 +42,10 @@ def onchange_details_model(self):
self.details_model_record = self.env[self.details_model].search([], limit=1)
else:
self.details_model_exists = False
self.details_model_record = False

@api.multi
@api.depends('details_model')
def _compute_existence(self):
for rec in self:
if rec.details_model and rec.details_model in [x.model for x in rec.env['ir.model'].search([])]:
Expand Down

0 comments on commit d8b3a7f

Please sign in to comment.