Skip to content

Commit

Permalink
[imp] add model_create_multi to create method
Browse files Browse the repository at this point in the history
  • Loading branch information
is-ife committed Nov 4, 2024
1 parent 0c56bb4 commit a532290
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions maintenance_equipment_sequence/models/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ def _inverse_seq_number_next(self):
sequence = category.sequence_id._get_current_sequence()
sequence.sudo().number_next = category.sequence_number_next

@api.model
def create(self, vals):
if not vals.get("sequence_id", False):
if vals.get("sequence_prefix", False):
vals["sequence_id"] = self.sudo()._create_sequence(vals).id
else:
vals["sequence_prefix"] = (
self.env["ir.sequence"].browse(vals["sequence_id"]).prefix
)
result = super(MaintenanceEquipmentCategory, self).create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if not vals.get("sequence_id", False):
if vals.get("sequence_prefix", False):
vals["sequence_id"] = self.sudo()._create_sequence(vals).id
else:
vals["sequence_prefix"] = (

Check warning on line 73 in maintenance_equipment_sequence/models/maintenance.py

View check run for this annotation

Codecov / codecov/patch

maintenance_equipment_sequence/models/maintenance.py#L73

Added line #L73 was not covered by tests
self.env["ir.sequence"].browse(vals["sequence_id"]).prefix
)
result = super().create(vals_list)
self._compute_equipment_code()
return result

Expand Down

0 comments on commit a532290

Please sign in to comment.