forked from OCA/product-attribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] the relation to the attribute set should be on the product.temp…
…late, not the product.product. The rationale for this is that a set can contain attributes stored on the product or on the template. Thus, we have to know to which set a template is related to be able to read the list of attributes of the template within this set.
- Loading branch information
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
product_custom_attributes/migrations/7.0.0.2/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Guewen Baconnier | ||
# Copyright 2013 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('upgrade') | ||
|
||
|
||
def migrate(cr, version): | ||
logger.info("Migrating product_custom_attributes from version %s", version) | ||
cr.execute("UPDATE product_template pt " | ||
"SET attribute_set_id = (SELECT pp.attribute_set_id_copy " | ||
" FROM product_product pp WHERE " | ||
" pp.product_tmpl_id = pt.id " | ||
" LIMIT 1)" | ||
"WHERE pt.attribute_set_id IS NULL") | ||
cr.execute('ALTER TABLE product_product DROP COLUMN attribute_set_id') |
36 changes: 36 additions & 0 deletions
36
product_custom_attributes/migrations/7.0.0.2/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Guewen Baconnier | ||
# Copyright 2013 Camptocamp SA | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('upgrade') | ||
|
||
|
||
def migrate(cr, version): | ||
logger.info("Migrating product_custom_attributes from version %s", version) | ||
cr.execute("SELECT count(pp.attribute_set_id), pp.attribute_set_id " | ||
"FROM product_product pp " | ||
"INNER JOIN product_template pt ON pp.product_tmpl_id = pt.id " | ||
"GROUP BY pp.attribute_set_id " | ||
"HAVING count(pp.id) > 1") | ||
if cr.rowcount > 0: | ||
raise Exception('Impossible to migrate: all the variants should have ' | ||
'the same attribute set.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters