Skip to content

Commit

Permalink
[IMP] base_import_pdf_by_template: Add json field compatibility
Browse files Browse the repository at this point in the history
TT50003
  • Loading branch information
victoralmau committed Dec 3, 2024
1 parent ce64521 commit 7b551ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json
import re
from datetime import datetime

Expand Down Expand Up @@ -342,6 +343,7 @@ def _get_fixed_field_name_ttype_mapped(self):
"integer": "fixed_value_integer",
"selection": "fixed_value_selection",
"text": "fixed_value_text",
"json": "fixed_value_text",
"many2one": "fixed_value",
}

Expand All @@ -351,6 +353,8 @@ def _get_fixed_value(self):
f_value = self[f_name]
if self.field_ttype == "selection":
f_value = f_value.value
elif self.field_ttype == "json":
f_value = json.loads(f_value)
return f_value

def _replace_text(self, text, letters, prefix):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<field
name="fixed_value_text"
string="Fixed value"
invisible="value_type != 'fixed' or field_ttype != 'text'"
invisible="value_type != 'fixed' or field_ttype not in ('text', 'json')"
/>
<field
name="fixed_value"
Expand Down

0 comments on commit 7b551ce

Please sign in to comment.