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][MIG] project_task_code #1084

Closed
wants to merge 52 commits into from

Conversation

Abranes
Copy link
Member

@Abranes Abranes commented Mar 9, 2023

Supersedes #1013

@Abranes Abranes force-pushed the 16.0-mig-project_task_code branch from baa5a78 to 1329761 Compare March 9, 2023 09:46
@Abranes Abranes force-pushed the 16.0-mig-project_task_code branch from 1329761 to 01f2b27 Compare March 9, 2023 09:52
@pedrobaeza
Copy link
Member

/ocabot migration project_task_code

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Mar 9, 2023
@OCA-git-bot OCA-git-bot mentioned this pull request Mar 9, 2023
38 tasks
@OCA-git-bot
Copy link
Contributor

The migration issue (#988) has been updated to reference the current pull request.
however, a previous pull request was referenced : #1013.
Perhaps you should check that there is no duplicate work.
CC : @uncannycs

@Abranes Abranes force-pushed the 16.0-mig-project_task_code branch from 01f2b27 to 90103ce Compare March 16, 2023 10:49
@rafaelbn
Copy link
Member

rafaelbn commented Mar 27, 2023

Hello @Abranes

Please this module in 15 (at least) is creating constraint that breaks runboat with other modules. could you FIX it here in migration?

@Shide

Yes, project_task_code module is creating a constraint on project.task and other modules who creates tasks (by strange ways or on a different order) breaks the init of the ruboat with demo data.

@sbidoul

Ah, yes. IMO modules that add constraints on standard models should enable them by configuration, otherwise we reach dead ends like this one.

#1096 (comment)

Thank you!

@Abranes Abranes force-pushed the 16.0-mig-project_task_code branch from 90103ce to f1a8517 Compare April 21, 2023 16:03
@Abranes
Copy link
Member Author

Abranes commented Apr 21, 2023

Hello @Abranes

Please this module in 15 (at least) is creating constraint that breaks runboat with other modules. could you FIX it here in migration?

@Shide

Yes, project_task_code module is creating a constraint on project.task and other modules who creates tasks (by strange ways or on a different order) breaks the init of the ruboat with demo data.

@sbidoul

Ah, yes. IMO modules that add constraints on standard models should enable them by configuration, otherwise we reach dead ends like this one.

#1096 (comment)

Thank you!

Done! You can review it.

Copy link

@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.

Code is being set even if in the settings, the Task Code Unique is not checked.
Also check the pre_init_hook and post_init_hook


@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
Copy link

Choose a reason for hiding this comment

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

Should be done if user has activated the corresponding parameter in res.config.settings and sequence exists in self.env.company.

@rousseldenis
Copy link

@Abranes

@yaazkal
Copy link

yaazkal commented Oct 12, 2023

Is there something pending here still?

@Shide
Copy link

Shide commented Oct 16, 2023

Is there something pending here still?

Check @jort-aardug and @Shide suggestions

@yaazkal
Copy link

yaazkal commented Oct 21, 2023

@Abranes can you check the suggestions for this to be merged? Thanks

@robinkeunen
Copy link

I made a suggestion for the name tag comment. If I understand correctly, the project_task_unique_code parameter adds the check for unicity, it does not activate the feature. If so, @Shide 's comment do not apply.

I can do a superseeding PR if @Abranes or maintainers give me the go.

@Abranes
Copy link
Member Author

Abranes commented Oct 27, 2023

Sorry guys, I forgot this PR.

I'll try to address all points next week.

@Abranes
Copy link
Member Author

Abranes commented Nov 2, 2023

@jort-aardug @Shide @robinkeunen @yaazkal could you check it one more time? :)

Copy link

@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.

praise: Good job with this man :)

Code LGTM

@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). 🤖

Copy link

@robinkeunen robinkeunen left a comment

Choose a reason for hiding this comment

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

I think there is a confusion here, the module should

  • add the task code upon installation
  • force the unicity constraint on configuration

The last fixes does the opposite:

  • force the unicity constraint upon installation
  • create the task code on configuration

