odoo-ps/ps-ai-skills · Archived

custom_util

"PS-specific Odoo migration helpers for model/field renaming, Studio field transfers, and batch view updates, ensuring proper registry state management."

Hot #1655

Installation

$ npx skills add odoo-ps/ps-ai-skills --skill custom_util

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from odoo-ps/ps-ai-skills · top by installs.

npx skills add odoo-ps/ps-ai-skills

Browse all from odoo-ps/ps-ai-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,664 B
  • docs SUMMARY.md 170 B

History

  1. First recorded snapshot · 7 installs

SKILL.md

PS Custom Upgrade Utils Skill

Use the custom_util module for PS-specific Odoo data migrations. These helpers extend the standard upgrade-util library to handle common PS patterns and ensure technical debt (like Studio fields) is cleanly versioned.

Summary of Helpers

  • customutil.customrenamemodel(cr, oldname, new_name):

- Renames the model and ensures its state is set to 'base'. Required for custom models to be correctly handled by the Odoo registry.

  • customutil.customrenamefield(cr, model, oldname, new_name):

- Renames a field and ensures its state is set to 'base'. Use this for all x or xstudio_ fields.

  • customutil.transfercustomfields(cr, srcmodule, destmodule, fieldsto_transfer):

- Moves fields between modules. fieldstotransfer is a list of (model, field) or (model, oldfield, newfield) tuples.

  • customutil.customrenamemodule(cr, oldname, new_name):

- Safely renames a custom module, handling cases where a new module record might already exist.

  • customutil.updatecustomviews(cr, listfields):

- Batch updates multiple fields in ALL views. listfields is a list of (model, oldfield, new_field) tuples.

  • customutil.views.edit.editviews(cr, { xmlid: (Operations) }):

- Fine-grained view modification using specific operation objects: - operations.ReplaceValue(search, replace): Search/replace strings or regex. - operations.UpdateAttributes(xpath, attrs): Update or remove (if None) XML attributes. - operations.RemoveFields(names): Shorthand to remove one or more fields. - operations.RenameElements(old, new)**: Renames elements (and their labels) while keeping other attributes.

  • customutil.updaterelatedfield(cr, listfields):

- Updates related definitions on fields that point to renamed custom fields.

  • customutil.mergegroups(cr, srcxmlid, destxmlid):

- Merges one security group into another, remapping users and updating references.

  • customutil.mergemodelanddata(cr, sourcemodel, targetmodel, copyfields, setvalues=None):

- Merges one model into another, copying the records and remapping all IDs and references.

  • customutil.renamexmlids(cr, pairs, detect_module=True):

- Renames a batch of XML IDs. pairs is a list of (oldxmlid, newxmlid) tuples.

Usage Example

from odoo.upgrade import util
from custom_util import custom_util

def migrate(cr, version):
    # Rename a custom model and field
    custom_util.custom_rename_model(cr, 'x_my_old_model', 'my.new.model')
    custom_util.custom_rename_field(cr, 'my.new.model', 'x_my_old_field', 'my_new_field')

    # Transfer Studio fields
    custom_util.transfer_custom_fields(cr, 'studio_customization', 'my_module', [
        ('res.partner', 'x_studio_custom_field', 'custom_field'),
    ])

    # Bulk update views for renamed fields
    custom_util.update_custom_views(cr, [
        ('res.partner', 'x_old_field', 'new_field'),
    ])

Best Practices

  • Registry Health: Always use custom_util for custom/studio fields to keep the Odoo registry in the standard

'base' state.

  • Documentation: If a field is renamed, verify if other fields' related or depends attributes need updating

via updaterelatedfield.