Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions server_action_mass_edit/wizard/mass_editing_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,52 @@

return res

def onchange(self, values, field_names, fields_spec):
first_call = not field_names

Check warning on line 73 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L73

Added line #L73 was not covered by tests
if first_call:
field_names = [fname for fname in values if fname != "id"]
missing_names = [fname for fname in fields_spec if fname not in values]
defaults = self.default_get(missing_names)

Check warning on line 77 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L75-L77

Added lines #L75 - L77 were not covered by tests
for field_name in missing_names:
values[field_name] = defaults.get(field_name, False)

Check warning on line 79 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L79

Added line #L79 was not covered by tests
if field_name in defaults:
field_names.append(field_name)

Check warning on line 81 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L81

Added line #L81 was not covered by tests

server_action_id = self.env.context.get("server_action_id")
server_action = self.env["ir.actions.server"].sudo().browse(server_action_id)

Check warning on line 84 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L83-L84

Added lines #L83 - L84 were not covered by tests
if not server_action:
return super().onchange(values, field_names, fields_spec)
dynamic_fields = {}

Check warning on line 87 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L86-L87

Added lines #L86 - L87 were not covered by tests

for line in server_action.mapped("mass_edit_line_ids"):
values["selection__" + line.field_id.name] = "ignore"
values[line.field_id.name] = False

Check warning on line 91 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L90-L91

Added lines #L90 - L91 were not covered by tests

dynamic_fields["selection__" + line.field_id.name] = fields.Selection(

Check warning on line 93 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L93

Added line #L93 was not covered by tests
[('ignore', _("Don't touch"))], default="ignore"
)
dynamic_fields[line.field_id.name] = fields.Text([()], default=False)

Check warning on line 96 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L96

Added line #L96 was not covered by tests

self._fields.update(dynamic_fields)

Check warning on line 98 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L98

Added line #L98 was not covered by tests

res = super().onchange(values, field_names, fields_spec)

Check warning on line 100 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L100

Added line #L100 was not covered by tests
if not res["value"]:
value = {key: value for key, value in values.items() if value is not False}
res["value"] = value

Check warning on line 103 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L102-L103

Added lines #L102 - L103 were not covered by tests

for field in dynamic_fields:
self._fields.pop(field)

Check warning on line 106 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L106

Added line #L106 was not covered by tests

view_temp = (

Check warning on line 108 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L108

Added line #L108 was not covered by tests
self.env["ir.ui.view"]
.sudo()
.search([("name", "=", "Temporary Mass Editing Wizard")], limit=1)
)
if view_temp:
view_temp.unlink()

Check warning on line 114 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L114

Added line #L114 was not covered by tests

return res

Check warning on line 116 in server_action_mass_edit/wizard/mass_editing_wizard.py

View check run for this annotation

Codecov / codecov/patch

server_action_mass_edit/wizard/mass_editing_wizard.py#L116

Added line #L116 was not covered by tests

@api.model
def _prepare_fields(self, line, field, field_info):
result = {}
Expand Down
Loading