Skip to content
Snippets Groups Projects
Commit 120224ee69e0 authored by Etienne Ferriere's avatar Etienne Ferriere
Browse files

Corrected a bug in the 'write' method override. Sometimes, the field, giving the

created analytic code name, is not immediately filled in the first write
processes, and only filled afterwards.
parent 366e2faa25e7
No related branches found
No related tags found
No related merge requests found
......@@ -575,7 +575,8 @@
context = self.env.context
code_vals = {}
new = False
news = []
standard_process = False
if sync_parent:
cp = self._get_code_parent(vals)
......@@ -607,7 +608,7 @@
code_vals['name'] = vals[name_col]
if description_col in vals:
code_vals['description'] = vals[description_col]
codes = {rec: getattr(rec, column) for rec in self}
standard_process = True
res = super(superclass, self).write(vals, **kwargs)
......@@ -611,6 +612,4 @@
res = super(superclass, self).write(vals, **kwargs)
news = []
# If updating records with no code, create these.
......@@ -616,4 +615,4 @@
# If updating records with no code, create these.
if codes:
if standard_process:
code_obj = self.env['analytic.code']
......@@ -618,7 +617,9 @@
code_obj = self.env['analytic.code']
for rec, code in codes.iteritems():
for rec in self:
code = getattr(rec, column)
rec_code_vals = code_vals.copy()
rec_vals = dict().copy()
......@@ -621,7 +622,7 @@
rec_code_vals = code_vals.copy()
rec_vals = dict().copy()
if 'name' not in rec_code_vals:
if not rec_code_vals.get('name'):
rec_code_vals['name'] = \
rec.read([name_col])[0][name_col]
......@@ -626,8 +627,8 @@
rec_code_vals['name'] = \
rec.read([name_col])[0][name_col]
if 'description' not in code_vals:
if not rec_code_vals.get('description'):
rec_code_vals['description'] = (
self.read([description_col])[0]
[description_col]
)
......@@ -629,9 +630,9 @@
rec_code_vals['description'] = (
self.read([description_col])[0]
[description_col]
)
if not code and not getattr(rec, column):
if not code and rec_code_vals.get('name'):
news.append(rec.id)
rec_code_vals['nd_id'] = rec._get_bound_dimension_id()
rec_code_vals['origin_id'] = \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment