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

[FIX]do not delete module version if already exists and just update #30

Merged

Conversation

bizzappdev
Copy link
Contributor

If Odoo module version already exists then instead of updating that version it is deleting and creating a new one.

Expected behaviour after this PR, It will not delete the existing version.

Updating the existing version functionality is already there

@bizzappdev
Copy link
Contributor Author

OCA/apps-store#31 will be solved after this PR merged.

@bizzappdev
Copy link
Contributor Author

@RoelAdriaans @oscarolar @StephanRozendaal Can anyone of you please review this.

Copy link
Contributor

@StephanRozendaal StephanRozendaal left a comment

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza
Copy link
Member

Why Travis is red?

@bizzappdev
Copy link
Contributor Author

@pedrobaeza https://github.com/OCA/interface-github/blob/11.0/github_connector/models/github.py#L75 this is the normal python Class and Travis is expecting a Super call for create method https://github.com/OCA/interface-github/blob/11.0/github_connector/models/github.py#L156

changes are Not from my commit.

@StephanRozendaal
Copy link
Contributor

Looks like the flake8 test failed, in the log I see:

github_connector_odoo/models/github_repository_branch.py:88:13: F841 local variable 'module_versions' is assigned to but never used

@pedrobaeza
Copy link
Member

Yes, you should remove previous line too. But I wonder why it was there initially, as this seems to be put on purpose.

@legalsylvain @cubells any idea?

@bizzappdev
Copy link
Contributor Author

Not needed code removed. thanks @StephanRozendaal
@pedrobaeza No idea why it was there before. might be the original author can answer

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

Hi, I understand that it is problematic with the new appstore !

this code was designed to be sure that all the module version was up to date. I mean to handle situations where a module version moved out of the repository.

I think we should replace this code by another, to test if the module still exist, and if not, delete obsolete module version.
please ping me if I'm not clear.

@bizzappdev
Copy link
Contributor Author

@legalsylvain okay clear, You mean to say at the end of the cron job we should call the module and module version verification method.
I will work on that tomorrow

@elicoidal
Copy link

I think we should replace this code by another, to test if the module still exist, and if not, delete obsolete module version.

Makes sense to me too

@legalsylvain
Copy link
Contributor

legalsylvain commented Oct 12, 2018

Not exactly. I mean :
After first analysis :
a repository contains 5 module.version.

when we analyse again, if a module.version disappeared from the repository we should drop it. (and so the appstore should drop the related products also)

so kind of algorithm like :

# at the beginning of the analyse of a repository, save current_module_version_ids

# during the analyse save all the currently analyse module version into a analysed_module_version_ids

# at the end, drop all module versions that are in current_module_version_ids - analysed_module_version_ids

(something like that)

@elicoidal
Copy link

should drop the related products also

you mean inactivate. When it reappears we just reactivate the product.

@hbrunn has an interesting idea that we could develop later to create products in Alpha maturity level for open PR with green travis. We should be able to activate/inactivate a version after discovery IMO

@bizzappdev
Copy link
Contributor Author

Not exactly. I mean :
After first analysis :
a repository contains 5 module.version.

when we analyse again, if a module.version disappeared from the repository we should drop it. (and so the appstore should drop the related products also)

so kind of algorithm like :

# at the beginning of the analyse of a repository, save current_module_version_ids

# during the analyse save all the currently analyse module version into an analysed_module_version_ids

# at the end, drop all module versions that are in current_module_version_ids - analysed_module_version_ids

(something like that)

this seems little tricky as we do process always all the branches. we just project the branches which have state to_analyze.
IMO we should have another special cron job to check the drop odoo module version. which we can enhance in the app-store module to archive the product.

@elicoidal
Copy link

IMO we should have another special cron job to check the drop odoo module version. which we can enhance in the app-store module to archive the product.

Looks like a good idea to one specific cron job to have one pass on all module and change the active field indeed

@bizzappdev
Copy link
Contributor Author

as per that, I have added a new cron job for cleaning up the Odoo module version.
@legalsylvain Can you please review

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

Nice design, thanks !

A blocking point about path. LGTM otherwise.

regards.

def clean_odoo_module_version(self):
for module_version in self:
module_ver_path = os.path.join(
module_version.repository_branch_id.local_path,
Copy link
Contributor

Choose a reason for hiding this comment

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

You should base your analyse about local_path, but on module_paths. Otherwise, analysis of project base on Odoo. (OCB, OpenUpgrade, will fail).
so a for each is required.

see line 87 (previously 94) of the same file.

module_version.technical_name)
if os.path.exists(module_ver_path):
continue
module_version._process_clean_module_version()
Copy link
Contributor

@legalsylvain legalsylvain Oct 15, 2018

Choose a reason for hiding this comment

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

