Skip to content
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

[IMP] util.delete_unused #205

Closed

Conversation

KangOl
Copy link
Contributor

@KangOl KangOl commented Jan 31, 2025

Also consider child records when searching for record usage.

i.e. when try to remove a product category, also search for its sub categories as they will be cascade deleted if unused.

@KangOl KangOl requested review from nseinlet and aj-fuentes January 31, 2025 17:50
@robodoo
Copy link
Contributor

robodoo commented Jan 31, 2025

Pull request status dashboard

@KangOl KangOl force-pushed the master-delete_unused-cascade-children-chs branch from 2b1d4b3 to ec5036f Compare January 31, 2025 17:54
@KangOl
Copy link
Contributor Author

KangOl commented Jan 31, 2025

upgradeci retry with always only account account_reports appointment_account_payment auth_signup base calendar crm_iap_lead documents documents_hr event fleet hr_appraisal hr_expense hr_fleet hr_holidays hr_payroll hr_payroll_account hr_recruitment hr_timesheet industry_fsm industry_fsm_sale knowledge l10n_ae_hr_payroll l10n_ar l10n_at l10n_au_hr_payroll l10n_au_hr_payroll_account l10n_be l10n_be_hr_contract_salary l10n_be_hr_payroll l10n_ch_hr_payroll l10n_cl l10n_co l10n_de l10n_do l10n_es l10n_fr_hr_payroll l10n_hu l10n_in_hr_payroll l10n_it l10n_ke_hr_payroll l10n_lu_hr_payroll l10n_mn l10n_pe l10n_pl l10n_th l10n_tr mass_mailing payment payment_demo planning_contract point_of_sale portal_anonymous pos_pricer pos_restaurant product project project_todo repair resource sale_subscription sales_team sign stock stock_dropshipping survey training_base utm website_sale_slides website_slides in all versions

Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

To be sure I understand:
We extend the delete_unused method to take into account children of the record being removed. In effect if a child has a cascade removal it is fine to consider the parent unused as long a the child is also unused.

I still have mixed feelings bout this because how can we be sure it is a parent/child relationship? Maybe it is a same-table relation but not really a parent/child situation. I'd feel more reassured if at least we restrict to parent_id columns :/

Just for the sake of ensuring we discuss it. If there is a parent/child relationship already present in the list of records to remove I think current approach is still correct.

This patch requires a small comment in the docs if we move forward.

src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@KangOl
Copy link
Contributor Author

KangOl commented Feb 5, 2025

To be sure I understand: We extend the delete_unused method to take into account children of the record being removed. In effect if a child has a cascade removal it is fine to consider the parent unused as long a the child is also unused.

I still have mixed feelings bout this because how can we be sure it is a parent/child relationship? Maybe it is a same-table relation but not really a parent/child situation. I'd feel more reassured if at least we restrict to parent_id columns :/

The condition is same table + ondelete=cascade. I think it's enough to be considered to have a dependency between records.

Just for the sake of ensuring we discuss it. If there is a parent/child relationship already present in the list of records to remove I think current approach is still correct.

It bite us in the upgrade of odoo.com to saas~18.1 with the deletion of product categories.

This patch requires a small comment in the docs if we move forward.

Obviously

@aj-fuentes
Copy link
Contributor

It bite us in the upgrade of odoo.com to saas~18.1 with the deletion of product categories.

I was actually referring to the approach in this patch :) In other words I wanted to be sure that the presence of parent-child relationship in the input will work well with the new implementation added in this patch (wrongly referred as "current approach")

@KangOl KangOl force-pushed the master-delete_unused-cascade-children-chs branch from ec5036f to aaf2732 Compare February 6, 2025 13:19
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Show resolved Hide resolved
src/util/records.py Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@KangOl KangOl force-pushed the master-delete_unused-cascade-children-chs branch from f1e6dca to ee57780 Compare February 7, 2025 10:38
@KangOl KangOl force-pushed the master-delete_unused-cascade-children-chs branch from ee57780 to 8717722 Compare February 17, 2025 09:26
Also consider child records when searching for record usage.

i.e. when try to remove a product category, also search for its sub
categories as they will be cascade deleted if unused.

Co-authored-by: Alvaro Fuentes <afu@odoo.com>
@KangOl KangOl force-pushed the master-delete_unused-cascade-children-chs branch from 8717722 to e97c25b Compare February 17, 2025 15:11
@nseinlet
Copy link
Contributor

@robodoo r+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants