Skip to content

Commit

Permalink
Merge PR #1033 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 9, 2024
2 parents dde1dd8 + 10e5c1b commit f01bc32
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def _process_set_value_form(self, _form, field_name, value):

def _process_form(self):
"""Create record with Form() according to text."""
# text = "".join(data)
text = self.data
template = self.template_id
model = self.env[template.model]
Expand Down Expand Up @@ -202,7 +201,15 @@ def _process_form(self):
model_name=template.child_model, related_model="lines"
)._process_set_value_form(line_form, field_name, line[field_name])
try:
record = model_form.save()
# Prepare vals (similar to .save()) + apply defaults (in case it has changed
# in some onchange for example: warehouse_id from sale orders)
vals = model_form._values_to_save()
for key in ctx:
if key.startswith("default_"):
field = key.replace("default_", "")
if field in vals:
vals.update({field: ctx[key]})
record = model.with_context(**ctx).create(vals)
except (AssertionError) as err:
raise UserError(err) from err
if self.log_text:
Expand Down

0 comments on commit f01bc32

Please sign in to comment.