-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD] util.fields: handle ir.exports model/fields renames/removal #84
base: master
Are you sure you want to change the base?
Conversation
a4fc2be
to
8fd6ad7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the base idea of this PR is nice. The current implementation seems like doing too much for a first version. My suggestions are mostly to simplify the idea and focus on the simplest solution that work. If we encounter performance issues then we can switch to alternatives, probably reusing ideas already here.
src/util/fields.py
Outdated
) | ||
|
||
|
||
def get_resolved_ir_exports(cr, models=None, fields=None, only_missing=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be made simpler. Perform a couple of queries to get the pairs model,path
that need processing then use the _resolve_model_fields_path
with them.
I find it odd to have this util in fields.py
, maybe helpers.py
would be better suited?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be no perfect place to put it. For models-specific helpers I see accounting
, domains
modules, views are scattered between snippets
and records
(until #23 moves forward), there's some server actions helpers in fields
.
I'm not sure what data
module is for?
Perhaps records
could also be considered?
But I guess helpers
is an okay compromise (also to not mess with imports too much).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be records.py indeed. But I'm not sure myself. @KangOl ?
Implement proper fixing and/or removal of ir.exports and ir.exports.line records on model/fields renames/removal: - renamed fields: update affected ir.exports.line records - removed fields: remove affected ir.exports.line records - renamed models: update affected ir.exports records `resource` - removed models: remove affected ir.exports.line / ir.exports records Some of these cases were already handled but have been improved. Specifically: - for renamed fields, previously was done by doing a simple string replacement, which is not good enough because export lines can reference fields paths, and these in turn *might* contain paths to multiple fields with the same name on different models, only some of which are affected. Now the fields path get properly resolved for renaming, only the affected fields path parts are updated. - for removed fields, previously no action was taken, leaving a broken export template and UI traceback. Now the affected export lines are removed, using fields paths resolution. - for renamed and removed models, this was already handled by the indirect_references mechanism, but now export lines for the removed models are checked with the same mechanism for fields above. Additionally, unit tests have been added to make sure these cases are properly handled by the code.
The newly added ir.exports fixing code uses a recursive CTE query to resolve fields paths (from a root model). Similar code is already existing for handling domains, `ir.model.fields`.`depends`, and `ir.act.server`.`update_path`; but this older code is using a python for loop and issuing multiple queries to resolve the paths. In this commit, some of those helpers code is refactored to use the newer recursive CTE query instead. Additionally, the `_resolve_model_fields_path` helper and related code has been moved to `util.helpers` module.
8fd6ad7
to
44a6787
Compare
Hey, such a nice PR. I've got some entries in |
Forgot to ping you guys sorry @andreabak @aj-fuentes |
Properly handle ir.exports, especially on model/fields removal.
See commits for additional details.