-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[15.0][IMP] excel_import_export: allow selection of all related templates for export action #3095
base: 15.0
Are you sure you want to change the base?
Conversation
is_display = fields.Boolean( | ||
help="Technical field to control template visibility in server actions." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is_available
may make a better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, we can actually remove this field. Just adjust template_domain
of the export action context to use export_action_id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer second option to avoid adding new field.
@@ -431,29 +434,51 @@ def _compute_output_instruction(self): | |||
|
|||
def add_export_action(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method can be restructured in the following manner for better readability:
def add_export_action(self):
self.ensure_one()
model = self.env["ir.model"].search([("model", "=", self.res_model)], limit=1)
export_action = self._get_export_action(model)
if not export_action:
export_action = self._create_export_action(model)
self.export_action_id = export_action
self.is_available = True
} | ||
action = self.env["ir.actions.act_window"].create(vals) | ||
self.export_action_id = action | ||
self.is_display = True | ||
|
||
def remove_export_action(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be a bit more concise:
def remove_export_action(self):
self.ensure_one()
self.is_available = False
if not self.search(
[("res_model", "=", self.res_model), ("is_available", "=", True)]
):
self.export_action_id.unlink()
self.export_action_id = False
Hi @kittiu, |
123fa64
to
7627479
Compare
if not self.search( | ||
[ | ||
("res_model", "=", self.res_model), | ||
("export_action_id", "!=", False), | ||
("id", "!=", self.id), | ||
] | ||
): | ||
self.export_action_id.unlink() | ||
self.export_action_id = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition ("export_action_id", "!=", False)
is probably not optimal, considering there could be cases where multiple export actions exist for a model.
if not self.search( | |
[ | |
("res_model", "=", self.res_model), | |
("export_action_id", "!=", False), | |
("id", "!=", self.id), | |
] | |
): | |
self.export_action_id.unlink() | |
self.export_action_id = False | |
export_action = self.export_action_id | |
self.export_action_id = False | |
if not self.search( | |
[("res_model", "=", self.res_model), ("export_action_id", "=", export_action.id)] | |
): | |
export_action.unlink() |
…l related templates for export action Before this commit, when two templates exist for the same model, clicking "ADD EXPORT ACTION" for each template creates separate server actions for each. As a result, if multiple templates are created for the same model, numerous server actions with the label "Export Excel" will accumulate for that model. With this commit, if two templates exist for the same model and "ADD EXPORT ACTION" is clicked for each, they will now share a single server action. Users can then select templates from within the "Export Excel" wizard. Clicking "REMOVE EXPORT ACTION" on a template will remove only that template from the "Export Excel" selection. The server action itself will be deleted only when no templates use it for export.
7627479
to
d0ba381
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review.
Before this PR, when two templates exist for the same model, clicking
ADD EXPORT ACTION
for each templatecreates separate server actions for each. As a result, if multiple templates are created for the same model,
numerous server actions with the label
Export Excel
will accumulate for that model.With this PR, if two templates exist for the same model and
ADD EXPORT ACTION
is clicked for each,they will now share a single server action. Users can then select templates from within the
Export Excel
wizard.Clicking
REMOVE EXPORT ACTION
on a template will remove only that template from theExport Excel
selection.The server action itself will be deleted only when no templates use it for export.
@qrtl QT4815