-
-
Notifications
You must be signed in to change notification settings - Fork 172
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] convert_from_company_dependent #390
base: master
Are you sure you want to change the base?
Conversation
But I think this depends on the business logic behind, as you are converting a multi-valued field (potentially one per company) into only one value, so you need to decide what to do in case of conflict depending on the use case. |
I think the general case will be pretty much the same everywhere: v(n-1): model has no company_id and property property_whatever Then the user of the function duplicates every row of model for each company where it makes sense (that's the business logic depending part), and calls |
But in such duplication, |
it will, because the caller sets company_id for the cloned records as it's appropriate. consider the account migration, there they duplicate tax groups as it makes sense into the different companies, and in the next function I can replace the horrible incomplete sql statements with three calls to the function I propose. Wherever Odoo decides to go from properties to company aware on model level, we need the exact same thing. |
FROM ir_property ip | ||
WHERE ip.fields_id={field_id} --- {origin_field_name} | ||
AND ( | ||
ip.res_id = '{model_name}.' || {table_name}.id |
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 insist that this is the problem. The duplicated record has an ID that is not on ir_property
table, as the corresponding one is the previous record ID.
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.
thanks for insisting, see below
aaah wait, I get it now. This indeed needs the extra field I propose on the PR to link the clones to their origin record. That's a good thing to have in those cases anyways, will do next week |
this is the function I propose in OCA/OpenUpgrade#4457 (comment), will be useful elsewhere too