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

[16.0][IMP] crm_project_create: Archive or reactive the project and its analytical account from lead. #631

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

edlopen
Copy link
Member

@edlopen edlopen commented Jan 31, 2025

Hello,
This pull request adds the functionality that when archiving or unarchiving an opportunity, its associated projects and analytical accounts are also archived or unarchived. It also works when a lead is lost.

TODO: video

@moduon MT-8265

@OCA-git-bot
Copy link
Contributor

Hi @rafaelbn, @EmilioPascual,
some modules you are maintaining are being modified, check this out!

@EmilioPascual
Copy link
Contributor

Also you should review the tests.

@edlopen edlopen force-pushed the 16.0-imp-archive_project_on_lost_lead branch from 2aaebb9 to 5fac8bc Compare January 31, 2025 15:15
@rafaelbn rafaelbn added this to the 16.0 milestone Feb 3, 2025
@edlopen edlopen force-pushed the 16.0-imp-archive_project_on_lost_lead branch from 5fac8bc to 53c6f90 Compare February 4, 2025 08:32
Copy link
Contributor

@EmilioPascual EmilioPascual left a comment

Choose a reason for hiding this comment

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

A little change

Comment on lines 77 to 78
self.assertTrue(self.lead.project_id.active)
self.assertTrue(self.lead.project_id.analytic_account_id.active)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.assertTrue(self.lead.project_id.active)
self.assertTrue(self.lead.project_id.analytic_account_id.active)

Why do you check the project and the analytic account are active? I think it's not necessary, the project and the account analytic have just been created, they should be active unless you have added a new behavior for it, but this isn't the case.

@edlopen edlopen force-pushed the 16.0-imp-archive_project_on_lost_lead branch from 53c6f90 to 264414d Compare February 5, 2025 08:18
Copy link
Contributor

@EmilioPascual EmilioPascual left a comment

Choose a reason for hiding this comment

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

Code and functional review.

Good Job @edlopen!!

Copy link
Contributor

@Shide Shide left a comment

Choose a reason for hiding this comment

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

nitpick: Avoid negate variables when not needed

Comment on lines 14 to 17
for lead in self.filtered(lambda l: l.project_id):
lead.sudo().project_id.active = not lead.active
lead.sudo().project_id.analytic_account_id.active = not lead.active
return super().toggle_active()
Copy link
Contributor

@Shide Shide Feb 5, 2025

Choose a reason for hiding this comment

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

Why not move super().toggle_active() to top and avoid the confusing not lead.active?

Suggested change
for lead in self.filtered(lambda l: l.project_id):
lead.sudo().project_id.active = not lead.active
lead.sudo().project_id.analytic_account_id.active = not lead.active
return super().toggle_active()
res = super().toggle_active()
for lead in self.filtered(lambda l: l.project_id):
lead.sudo().project_id.active = lead.active
lead.sudo().project_id.analytic_account_id.active = lead.active
return res

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes sense. Thanks for the advice!

@edlopen edlopen force-pushed the 16.0-imp-archive_project_on_lost_lead branch from 264414d to 241b724 Compare February 5, 2025 10:45
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

👍🏼 tested functionally in runbot

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@rafaelbn
Copy link
Member

rafaelbn commented Feb 5, 2025

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-631-by-rafaelbn-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 453f0d0 into OCA:16.0 Feb 5, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 5d711a8. Thanks a lot for contributing to OCA. ❤️

@Shide Shide deleted the 16.0-imp-archive_project_on_lost_lead branch February 5, 2025 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants