Skip to content
Snippets Groups Projects

Refactor 'force_code_id' logic to handle context key and return force_code

Merged oury.balde requested to merge topic/16.0/TG-228 into branch/16.0
3 files
+ 16
6
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 10
5
@@ -502,9 +502,11 @@
# Direct changes to the 'bound analytic code' field are ignored
# unless the 'force_code_id' context key is passed as True.
force_code_id = vals.pop(column, False)
if self.env.context.get("force_code_id"):
self._force_code(force_code_id, code_vals)
force_code_id = vals.pop(column, False) or self.env.context.get(
"force_code_id"
)
if force_code_id:
new_code = self._force_code(force_code_id, code_vals)
vals[column] = force_code_id
else:
@@ -577,8 +579,10 @@
# Direct changes to the 'bound analytic code' field are ignored
# unless the 'force_code_id' context key is passed as True.
force_code_id = vals.pop(column, False)
if self.env.context.get("force_code_id"):
force_code_id = vals.pop(column, False) or self.env.context.get(
"force_code_id"
)
if force_code_id:
self._force_code(force_code_id, code_vals)
vals[column] = force_code_id
@@ -677,6 +681,7 @@
if code_vals:
# These are behind-the-scenes links so bypass security rules.
force_code.sudo().write(code_vals)
return force_code
if sync_parent:
# This function is called as a method and can be overridden.
Loading