Skip to content

[FIX] maintenance_equipment_sequence: convert create to api.model_create_multi#564

Open
miquelrosell99 wants to merge 1 commit into
OCA:17.0from
miquelrosell99:17.0-fix-maintenance-equipment-sequence-model-create-multi
Open

[FIX] maintenance_equipment_sequence: convert create to api.model_create_multi#564
miquelrosell99 wants to merge 1 commit into
OCA:17.0from
miquelrosell99:17.0-fix-maintenance-equipment-sequence-model-create-multi

Conversation

@miquelrosell99
Copy link
Copy Markdown

Converts MaintenanceEquipmentCategory.create() and MaintenanceEquipment.create() to batch-compatible api.model_create_multi for Odoo 17 best practice.

…ate_multi

Converts MaintenanceEquipmentCategory.create() and
MaintenanceEquipment.create() to batch-compatible
api.model_create_multi for Odoo 17 best practice.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @AdriaGForgeFlow,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:17.0 mod:maintenance_equipment_sequence Module maintenance_equipment_sequence labels May 20, 2026
Copy link
Copy Markdown
Contributor

@dalonsod dalonsod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See possible performance improvement comment

vals["sequence_id"] = self.sudo()._create_sequence(vals).id
else:
vals["sequence_prefix"] = (
self.env["ir.sequence"].browse(vals["sequence_id"]).prefix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line implies a browse() access for each for iteration. IMO it is desirable moving it outside for statement, make only one browse and manage result with a proper python dict within for.

if equipment.category_id and not equipment.serial_no:
sequence_id = (
self.env["maintenance.equipment.category"]
.browse(vals.get("category_id"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:maintenance_equipment_sequence Module maintenance_equipment_sequence series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants