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
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps_product_creator/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
'name': 'Github product creator',
'summary': 'Create a product variant (by version) for every module found '
'in the Github repositories',
'version': '11.0.1.1.2',
'version': '11.0.1.1.3',
'category': 'Connector',
'license': 'AGPL-3',
'author': 'Odoo Community Association (OCA)',
'author': 'Odoo Community Association (OCA), BizzAppDev',
'depends': [
'github_connector_oca',
'github_connector_odoo',
Expand Down
1 change: 1 addition & 0 deletions apps_product_creator/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import product_template
from . import product_product
from . import odoo_module
from . import odoo_module_veresion
25 changes: 25 additions & 0 deletions apps_product_creator/models/odoo_module_veresion.py
Original file line number Diff line number Diff line change
@@ -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

# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api


class OdooModuleVersion(models.Model):
_inherit = 'odoo.module.version'

@api.multi
def _process_clean_module_version(self):
for module_version in self:
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

[
not a for a in
product.product_tmpl_id.product_variant_ids.mapped(
'active')
]
)
if all_varient_archived:
product.product_tmpl_id.write(
{'active': False, 'website_published': False})
return super(OdooModuleVersion, self)._process_clean_module_version()