[IMP] add update_domain function for renaming fields in domains or changing values #430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For a customer project, I'm migrating companies to operating units. This involves rewriting domains in ie ir.filters from
[('company_id', '=', some_company_id)]to[('operating_unit_id', '=', the_corresponding_ou_id)].Als I've encountered things like this several times already, I think it's time to have this in openupgradelib. We can make use of this function in merge_records and rename_fields eventually, but it's useful on its own for arbitrary domain fields.
Docstring:
Given a string containing a domain, this function
returns a text representation of it modified as executed by the
update_* functions passed.
:param domain: an Odoo domain like "[('some_field', '=', value)]"
:param update_name_func: function being passed a field name as string, returning a replacement string.
Example:
With
calling
returns
:param update_value_func: function being passed a domain field name as string, and a value as string, int, list or ast.Expression if the right hand side of a domain leaf cannot be parsed as one of the former. Return one of the aformentioned types to replace the right hand side of the domain leaf.
Example:
With
calling
returns