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

[14.0][IMP] add default_value for import and export #114

Open
wants to merge 2 commits into
base: 14.0
Choose a base branch
from

Conversation

chafique-delli
Copy link
Contributor

@chafique-delli chafique-delli commented Feb 6, 2023

@chafique-delli chafique-delli force-pushed the 14.0-imp-pattern_import_export_custom_header branch 2 times, most recently from bc4a28c to f228775 Compare February 7, 2023 11:11
@chafique-delli
Copy link
Contributor Author

ping @sebastienbeau

@chafique-delli chafique-delli force-pushed the 14.0-imp-pattern_import_export_custom_header branch from f228775 to d4326da Compare February 7, 2023 16:35
_inherit = "base"

def _pattern_format2json(self, row):
pattern_config_ctx = self._context.get("pattern_config")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config = self._context["pattern_config"]["pattern_file"].pattern_config_id

Comment on lines 17 to 23
for custom_header in pattern_config.custom_header_ids:
value = ""
if custom_header.name in row:
value = row[custom_header.name]
if not value and custom_header.import_default_value:
value = custom_header.import_default_value
new_row[custom_header.initial_header_name] = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for custom_header in pattern_config.custom_header_ids:
value = ""
if custom_header.name in row:
value = row[custom_header.name]
if not value and custom_header.import_default_value:
value = custom_header.import_default_value
new_row[custom_header.initial_header_name] = value
new_row = {
header.initial_header_name: row.get(header.name) or header.import_default_value
for header in custom_header_ids
}
if new_row:
row = new_row

@chafique-delli chafique-delli force-pushed the 14.0-imp-pattern_import_export_custom_header branch from d4326da to ae76975 Compare February 17, 2023 11:06
@chafique-delli chafique-delli force-pushed the 14.0-imp-pattern_import_export_custom_header branch from 4baccd8 to 515c654 Compare December 22, 2023 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants