diff --git a/product_create_stock_picking/__manifest__.py b/product_create_stock_picking/__manifest__.py index ff02431..37b527a 100644 --- a/product_create_stock_picking/__manifest__.py +++ b/product_create_stock_picking/__manifest__.py @@ -2,7 +2,7 @@ 'name': 'Product Create Stock Picking', 'category': 'Warehouse', 'summary': 'Add an action to create a stock picking from a selection of products.', - 'version': "16.0.1.0.0", + 'version': '12.0.0.0.1', 'description': """ Add an action to create a stock picking from a selection of products. diff --git a/product_create_stock_picking/models/product_template.py b/product_create_stock_picking/models/product_template.py index 9b8c8e9..fc6609b 100644 --- a/product_create_stock_picking/models/product_template.py +++ b/product_create_stock_picking/models/product_template.py @@ -11,6 +11,7 @@ from odoo import tools, models, fields, api, _ class ProductTemplate(models.Model): _inherit = "product.template" + @api.multi def create_stock_picking(self): picking_vals = self.env['stock.picking'].default_get(self.env['stock.picking']._fields.keys()) picking_vals.update({ diff --git a/product_library/__manifest__.py b/product_library/__manifest__.py index fc8ce0b..e4f7ce9 100644 --- a/product_library/__manifest__.py +++ b/product_library/__manifest__.py @@ -2,7 +2,7 @@ 'name': 'Product Library', 'category': 'Product', 'summary': 'Add library related fields to product', - 'version': "16.0.1.0.0", + 'version': '12.0.1.0.2', 'description': """ Addon mejora de Odoo para librerías y tiendas de discos diff --git a/product_library/models/product_product.py b/product_library/models/product_product.py index c584498..0cb6f82 100644 --- a/product_library/models/product_product.py +++ b/product_library/models/product_product.py @@ -10,6 +10,7 @@ from odoo import models, fields, api class ProductProduct(models.Model): _inherit = 'product.product' + @api.multi @api.depends('image') def _compute_has_image(self): for product in self: diff --git a/product_library/models/product_template.py b/product_library/models/product_template.py index 59ca65d..4719c0a 100644 --- a/product_library/models/product_template.py +++ b/product_library/models/product_template.py @@ -11,16 +11,16 @@ _logger = logging.getLogger(__name__) class ProductTemplate(models.Model): _inherit = "product.template" - subtitle = fields.Char('Subtitulo') + subtitle = fields.Char('Subtítulo') editorial = fields.Char('Editorial') formato = fields.Char('Formato') - pais_edicion = fields.Char('Pais de edicion') - colacion = fields.Char('Colacion') + pais_edicion = fields.Char('País de Edicion') + colacion = fields.Char('Colación') autor = fields.Char('Autor') isbn = fields.Char('ISBN') - coleccion = fields.Char('Coleccion') - subcoleccion = fields.Char('Subcoleccion') + coleccion = fields.Char('Colección') + subcoleccion = fields.Char('Subcolección') idioma = fields.Char('Idioma') fecha_entrada = fields.Char('Fecha de entrada') fecha_edicion = fields.Char('Fecha de edición') - genero = fields.Char('Genero') + genero = fields.Char('Género') diff --git a/product_library/views/product.xml b/product_library/views/product.xml index 210c30f..938faef 100644 --- a/product_library/views/product.xml +++ b/product_library/views/product.xml @@ -1,5 +1,6 @@ - + + product.template.library.form product.template @@ -26,4 +27,5 @@ - + + diff --git a/product_retail_cm/__manifest__.py b/product_retail_cm/__manifest__.py index a1e8465..5d29d6c 100644 --- a/product_retail_cm/__manifest__.py +++ b/product_retail_cm/__manifest__.py @@ -2,7 +2,7 @@ 'name': 'Product Retail', 'category': 'Product', 'summary': 'Gestiona productos en distribución / Venta a minoristas', - 'version': "16.0.1.0.0", + 'version': '12.0.1.0.0', 'description': """ Gestiona productos en distribución / Venta a minoristas diff --git a/product_sequence/__manifest__.py b/product_sequence/__manifest__.py index 3a8c8e1..3736a23 100644 --- a/product_sequence/__manifest__.py +++ b/product_sequence/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Product Sequence', - 'version': "16.0.1.0.0", + 'version': '12.0.2.0.2', 'author': "Zikzakmedia SL,Sodexis,Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/product-attribute', 'license': 'AGPL-3', diff --git a/product_sequence/models/product_category.py b/product_sequence/models/product_category.py index 3f80e31..817f5a7 100644 --- a/product_sequence/models/product_category.py +++ b/product_sequence/models/product_category.py @@ -36,6 +36,7 @@ class ProductCategory(models.Model): } return vals + @api.multi def write(self, vals): prefix = vals.get("code_prefix") if prefix: diff --git a/product_sequence/models/product_product.py b/product_sequence/models/product_product.py index a8797a6..0c7db9c 100644 --- a/product_sequence/models/product_product.py +++ b/product_sequence/models/product_product.py @@ -13,7 +13,7 @@ class ProductProduct(models.Model): default_code = fields.Char( required=True, default='/', - tracking=True, + track_visibility='onchange', help="Set to '/' and save if you want a new internal reference " "to be proposed." ) @@ -35,6 +35,7 @@ class ProductProduct(models.Model): vals['default_code'] = sequence.next_by_id() return super().create(vals) + @api.multi def write(self, vals): """To assign a new internal reference, just write '/' on the field. Note this is up to the user, if the product category is changed, @@ -54,6 +55,7 @@ class ProductProduct(models.Model): return True return super().write(vals) + @api.multi def copy(self, default=None): if default is None: default = {} diff --git a/product_sequence/tests/__init__.py b/product_sequence/tests/__init__.py new file mode 100644 index 0000000..29b6235 --- /dev/null +++ b/product_sequence/tests/__init__.py @@ -0,0 +1 @@ +from . import test_product_sequence diff --git a/product_sequence/tests/test_product_sequence.py b/product_sequence/tests/test_product_sequence.py new file mode 100644 index 0000000..f327c7b --- /dev/null +++ b/product_sequence/tests/test_product_sequence.py @@ -0,0 +1,140 @@ +# Copyright 2016 Sodexis +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase +from ..hooks import pre_init_hook + + +class TestProductSequence(TransactionCase): + """Tests for creating product with and without Product Sequence""" + + def setUp(self): + super(TestProductSequence, self).setUp() + self.product_product = self.env['product.product'] + self.product_category = self.env['product.category'] + self.product_template = self.env['product.template'].create({ + 'name': 'Demo Product', + }) + + def test_product_create_with_default_code(self): + product = self.product_product.create(dict( + name="Apple", + default_code='PROD01' + )) + self.assertEqual(product.default_code, 'PROD01') + product_new = self.product_product.create(dict( + name="Demo Apple", + product_tmpl_id=self.product_template.id + )) + self.assertTrue(product_new.default_code) + + def test_product_create_without_default_code(self): + product_1 = self.product_product.create(dict( + name="Orange", + default_code='/')) + self.assertRegexpMatches(str(product_1.default_code), r'PR/*') + + def test_product_copy(self): + product_2 = self.product_product.create(dict( + name="Apple", + default_code='PROD02' + )) + copy_product_2 = product_2.copy() + self.assertEqual(copy_product_2.default_code, 'PROD02-copy') + + def test_pre_init_hook(self): + product_3 = self.product_product.create(dict( + name="Apple", + default_code='PROD03' + )) + sql = "update product_product set default_code='/' where id=%s" + self.cr.execute(sql, (product_3.id,)) + product_3.invalidate_cache() + self.assertEqual(product_3.default_code, '/') + pre_init_hook(self.cr) + product_3.invalidate_cache() + self.assertEqual(product_3.default_code, '!!mig!!%s' % (product_3.id,)) + + def test_product_category_sequence(self): + categ_grocery = self.product_category.create(dict( + name="Grocery", + code_prefix="GRO", + )) + self.assertTrue(categ_grocery.sequence_id) + self.assertEqual(categ_grocery.sequence_id.prefix, "GRO") + self.assertFalse(categ_grocery.sequence_id.company_id) + product_3 = self.product_product.create(dict( + name="Apple", + categ_id=categ_grocery.id, + )) + self.assertEqual(product_3.default_code[:3], "GRO") + self.assertEqual(product_3.product_tmpl_id.default_code[:3], "GRO") + categ_electronics = self.product_category.create(dict( + name="Electronics", + code_prefix="ELE", + )) + product_3.write({'default_code': '/', + 'categ_id': categ_electronics.id}) + self.assertEqual(product_3.default_code[:3], "ELE") + self.assertEqual(product_3.product_tmpl_id.default_code[:3], "ELE") + + product_4 = self.product_product.create(dict( + name="Truck", + default_code='PROD04' + )) + product_4.write({'default_code': '/'}) + self.assertTrue(product_4.categ_id, 'Category is not set.') + + categ_car = self.product_category.create(dict( + name="Car", + code_prefix="CAR", + )) + product_3.product_tmpl_id.categ_id = categ_car + product_3.product_tmpl_id.default_code = '/' + product_3.refresh() + self.assertEqual(product_3.default_code[:3], "CAR") + self.assertEqual(product_3.product_tmpl_id.default_code[:3], "CAR") + categ_car.write(dict( + name="Bike", + code_prefix="BIK", + )) + self.assertEqual(categ_car.sequence_id.prefix, "BIK") + categ_car.sequence_id = False + categ_car.write({'code_prefix': 'KIA'}) + self.assertEqual(categ_car.sequence_id.prefix, "KIA") + + def test_product_parent_category_sequence(self): + parent_categ = self.product_category.create(dict( + name="Parents", + code_prefix="PAR", + )) + categ = self.product_category.create(dict( + name="Child", + parent_id=parent_categ.id, + )) + + product_anna = self.product_product.create(dict( + name="Anna", + categ_id=categ.id, + )) + self.assertEqual(product_anna.default_code[:2], "PR") + self.assertEqual(product_anna.product_tmpl_id.default_code[:2], "PR") + + self.env.user.company_id.use_parent_categories_to_determine_prefix = True + + product_claudia = self.product_product.create(dict( + name="Claudia", + categ_id=categ.id, + )) + self.assertEqual(product_claudia.default_code[:3], "PAR") + self.assertEqual(product_claudia.product_tmpl_id.default_code[:3], "PAR") + + def test_product_copy_with_default_values(self): + product_2 = self.product_product.create(dict( + name="Apple", + default_code='PROD02' + )) + copy_product_2 = product_2.copy({ + 'default_code': 'product test sequence', + }) + self.assertEqual(copy_product_2.default_code, 'product test sequence') diff --git a/product_state/__manifest__.py b/product_state/__manifest__.py index 0e54111..ea49465 100644 --- a/product_state/__manifest__.py +++ b/product_state/__manifest__.py @@ -7,7 +7,7 @@ "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/product-attribute", "category": "Product", - "version": "16.0.1.0.0", + "version": "12.0.2.0.2", "license": "AGPL-3", "depends": ["sale", "product"], "data": [ diff --git a/product_state/migrations/12.0.2.0.0/post-migration.py b/product_state/migrations/12.0.2.0.0/post-migration.py new file mode 100644 index 0000000..541449c --- /dev/null +++ b/product_state/migrations/12.0.2.0.0/post-migration.py @@ -0,0 +1,7 @@ +# Copyright 2020 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo.addons.product_state.hooks import post_init_hook + + +def migrate(cr, version): + post_init_hook(cr, False) diff --git a/product_state/views/product_views.xml b/product_state/views/product_views.xml index 663825c..5967949 100644 --- a/product_state/views/product_views.xml +++ b/product_state/views/product_views.xml @@ -129,6 +129,7 @@ State product.state + form kanban,form,tree - + Depósito Salidas @@ -21,7 +21,7 @@ - + Depósitos Entradas diff --git a/stock_picking_deposito/models/res_partner.py b/stock_picking_deposito/models/res_partner.py index 935296d..e271dd2 100644 --- a/stock_picking_deposito/models/res_partner.py +++ b/stock_picking_deposito/models/res_partner.py @@ -55,6 +55,7 @@ class ResPartner(models.Model): }).id return super().create(vals) + @api.multi def write(self, vals): if ( vals.get('deposit_sale_accept', False) == True ) and not self.deposit_sale_location_id: vals['deposit_sale_location_id'] = self.env['stock.location'].create({