@Abranes
Copy link
Member Author

Abranes commented Nov 2, 2023

I think there is a confusion here, the module should

  • add the task code upon installation
  • force the unicity constraint on configuration

The last fixes does the opposite:

  • force the unicity constraint upon installation
  • create the task code on configuration

It's what @Shide requests and I think it's not a bad approach.

@robinkeunen
Copy link

robinkeunen commented Nov 2, 2023

But that changes the purpose of the module, migration is not the good time to do that. Plus a better module name would then me project_task_code_unique.

Plus it does not follow @sbidoul and @rafaelbn 's recommendation. Let's see what others think.

@robinkeunen
Copy link

Hi @rousseldenis @dreispt , we're disagreeing on the way to go with this PR. Can you help us move forward ?

@Shide
Copy link

Shide commented Dec 15, 2023

But that changes the purpose of the module, migration is not the good time to do that. Plus a better module name would then me project_task_code_unique.

Plus it does not follow @sbidoul and @rafaelbn 's recommendation. Let's see what others think.

Maybe we should add a migration script?

The module without this fix/feature will break tests for sure at any point in the future... If someone has the bad luck of having this module installed in another way.

@rafaelbn
Copy link
Member

Hello,

I don't know in this point which is the disagree. I pinged @Abranes because this module is breaking other modules test, etc... and we said to FIX it here.

Hello @Abranes

Please this module in 15 (at least) is creating constraint that breaks runboat with other modules. could you FIX it here in migration?

@Shide

Yes, project_task_code module is creating a constraint on project.task and other modules who creates tasks (by strange ways or on a different order) breaks the init of the ruboat with demo data.

@sbidoul

Ah, yes. IMO modules that add constraints on standard models should enable them by configuration, otherwise we reach dead ends like this one.

#1096 (comment)

Thank you!

  • The request was to address a constraint issue in the project_task_code module for version 15. The module's constraint on project.task is causing conflicts with other modules in runboat environments, especially those creating tasks in unconventional ways. @sbidoul suggests that modules adding constraints to standard models should have the option to enable these constraints through configuration to avoid such conflicts. This suggestion aims to prevent dead ends and improve module compatibility.

We are not using this module at all, just we are affected in other modules un runboat and test because this one.

@robinkeunen > But that changes the purpose of the module
@Shide > The module without this fix/feature will break tests for sure at any point in the future... If someone has the bad luck of having this module installed in another way.

  • The purpose of the module shouln't be change but FIXED

Maybe @oihane or @pedrobaeza as original contributors what to put an opinion. I don't know exacly what's the problem now. @dreispt Do you have a solution here o some past use case?

Thank you all! 😄 ❤️

Sorry, something went wrong.

@pedrobaeza
Copy link
Member

Can you summarize instead of copying a lot of texts? If I understand correctly, there was a constraint and it has been removed in the migration? Or the contrary? Which is the problem in runboat?

@robinkeunen
Copy link

In 15.0 : project_task_code

  • adds code field on tasks
  • adds sql contraint project_task_unique_code
  • a hook initializes code from project.task sequence
  • in create, code is assigned from project.task sequence

In his migration review (2023-03-27), @rafaelbn pointed out that the a configuration should be added for the constraint. Otherwise, it breaks the tests from other modules.

I understand from the suggestion that the module should

  • add the task code upon installation
  • force the unicity constraint on configuration

The fix from @Abranes, based on @Shide's request, does the opposite, it

  • forces the unicity constraint upon installation
  • creates the task code on configuration

@pedrobaeza
Copy link
Member

Thanks for the summary, Robin.

It's true that enforcing a uniqueness can be conflicting for prior version databases not containing this constraint migrating to this version. If implemented via SQL constraint, Postgres will try to put the constraint and fail, not having the constraint at all, but only a warning each time you update. Doing that by Python constraint allows to be enabled by configuration, and this would be a saner feature.

Another conflicting change is to fill existing taxes with a code, as you may not want to have one at all. I would go for having a button on configuration to fill the code on "empty code" taxes on demand.

