-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][IMP] add default_value for import and export
- Loading branch information
1 parent
e896fd6
commit f228775
Showing
6 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from . import pattern_config | ||
from . import base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (C) 2023 Akretion (<http://www.akretion.com>). | ||
# @author Chafique Delli <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class Base(models.AbstractModel): | ||
_inherit = "base" | ||
|
||
def _pattern_format2json(self, row): | ||
pattern_config_ctx = self._context.get("pattern_config") | ||
if pattern_config_ctx: | ||
pattern_file = pattern_config_ctx.get("pattern_file") | ||
pattern_config = pattern_file.pattern_config_id | ||
new_row = {} | ||
for custom_header in pattern_config.custom_header_ids: | ||
value = "" | ||
if custom_header.custom_name and custom_header.custom_name in row: | ||
value = row[custom_header.custom_name] | ||
elif ( | ||
custom_header.initial_header_name | ||
and custom_header.initial_header_name in row | ||
): | ||
value = row[custom_header.initial_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 | ||
row = new_row | ||
return super()._pattern_format2json(row=row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters