diff --git a/stock_secondary_unit/README.rst b/stock_secondary_unit/README.rst index c97b74b79..4fc4c5c55 100644 --- a/stock_secondary_unit/README.rst +++ b/stock_secondary_unit/README.rst @@ -14,13 +14,13 @@ Stock Secondary Unit :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github - :target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_secondary_unit + :target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_secondary_unit :alt: OCA/stock-logistics-warehouse .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-11-0/stock-logistics-warehouse-11-0-stock_secondary_unit + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_secondary_unit :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/153/11.0 + :target: https://runbot.odoo-community.org/runbot/153/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -51,7 +51,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -68,6 +68,7 @@ Contributors * Carlos Dauden * Sergio Teruel +* Kitti Upariphutthiphong Maintainers ~~~~~~~~~~~ @@ -82,6 +83,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_secondary_unit/__manifest__.py b/stock_secondary_unit/__manifest__.py index d2d65f53a..6c6c66b3d 100644 --- a/stock_secondary_unit/__manifest__.py +++ b/stock_secondary_unit/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Stock Secondary Unit', 'summary': 'Get product quantities in a secondary unit', - 'version': '11.0.1.0.0', + 'version': '12.0.1.0.0', 'development_status': 'Beta', 'category': 'stock', 'website': 'https://github.com/OCA/stock-logistics-warehouse', diff --git a/stock_secondary_unit/models/product.py b/stock_secondary_unit/models/product.py index 49efefb03..46fa07283 100644 --- a/stock_secondary_unit/models/product.py +++ b/stock_secondary_unit/models/product.py @@ -7,6 +7,7 @@ from odoo.tools.float_utils import float_round class StockProductSecondaryUnit(models.AbstractModel): _name = 'stock.product.secondary.unit' + _description = 'Stock Product Secondary Unit' secondary_unit_qty_available = fields.Float( string='Quantity On Hand (2Unit)', diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py index dcb5d6156..13b553d97 100644 --- a/stock_secondary_unit/models/stock_move.py +++ b/stock_secondary_unit/models/stock_move.py @@ -7,6 +7,7 @@ from odoo.tools.float_utils import float_round class StockSecondaryUnitMixin(models.AbstractModel): _name = 'stock.secondary.unit.mixin' + _description = 'Stock Secondary Unit Mixin' secondary_uom_id = fields.Many2one( comodel_name='product.secondary.unit', @@ -36,7 +37,7 @@ class StockMoveLine(models.Model): def create(self, vals): move = self.env['stock.move'].browse(vals['move_id']) if move.secondary_uom_id: - uom = self.env['product.uom'].browse(vals['product_uom_id']) + uom = self.env['uom.uom'].browse(vals['product_uom_id']) factor = move.secondary_uom_id.factor * uom.factor move_line_qty = vals.get( 'product_uom_qty', vals.get('qty_done', 0.0)) diff --git a/stock_secondary_unit/readme/CONTRIBUTORS.rst b/stock_secondary_unit/readme/CONTRIBUTORS.rst index b919cb776..3b07d85d5 100644 --- a/stock_secondary_unit/readme/CONTRIBUTORS.rst +++ b/stock_secondary_unit/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Carlos Dauden * Sergio Teruel +* Kitti Upariphutthiphong diff --git a/stock_secondary_unit/static/description/index.html b/stock_secondary_unit/static/description/index.html index 65a1255be..d6d5885d2 100644 --- a/stock_secondary_unit/static/description/index.html +++ b/stock_secondary_unit/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

This module extends the functionality of stock module to allow define other units with their conversion factor.

Table of contents

@@ -400,7 +400,7 @@ other units with their conversion factor.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -416,6 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
@@ -425,7 +426,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

