From 4b70c571214a67b155801e88007dd1163ecd7e9b Mon Sep 17 00:00:00 2001 From: Diego Paradeda Date: Thu, 14 Nov 2024 13:27:34 -0300 Subject: [PATCH] [FIX] l10n_br_fiscal: operation copy --- l10n_br_fiscal/models/operation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/l10n_br_fiscal/models/operation.py b/l10n_br_fiscal/models/operation.py index afff7df9249b..94e859df43c7 100644 --- a/l10n_br_fiscal/models/operation.py +++ b/l10n_br_fiscal/models/operation.py @@ -268,3 +268,17 @@ def score(line): def _onchange_operation_subsequent_ids(self): for sub_operation in self.operation_subsequent_ids: sub_operation.fiscal_operation_id = self.id + + def copy(self, default=None): + """ + Inherit copy to edit field code. This is needed because the field is + Unique and Required. + """ + self.ensure_one() + if default is None: + default = {} + if self.code: + default["code"] = self.code + _(" (Copy)") + + res = super().copy(default) + return res