why not just move_version.unlink() ? and removing the function _process_clean_module_version.
(sorry for the noice, just understood that point, reading https://github.com/OCA/apps-store/pull/36/files#diff-65d1a23272a69d00ef4e64370b596546R10

Copy link

@elicoidal elicoidal left a comment

Choose a reason for hiding this comment

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

I have a question (I am not able to see it in the code sorry).
I understand the pseudo code as followed:

  • if a module is present we check whether there is a product associated (active or inactive)
  • if product is inactive -> activate and publish
  • if module is not present and there is a product -> inactivate and unpublish

I think this is what you do here: https://github.com/OCA/apps-store/pull/36/files but I just want to be sure

@bizzappdev
Copy link
Contributor Author

@elicoidal yes the flow is exactly what you say.
in interface-github only the code is for deleting the module version while on apps-store module we have code for achieving the product.

@bizzappdev
Copy link
Contributor Author

bizzappdev commented Oct 16, 2018

@legalsylvain changes are done as per your suggestion. and module_paths is Now supported.

@legalsylvain
Copy link
Contributor

and module_paths is not supported.

I don't understand that point. I'm running this module in local instance, and I analyse correctly modules, downloading the code of https://github.com/odoo/odoo and the analysis of the modules of Odoo core works fine.

@bizzappdev
Copy link
Contributor Author

and module_paths is not supported.

I don't understand that point. I'm running this module in local instance, and I analyse correctly modules, downloading the code of https://github.com/odoo/odoo and the analysis of the modules of Odoo core works fine.

Sorry for the previous update. "Now" is autocorrected in mind by "Not". and that has changed the complete meaning of the Sentence.

@legalsylvain
Copy link
Contributor

OK. ;-).
note : I don't see the changes, did you commited ?

@bizzappdev
Copy link
Contributor Author

indeed push was not done.

Copy link
Contributor

@legalsylvain legalsylvain left a comment

Choose a reason for hiding this comment

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

minor non blocking point. LGTM. code review, no test.

Thanks for the changes.

for module_version in self:
# Compute path(s) to analyze
branch = module_version.repository_branch_id
if branch.module_paths:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi thanks.
Not blocking point. (can be done later).
it could be great to refactor this lines because duplicated with a new function in repository.branch model named :

@api.multi 
def _get_module_paths:
    self.ensure_one()
   branch = self
    if branch.module_path  
         paths = []
         for path in branch.module_paths.split('\n'):
            if path.strip():
                paths.append(os.path.join(branch.local_path, path))
        else:
            paths = [branch.local_path]
return paths

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead, I would suggest having a new functional field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry my bad it will be not possible as we might have list in paths

Copy link
Contributor

Choose a reason for hiding this comment

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

As you wish on that point.

  • it can be the function, (as proposed).
  • it can be a new computed field my_computed_field = fields.Char(help="coma separated path") (as in ADDONS_PATH syntax), that we have just to split after.
    no clear point of view on that point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed redundant code and added function for that.

@bizzappdev
Copy link
Contributor Author

@StephanRozendaal can you please review again because few things are changed after your approval.

Copy link

@elicoidal elicoidal left a comment

Choose a reason for hiding this comment

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

LGTM

@elicoidal elicoidal added this to the 11.0 milestone Oct 17, 2018
@elicoidal
Copy link

@StephanRozendaal are we good to go?

Copy link
Contributor

@StephanRozendaal StephanRozendaal left a comment

Choose a reason for hiding this comment

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

LGTM

@elicoidal
Copy link

thanks @StephanRozendaal merging

@elicoidal elicoidal merged commit 8fe4283 into OCA:11.0 Oct 25, 2018
cubells pushed a commit to Tecnativa/interface-github that referenced this pull request Apr 5, 2019
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
Tardo pushed a commit to Tecnativa/interface-github that referenced this pull request Apr 14, 2020
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
Tardo pushed a commit to Tecnativa/interface-github that referenced this pull request Jun 17, 2020
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
pedrobaeza pushed a commit to Tecnativa/interface-github that referenced this pull request Jun 18, 2020
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
OpenCode pushed a commit to OpenCode/interface-github that referenced this pull request Jul 15, 2021
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
ernestotejeda pushed a commit to Tecnativa/interface-github that referenced this pull request Jul 30, 2021
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
OpenCode pushed a commit to OpenCode/interface-github that referenced this pull request Jun 23, 2022
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
victoralmau pushed a commit to Tecnativa/interface-github that referenced this pull request Nov 17, 2022
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
carolinafernandez-tecnativa pushed a commit to Tecnativa/interface-github that referenced this pull request Jan 9, 2024
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
carolinafernandez-tecnativa pushed a commit to Tecnativa/interface-github that referenced this pull request Mar 7, 2024
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
victoralmau pushed a commit to Tecnativa/interface-github that referenced this pull request Nov 8, 2024
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
victoralmau pushed a commit to Tecnativa/interface-github that referenced this pull request Nov 11, 2024
…CA#30)

* [FIX]do not delete module version if already exists and just update

* [FIX]remove not needed code

* [IMP] added clean odoo module version cron

* [IMP]support module_paths also

* [IMP]separate function fo the module path to remove redundant code
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