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] while clean the odoo module version archive the product #36

Merged
merged 4 commits into from
Oct 26, 2018

Conversation

bizzappdev
Copy link

in reference to OCA/interface-github#30
when the Odoo module version will be deleted it will archive the related product variant.
If there will be no other product related to that product template then it will archive and unpublish the product template.

@bizzappdev
Copy link
Author

@RoelAdriaans @oscarolar @StephanRozendaal Please review.
cc @elicoidal

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

product = self.env['product.product'].search(
[('odoo_module_version_id', '=', module_version.id)])
product.write({'active': False})
all_varient_archived = all(

Choose a reason for hiding this comment

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

variant

@@ -0,0 +1,25 @@
# Copyright (C) 2017-Today: Odoo Community Association (OCA)

Choose a reason for hiding this comment

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

add your name

@elicoidal elicoidal added this to the 12.0 milestone Oct 15, 2018
@legalsylvain
Copy link

there is a typo in the name of the file
apps_product_creator/models/odoo_module_veresion.py

-> odoo_module_version.py

@bizzappdev
Copy link
Author

@elicoidal @legalsylvain thanks for your comments. changes are done as suggested. sorry for typos

@bizzappdev
Copy link
Author

@oscarolar @RoelAdriaans @StephanRozendaal @legalsylvain can you please review this PR.

Copy link

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

LGTM. Thanks for this work.
(code review / no test).

@bizzappdev bizzappdev closed this Oct 17, 2018
@bizzappdev bizzappdev reopened this Oct 17, 2018
@bizzappdev
Copy link
Author

once this PR and OCA/interface-github#30 both are merged. I will test on the migration database for the process to fix old products. and then we can proceed for the update on the production.
cc @elicoidal

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
Copy link

@oscarolar @RoelAdriaans @StephanRozendaal if you have the opportunity to review?

@elicoidal elicoidal modified the milestones: 12.0, 11.0 Oct 17, 2018
@bizzappdev
Copy link
Author

@elicoidal we have already 2 approval e can go ahead if we want.
NOTE: first I have to test on migration the steps to fix things on production.
that I can do after merge of both PRs

product = self.env['product.product'].search(
[('odoo_module_version_id', '=', module_version.id)])
product.write({'active': False})
all_variant_archived = all(
Copy link

@oscarolar oscarolar Oct 22, 2018

Choose a reason for hiding this comment

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

Since you are making 3 iterations(all, for, mapped) here I think you should use something with less performance impact:

active_variants = product_obj.search_count(
    [('product_tmpl_id', '=', product.product_tmpl_id.id),
     ('active', '=', True)])
if not active_variants:
    product.product_tmpl_id.write({'active': False, 'website_published': False})

what do you think?

Choose a reason for hiding this comment

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

@bizzappdev any feedback on this?

Copy link
Author

Choose a reason for hiding this comment

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

@oscarolar thank you for your suggestion, You are right, I have changed the code as per your suggestion.
cc @elicoidal

Choose a reason for hiding this comment

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

I do not see the change here. Did I miss somethign?

Copy link
Author

Choose a reason for hiding this comment

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

something strange with github this still shows the outdated changes.
https://github.com/OCA/apps-store/pull/36/files#diff-87908d4d380713ee148592d4aa5e5069R16
please find the changes it is there already

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
Copy link

@oscarolar please have a look but I think your remark was attended

@oscarolar
Copy link

👍 @bizzappdev @elicoidal

Copy link

@oscarolar oscarolar left a comment

Choose a reason for hiding this comment

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

Good to go.

@elicoidal elicoidal merged commit 235b013 into OCA:11.0 Oct 26, 2018
@elicoidal
Copy link

@gurneyalex The OCA/interface-github + OCA/apps-store repository should be refreshed in our ERP (not urgent)

@bizzappdev
Copy link
Author

@elicoidal @gurneyalex yes code can be pulled on the server.
for fixing old products/apps I will provide steps by today or tomorrow evening.

@elicoidal
Copy link

@bizzappdev could you have a look at Travis too because something got broken in the process.

@bizzappdev
Copy link
Author

@elicoidal
Copy link

elicoidal commented Oct 26, 2018 via email

@elicoidal
Copy link

@sbidoul maybe can help

@bizzappdev
Copy link
Author

@elicoidal it is failing for travis_makepot not sure what and why
@sbidoul help needed

@sbidoul
Copy link
Member

sbidoul commented Oct 26, 2018

makepot failed to push to github because in the meantime another commit (the readme update) was made.

But that commit triggered a new travis build which itself succeeded: https://github.com/OCA/apps-store/commits/11.0

So all is well.

@sbidoul
Copy link
Member

sbidoul commented Oct 26, 2018

Shall I install this on odoo-community.org?

@elicoidal
Copy link

@sbidoul yes please 😄

@bizzappdev
Copy link
Author

bizzappdev commented Oct 27, 2018

@sbidoul @gurneyalex along with the update on the odoo-community.org.

we have to update the latest code for interface-github repo also as OCA/interface-github#30 as the current PR is depending upon this
we have to fix the old products.
for that we have to execute a server action for the same
Please find the detail of the server action as below.
Detail of server action
Model: product.template
Action To Do Execute Python Code
Python code.

for rec in record:
    if len(rec.attribute_line_ids) != 1:
        continue
    att_list = []
    blank_list = []
    for att in rec.attribute_line_ids:
        if not att.value_ids:
            continue
        att_list.append([1, att.id, {'value_ids': [[6, 0, att.value_ids.ids]]}])
        blank_list.append([1, att.id, {'value_ids': [[6, 0, []]]}])
    
    rec.write({'attribute_line_ids':blank_list})
    rec.write({'attribute_line_ids':att_list})

As there are missing product variant and odoo module version.
when we will change the value attribute values of the template it will recalculate the odoo module version. in the end, we will have proper products/apps with its module information.

@sbidoul
Copy link
Member

sbidoul commented Oct 27, 2018

Installed. The above script is running right now.

@sbidoul
Copy link
Member

sbidoul commented Oct 27, 2018

Still running...

@elicoidal
Copy link

@bizzappdev thanks for the detailed procedure.
I suspect it might take some time as there are about 10K products

@sbidoul
Copy link
Member

sbidoul commented Oct 28, 2018

It's done. Can you please check everything is ok?

@bizzappdev
Copy link
Author

No it is not fixed.. not sure qhy. Do you think we should have screen sharing session or something tomorrow.

@sbidoul
Copy link
Member

sbidoul commented Oct 28, 2018

Hm, perhaps because I forgot to upgrade interface-github. I'm relaunching the script.

victormmtorres pushed a commit to Tecnativa/apps-store that referenced this pull request Apr 10, 2019
* [IMP] while clean the odoo module version archive the product

* [FIX]Added new line at the end of file

* [FIX] fix some typo

* [IMP]improve logic with less iterations
CarlosRoca13 pushed a commit to Tecnativa/apps-store that referenced this pull request Jul 10, 2020
* [IMP] while clean the odoo module version archive the product

* [FIX]Added new line at the end of file

* [FIX] fix some typo

* [IMP]improve logic with less iterations
pedrobaeza pushed a commit to Tecnativa/apps-store that referenced this pull request Jul 17, 2020
* [IMP] while clean the odoo module version archive the product

* [FIX]Added new line at the end of file

* [FIX] fix some typo

* [IMP]improve logic with less iterations
ernestotejeda pushed a commit to Tecnativa/apps-store that referenced this pull request Aug 2, 2021
* [IMP] while clean the odoo module version archive the product

* [FIX]Added new line at the end of file

* [FIX] fix some typo

* [IMP]improve logic with less iterations
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