diff --git a/.travis.yml b/.travis.yml index f88d6c8fe92..9684bffb899 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ addons: env: global: - - VERSION="8.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" + - VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0" - TRANSIFEX_USER='transbot@odoo-community.org' - secure: nzJrUI6abQi27D2bzd5wswlEoF5LzLqUyUpb/ZKv9+ylgZcPTmqYr1jFTbh68kVSSpepoL5JrjnWHDlh2qDEyB2Iak00mkGGdydxxVl6EJbkZP2kElrN3OGPTa6pImsNGf3lRoZqhE5nXRfWHcxIYCtX/F6GimPZdTJx9hvyyQQ= diff --git a/product_multi_image/__manifest__.py b/product_multi_image/__manifest__.py index 17918e6153a..dbd8dd9b83c 100644 --- a/product_multi_image/__manifest__.py +++ b/product_multi_image/__manifest__.py @@ -4,32 +4,32 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "Multiple Images in Products", - "version": "8.0.2.0.0", - "author": "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + 'name': 'Multiple Images in Products', + 'version': '10.0.1.0.0', + 'author': "Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Antiun Ingeniería, " "Tecnativa, " "Odoo Community Association (OCA)", - "license": "AGPL-3", - "website": "http://www.serviciosbaeza.com", - "category": "Sales Management", - #"pre_init_hook": "pre_init_hook", - "depends": [ - "storage_image", - "product", + 'license': 'AGPL-3', + 'website': 'http://www.serviciosbaeza.com', + 'category': 'Sales', + # "pre_init_hook": "pre_init_hook", + 'depends': [ + 'storage_image', + 'product', ], - "data": [ + 'data': [ + 'security/ir.model.access.csv', + 'security/ir.rule.csv', 'views/image_view.xml', 'views/product_template_view.xml', 'views/product_product_view.xml', - 'security/ir.model.access.csv', - 'security/ir.rule.csv', ], - 'installable': False, - "images": [ - "images/product.png", - "images/db.png", - "images/file.png", - "images/url.png", + 'images': [ + 'images/product.png', + 'images/db.png', + 'images/file.png', + 'images/url.png', ], + 'installable': True, } diff --git a/product_multi_image/models/image.py b/product_multi_image/models/image.py index d9465123de8..7d4c7fb9e31 100644 --- a/product_multi_image/models/image.py +++ b/product_multi_image/models/image.py @@ -2,19 +2,22 @@ # © 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). -from openerp import api, fields, models +from odoo import models, fields, api class Image(models.Model): - _inherit = "storage.image" + _inherit = 'storage.image' product_variant_ids = fields.Many2many( - comodel_name="product.product", string="Visible in these variants", + comodel_name='product.product', + string='Visible in these variants', help="If you leave it empty, all variants will show this image. " "Selecting one or several of the available variants, you " - "restrict the availability of the image to those variants.") + "restrict the availability of the image to those variants." + ) product_variant_count = fields.Integer( - compute="_compute_product_variant_count") + compute='_compute_product_variant_count' + ) @api.multi def _compute_product_variant_count(self): diff --git a/product_multi_image/models/product_product.py b/product_multi_image/models/product_product.py index aa9ab03791f..fe10df16986 100644 --- a/product_multi_image/models/product_product.py +++ b/product_multi_image/models/product_product.py @@ -2,19 +2,31 @@ # © 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3). -from openerp import api, fields, models -from openerp.osv import orm -from openerp.osv import fields as old_fields +from odoo import models, fields, api class ProductProduct(models.Model): - _name = "product.product" - _inherit = [_name, "storage.image.owner.compatibility"] + _name = 'product.product' + _inherit = [_name, 'storage.image.owner.compatibility'] + image = fields.Binary( + related='image_main', + store=False + ) + image_medium = fields.Binary( + related='image_main_medium', + store=False + ) + image_small = fields.Binary( + related='image_main_small', + store=False + ) # Make this field computed for getting only the available images image_ids = fields.One2many( - compute="_compute_image_ids", comodel_name="storage.image", - inverse="_inverse_image_ids") + compute='_compute_image_ids', + comodel_name='storage.image', + inverse='_inverse_image_ids' + ) @api.multi @api.depends('product_tmpl_id', 'product_tmpl_id.image_ids', @@ -75,25 +87,3 @@ def unlink(self): len(image.product_variant_ids) == 1)) images2remove.unlink() return super(ProductProduct, obj).unlink() - - -class ProductProductOld(orm.Model): - """It is needed to use v7 api here because core model fields use the - ``multi`` attribute, that has no equivalent in v8, and it needs to be - disabled or bad things will happen. For more reference, see - https://github.com/odoo/odoo/issues/10799 - - Needed for getting the correct data in the inheritance chain. Probably - in v10 this won't be needed as the inheritance has been globally - redesigned. - """ - _name = "product.product" - _inherit = [_name, "storage.image.owner.compatibility"] - _columns = { - "image": old_fields.related( - "image_main", type="binary", store=False, multi=False), - "image_medium": old_fields.related( - "image_main_medium", type="binary", store=False, multi=False), - "image_small": old_fields.related( - "image_main_small", type="binary", store=False, multi=False) - } diff --git a/product_multi_image/models/product_template.py b/product_multi_image/models/product_template.py index 6f500077ff7..f5520a05126 100644 --- a/product_multi_image/models/product_template.py +++ b/product_multi_image/models/product_template.py @@ -3,10 +3,10 @@ # © 2015 Antiun Ingeniería S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.osv import orm, fields +from odoo import models, fields -class ProductTemplate(orm.Model): +class ProductTemplate(models.Model): """Reference core image fields to multi-image variants. It is needed to use v7 api here because core model fields use the ``multi`` @@ -14,22 +14,18 @@ class ProductTemplate(orm.Model): bad things will happen. For more reference, see https://github.com/odoo/odoo/issues/10799 """ - _name = "product.template" + _name = 'product.template' _inherit = [_name, "storage.image.owner.compatibility"] - _columns = { - "image": fields.related( - "image_main", - type="binary", - store=False, - multi=False), - "image_medium": fields.related( - "image_main_medium", - type="binary", - store=False, - multi=False), - "image_small": fields.related( - "image_main_small", - type="binary", - store=False, - multi=False) - } + + image = fields.Binary( + related='image_main', + store=False + ) + image_medium = fields.Binary( + related='image_main_medium', + store=False + ) + image_small = fields.Binary( + related='image_main_small', + store=False + ) diff --git a/product_multi_image/security/ir.model.access.csv b/product_multi_image/security/ir.model.access.csv index 4d2617f3dd9..fe8a4d1b667 100644 --- a/product_multi_image/security/ir.model.access.csv +++ b/product_multi_image/security/ir.model.access.csv @@ -1,3 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_product_image_edit,product_image edit,storage_image.model_storage_image,base.group_sale_manager,1,1,1,1 -access_product_image_file_edit,product_image file edit,storage_file.model_storage_file,base.group_sale_manager,1,1,1,1 +access_product_image_edit,product_image edit,storage_image.model_storage_image,product.group_mrp_properties,1,1,1,1 +access_product_image_file_edit,product_image file edit,storage_file.model_storage_file,product.group_mrp_properties,1,1,1,1 diff --git a/product_multi_image/security/ir.rule.csv b/product_multi_image/security/ir.rule.csv index 9aea937c02a..0eab59914d6 100644 --- a/product_multi_image/security/ir.rule.csv +++ b/product_multi_image/security/ir.rule.csv @@ -1,3 +1,3 @@ id,name,model_id:id,groups:id,perm_read,perm_write,perm_create,perm_unlink,domain_force -access_product_image_retrict_edit,Product image restrict edit,storage_image.model_storage_image,base.group_sale_manager,True,True,True,True,"[('res_model','=', 'product.template')]" -access_product_image_file_retrict_edit,Product image file restrict edit,storage_file.model_storage_file,base.group_sale_manager,True,True,True,True,"[('res_model','=', 'product.template')]" +access_product_image_retrict_edit,Product image restrict edit,storage_image.model_storage_image,product.group_mrp_properties,True,True,True,True,"[('res_model','=', 'product.template')]" +access_product_image_file_retrict_edit,Product image file restrict edit,storage_file.model_storage_file,product.group_mrp_properties,True,True,True,True,"[('res_model','=', 'product.template')]" diff --git a/product_multi_image/views/image_view.xml b/product_multi_image/views/image_view.xml index 4ebd416b539..fb6e56002d9 100644 --- a/product_multi_image/views/image_view.xml +++ b/product_multi_image/views/image_view.xml @@ -1,50 +1,48 @@ - - + - - Multi image form - storage.image - - primary - - - - - - + + Multi image form + storage.image + + primary + + + + + + - - Product multi image kanban - storage.image - - primary - - - - - - - - - - Visible in all variants - - - Visible in variant(s) - - - - - - + + Product multi image kanban + storage.image + + primary + + + + + + + + + + Visible in all variants + + + Visible in variant(s) + + + + + + - - + diff --git a/product_multi_image/views/product_product_view.xml b/product_multi_image/views/product_product_view.xml index 9636d98e0ed..dc6ecf18001 100644 --- a/product_multi_image/views/product_product_view.xml +++ b/product_multi_image/views/product_product_view.xml @@ -2,19 +2,21 @@ - - + + - product.product - - - - - - - - + product.product + + + + +
+
+ +
+
+
-
-
+ + diff --git a/product_multi_image/views/product_template_view.xml b/product_multi_image/views/product_template_view.xml index 2da5957d3c4..c577c8790a9 100644 --- a/product_multi_image/views/product_template_view.xml +++ b/product_multi_image/views/product_template_view.xml @@ -2,44 +2,45 @@ - - + - - Add multi images - product.template - - - - - - - - - - - - + + Add multi images + product.template + + + + + + + + + + + + - - product.template - - - - - - - - - - - - + + product.template + + + + + +
+
+ +
+
+
+
+ +