+

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/stock_secondary_unit/tests/test_stock_secondary_unit.py b/stock_secondary_unit/tests/test_stock_secondary_unit.py index 4dfd737d6..d62b553f9 100644 --- a/stock_secondary_unit/tests/test_stock_secondary_unit.py +++ b/stock_secondary_unit/tests/test_stock_secondary_unit.py @@ -11,8 +11,8 @@ class TestProductSecondaryUnit(SavepointCase): def setUpClass(cls): super().setUpClass() cls.warehouse = cls.env.ref('stock.warehouse0') - cls.product_uom_kg = cls.env.ref('product.product_uom_kgm') - cls.product_uom_unit = cls.env.ref('product.product_uom_unit') + cls.product_uom_kg = cls.env.ref('uom.product_uom_kgm') + cls.product_uom_unit = cls.env.ref('uom.product_uom_unit') ProductAttribute = cls.env['product.attribute'] ProductAttributeValue = cls.env['product.attribute.value'] cls.attribute_color = ProductAttribute.create({'name': 'test_color'}) @@ -24,7 +24,6 @@ class TestProductSecondaryUnit(SavepointCase): 'name': 'test_black', 'attribute_id': cls.attribute_color.id, }) - Product = cls.env['product.product'] cls.product_template = cls.env['product.template'].create({ 'name': 'test', 'uom_id': cls.product_uom_kg.id, @@ -46,16 +45,10 @@ class TestProductSecondaryUnit(SavepointCase): ], 'attribute_line_ids': [(0, 0, { 'attribute_id': cls.attribute_color.id, + 'value_ids': [(4, cls.attribute_value_white.id), + (4, cls.attribute_value_black.id)], })], }) - cls.product_white = Product.create({ - 'product_tmpl_id': cls.product_template.id, - 'attribute_value_ids': [(6, 0, [cls.attribute_value_white.id])], - }) - cls.product_black = Product.create({ - 'product_tmpl_id': cls.product_template.id, - 'attribute_value_ids': [(6, 0, [cls.attribute_value_black.id])], - }) secondary_unit = cls.env['product.secondary.unit'].search([ ('product_tmpl_id', '=', cls.product_template.id), ], limit=1) @@ -65,21 +58,55 @@ class TestProductSecondaryUnit(SavepointCase): }) StockQuant = cls.env['stock.quant'] cls.quant_white = StockQuant.create({ - 'product_id': cls.product_white.id, + 'product_id': cls.product_template.product_variant_ids[0].id, 'location_id': cls.warehouse.lot_stock_id.id, 'quantity': 10.0, }) cls.quant_black = StockQuant.create({ - 'product_id': cls.product_black.id, + 'product_id': cls.product_template.product_variant_ids[1].id, 'location_id': cls.warehouse.lot_stock_id.id, 'quantity': 10.0, }) - def test_stock_secondary_unit_template(self): + def test_01_stock_secondary_unit_template(self): self.assertEqual( self.product_template.secondary_unit_qty_available, 40.0) - def test_stock_secondary_unit_variant(self): + def test_02_stock_secondary_unit_variant(self): for variant in self.product_template.product_variant_ids.filtered( 'attribute_value_ids'): self.assertEqual(variant.secondary_unit_qty_available, 20) + + def test_03_stock_picking_secondary_unit(self): + StockPicking = self.env['stock.picking'] + product1 = self.product_template.product_variant_ids[0] + location = self.env.ref('stock.stock_location_suppliers') + location_dest = self.env.ref('stock.stock_location_stock') + picking_type = self.env.ref('stock.picking_type_in') + move_vals = { + 'product_id': product1.id, + 'name': product1.display_name, + 'secondary_uom_id': product1.secondary_uom_ids[0].id, + 'product_uom': product1.uom_id.id, + 'product_uom_qty': 10.0, + 'location_id': location.id, + 'location_dest_id': location_dest.id, + } + do_vals = { + 'location_id': location.id, + 'location_dest_id': location_dest.id, + 'picking_type_id': picking_type.id, + 'move_ids_without_package': [(0, None, move_vals), + (0, None, move_vals)], # 2 moves + } + delivery_order = StockPicking.create(do_vals) + delivery_order.action_confirm() + # Move is merged into 1 line for both stock.move and stock.move.line + self.assertEquals(len(delivery_order.move_lines), 1) + self.assertEquals(len(delivery_order.move_line_ids), 1) + # Qty merged to 20, and secondary unit qty is 40line + uom_qty = sum(delivery_order.move_lines.mapped('product_uom_qty')) + secondary_uom_qty = \ + sum(delivery_order.move_line_ids.mapped('secondary_uom_qty')) + self.assertEquals(uom_qty, 20.0) + self.assertEquals(secondary_uom_qty, 40.0) diff --git a/stock_secondary_unit/views/product_views.xml b/stock_secondary_unit/views/product_views.xml index 8b14bc6da..fc24552f0 100755 --- a/stock_secondary_unit/views/product_views.xml +++ b/stock_secondary_unit/views/product_views.xml @@ -7,7 +7,7 @@ Product template Secondary Unit product.template - + @@ -23,7 +23,7 @@ product.template - +