Skip to content

[IMP] while clean the odoo module version archive the product - #36

Merged
elicoidal merged 4 commits into
OCA:11.0from
bizzappdev:11.0
Oct 26, 2018
Merged

[IMP] while clean the odoo module version archive the product#36
elicoidal merged 4 commits into
OCA:11.0from
bizzappdev:11.0

Conversation

@bizzappdev

Copy link
Copy Markdown

in reference to OCA/interface-git#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
Copy Markdown
Author

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

@elicoidal elicoidal left a comment

Copy link
Copy Markdown

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(

Copy link
Copy Markdown

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)

Copy link
Copy Markdown

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

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
Copy Markdown
Author

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

@bizzappdev

Copy link
Copy Markdown
Author

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

@legalsylvain legalsylvain left a comment

Copy link
Copy Markdown

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
Copy Markdown
Author

once this PR and OCA/interface-git#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

@elicoidal elicoidal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@elicoidal

Copy link
Copy Markdown

@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
Copy Markdown
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(

@oscarolar oscarolar Oct 22, 2018

Copy link
Copy Markdown

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?

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

@elicoidal elicoidal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@elicoidal

Copy link
Copy Markdown

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

@oscarolar

Copy link
Copy Markdown

👍 @bizzappdev @elicoidal

@oscarolar oscarolar left a comment

Copy link
Copy Markdown

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

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

@bizzappdev

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

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

@bizzappdev

Copy link
Copy Markdown
Author

@elicoidal

elicoidal commented Oct 26, 2018 via email

Copy link
Copy Markdown

@elicoidal

Copy link
Copy Markdown

@sbidoul maybe can help

@bizzappdev

Copy link
Copy Markdown
Author

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

@sbidoul

sbidoul commented Oct 26, 2018

Copy link
Copy Markdown
Member

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

sbidoul commented Oct 26, 2018

Copy link
Copy Markdown
Member

Shall I install this on odoo-community.org?

@elicoidal

Copy link
Copy Markdown

@sbidoul yes please 😄

@bizzappdev

bizzappdev commented Oct 27, 2018

Copy link
Copy Markdown
Author

@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-git#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

sbidoul commented Oct 27, 2018

Copy link
Copy Markdown
Member

Installed. The above script is running right now.

@sbidoul

sbidoul commented Oct 27, 2018

Copy link
Copy Markdown
Member

Still running...

@elicoidal

Copy link
Copy Markdown

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

@sbidoul

sbidoul commented Oct 28, 2018

Copy link
Copy Markdown
Member

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

@bizzappdev

Copy link
Copy Markdown
Author

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

@sbidoul

sbidoul commented Oct 28, 2018

Copy link
Copy Markdown
Member

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

martintorresvm 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
ntsirintanis pushed a commit to Therp/apps-store that referenced this pull request Oct 31, 2025
* [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