Do you see it very complicated to be done?

@huguesdk
Copy link
Member

i don’t understand why so many changes are introduced in a simple version migration. this sql constraint is present since version 8. the hooks that run upon module initialization ensure that this constraint is satisfied, and that tasks created subsequently (even by other modules) will have a unique code (coming from a sequence). it shouldn’t cause an issue.

i don’t think it’s a good idea to introduce such significant changes as part of a version migration, unless something that changed in that version prevents the module from working as it did in the previous version.

i think that the changes in commit 90103ce are enough.

@robinkeunen
Copy link

Rather than arguing, I propose this PR #1209. I leave it to the PSC to choose what is more appropriate :-)

@huguesdk
Copy link
Member

could someone give a more detailed explanation about what the problem that we’re trying to solve exactly is (apart from porting this module to 16)? i’ve read that it caused errors during the runboat build. could someone copy the exact error here to see if it can be solved in a simpler way?

note that the original sql constraint is not multi-company compatible (it requires uniqueness of the code while it should probably be unique per company) while sequences are per company by default. maybe this could be the issue?

@legalsylvain
Copy link
Contributor

Hi @rafaelbn

Please this module in 15 (at least) is creating constraint that breaks runboat with other modules. could you FIX it here in migration?

could you mention the error generated ? I don't understand how it can break things !

Thanks !

@Abranes
Copy link
Member Author

Abranes commented Dec 21, 2023

Hi all! I can make the changes you want but first let's all be clear, because in the first instance I perform a normal migration, then modify the module so that the constraint was not by SQL and was by python and thus be able to activate or deactivate it in the configuration to avoid problems with other modules, and finally carry out the current implementation, all at the request of different people.

How do you prefer it to proceed?

@huguesdk
Copy link
Member

i personally think that the sql constraint should stay. it is the only way to ensure uniqueness in a reliable way. checking it in python won’t prevent the same code to be used if records are created at the same time. we need to check what problem the sql constraint actually caused, and fix it without removing the constraint.

@rafaelbn
Copy link
Member

Thinking in an OCA Repo with more modules involved:

IMO modules that add constraints on standard models should enable them by configuration, otherwise we reach dead ends. So not by SQL but by python and thus be able to activate or deactivate it in the configuration to avoid problems with other modules

Not blocking anything, just my opinion.

Thanks all by efforts in the best way! 😄 ❤️

@legalsylvain
Copy link
Contributor

legalsylvain commented Dec 26, 2023

IMO modules that add constraints on standard models should enable them by configuration, otherwise we reach dead ends. So not by SQL but by python and thus be able to activate or deactivate it in the configuration to avoid problems with other modules

Hi. my opinion is "Keep It simple". An SQL constraint is way more simple as constraint enabled by configuration. So, if there is no existing problem, I propose to keep the V15 code.

https://github.com/OCA/project/blob/15.0/project_task_code/models/project_task.py#L18-L20 is simpler (2 lines) than :

@rafaelbn : you was saying that V15 runboat was broken, but I see it green. Is it fixed ? https://runboat.odoo-community.org/webui/builds.html?repo=OCA/project&target_branch=15.0

@rafaelbn
Copy link
Member

Hello @legalsylvain! Happy new year 2024! 😄

@Shide will explain after holidays the problem that this modules causes when living in the same repo with other ones.

We are not using this module at all, we just found problems when working in others in the same repo.

Thank you!

@Shide
Copy link

Shide commented Jan 10, 2024

@legalsylvain the case which i'm saying this needs a change is because this happens to me in this PR: #1096 (comment)

Check out the next 4 comments where i'd invoked you because the runboat breaks

@legalsylvain
Copy link
Contributor

Hi @Shide. Thanks a lot for pointing the issue. @robinkeunen, could you take a look at this issue ?
thanks !
and happy new years !

@Abranes Abranes closed this Jan 10, 2024
@rafaelbn
Copy link
Member

This PR is continued in #1209

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.

None yet