-
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.
pattern_import_export: fix o2m purge option
- Loading branch information
1 parent
e896fd6
commit fbd53ad
Showing
5 changed files
with
102 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
from . import pattern_file | ||
from . import pattern_chunk | ||
from . import ir_attachment | ||
from . import fields |
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,22 @@ | ||
# Copyright 2023 Akretion (https://www.akretion.com). | ||
# @author Sébastien BEAU <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from odoo import fields | ||
|
||
ori_write_real = fields.One2many.write_real | ||
|
||
|
||
def write_real(self, records_commands_list, create=False): | ||
if not create: | ||
for recs, commands in records_commands_list: | ||
if recs.env.context.get("pattern_config", {}).get("purge_one2many"): | ||
update_ids = [cmd[1] for cmd in commands if cmd[0] == 1] | ||
for item in recs[self.name]: | ||
if item.id not in update_ids: | ||
commands.append((3, item.id, 0)) | ||
return ori_write_real(self, records_commands_list, create=create) | ||
|
||
|
||
fields.One2many.write_real = write_real |
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