Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] base_import_pdf_by_template: Improve the import process to account for fixed values #1033

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading