From e415b946ca6715d1d639b853693fa99f306a784e Mon Sep 17 00:00:00 2001 From: ps-tubtim Date: Wed, 18 Dec 2019 17:13:00 +0700 Subject: [PATCH] [MIG] stock_secondary_unit: Migration to 13.0 --- stock_secondary_unit/README.rst | 11 ++++++----- stock_secondary_unit/__manifest__.py | 4 ++-- stock_secondary_unit/models/product.py | 19 +++++++++++-------- stock_secondary_unit/models/stock_move.py | 6 ++---- stock_secondary_unit/readme/CONTRIBUTORS.rst | 1 + .../report/report_deliveryslip.xml | 0 .../static/description/index.html | 7 ++++--- .../tests/test_stock_secondary_unit.py | 9 ++------- stock_secondary_unit/views/product_views.xml | 10 +++++----- .../views/stock_move_views.xml | 15 +++++++++++++++ .../views/stock_picking_views.xml | 6 ------ 11 files changed, 48 insertions(+), 40 deletions(-) mode change 100755 => 100644 stock_secondary_unit/report/report_deliveryslip.xml mode change 100755 => 100644 stock_secondary_unit/views/product_views.xml mode change 100755 => 100644 stock_secondary_unit/views/stock_move_views.xml mode change 100755 => 100644 stock_secondary_unit/views/stock_picking_views.xml diff --git a/stock_secondary_unit/README.rst b/stock_secondary_unit/README.rst index 4fc4c5c55..734b1dc78 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/12.0/stock_secondary_unit + :target: https://github.com/OCA/stock-logistics-warehouse/tree/13.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-12-0/stock-logistics-warehouse-12-0-stock_secondary_unit + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-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/12.0 + :target: https://runbot.odoo-community.org/runbot/153/13.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. @@ -69,6 +69,7 @@ Contributors * Carlos Dauden * Sergio Teruel * Kitti Upariphutthiphong +* Pimolnat Suntian Maintainers ~~~~~~~~~~~ @@ -83,6 +84,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 8754a85b8..b8837a32d 100644 --- a/stock_secondary_unit/__manifest__.py +++ b/stock_secondary_unit/__manifest__.py @@ -3,8 +3,8 @@ { "name": "Stock Secondary Unit", "summary": "Get product quantities in a secondary unit", - "version": "13.0.1.0.2", - "development_status": "Beta", + "version": "13.0.1.0.0", + "development_status": "Production/Stable", "category": "stock", "website": "https://github.com/OCA/stock-logistics-warehouse", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/stock_secondary_unit/models/product.py b/stock_secondary_unit/models/product.py index a75fc54e6..25b35cb84 100644 --- a/stock_secondary_unit/models/product.py +++ b/stock_secondary_unit/models/product.py @@ -3,8 +3,6 @@ from odoo import fields, models from odoo.tools.float_utils import float_round -from odoo.addons import decimal_precision as dp - class StockProductSecondaryUnit(models.AbstractModel): _name = "stock.product.secondary.unit" @@ -13,15 +11,20 @@ class StockProductSecondaryUnit(models.AbstractModel): secondary_unit_qty_available = fields.Float( string="Quantity On Hand (2Unit)", compute="_compute_secondary_unit_qty_available", - digits=dp.get_precision("Product Unit of Measure"), + digits="Product Unit of Measure", ) def _compute_secondary_unit_qty_available(self): - for product in self.filtered("stock_secondary_uom_id"): - qty = product.qty_available / (product.stock_secondary_uom_id.factor or 1.0) - product.secondary_unit_qty_available = float_round( - qty, precision_rounding=product.uom_id.rounding - ) + for product in self: + if not product.stock_secondary_uom_id: + product.secondary_unit_qty_available = 0.0 + else: + qty = product.qty_available / ( + product.stock_secondary_uom_id.factor or 1.0 + ) + product.secondary_unit_qty_available = float_round( + qty, precision_rounding=product.uom_id.rounding + ) class ProductTemplate(models.Model): diff --git a/stock_secondary_unit/models/stock_move.py b/stock_secondary_unit/models/stock_move.py index 3cf670d63..49821a399 100644 --- a/stock_secondary_unit/models/stock_move.py +++ b/stock_secondary_unit/models/stock_move.py @@ -3,8 +3,6 @@ from odoo import api, fields, models from odoo.tools.float_utils import float_round -from odoo.addons import decimal_precision as dp - class StockSecondaryUnitMixin(models.AbstractModel): _name = "stock.secondary.unit.mixin" @@ -14,7 +12,7 @@ class StockSecondaryUnitMixin(models.AbstractModel): comodel_name="product.secondary.unit", string="Second unit" ) secondary_uom_qty = fields.Float( - string="Secondary Qty", digits=dp.get_precision("Product Unit of Measure") + string="Secondary Qty", digits="Product Unit of Measure" ) @@ -23,7 +21,7 @@ class StockMove(models.Model): _name = "stock.move" def _merge_moves_fields(self): - res = super(StockMove, self)._merge_moves_fields() + res = super()._merge_moves_fields() res["secondary_uom_qty"] = self[-1:].secondary_uom_qty return res diff --git a/stock_secondary_unit/readme/CONTRIBUTORS.rst b/stock_secondary_unit/readme/CONTRIBUTORS.rst index 3b07d85d5..d35178a8f 100644 --- a/stock_secondary_unit/readme/CONTRIBUTORS.rst +++ b/stock_secondary_unit/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Carlos Dauden * Sergio Teruel * Kitti Upariphutthiphong +* Pimolnat Suntian diff --git a/stock_secondary_unit/report/report_deliveryslip.xml b/stock_secondary_unit/report/report_deliveryslip.xml old mode 100755 new mode 100644 diff --git a/stock_secondary_unit/static/description/index.html b/stock_secondary_unit/static/description/index.html index 057bee64f..037408bf1 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.

@@ -417,6 +417,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Carlos Dauden <carlos.dauden@tecnativa.com>
  • Sergio Teruel <sergio.teruel@tecnativa.com>
  • Kitti Upariphutthiphong <kittiu@ecosoft.co.th>
  • +
  • Pimolnat Suntian <pimolnats@ecosoft.co.th>
  • @@ -426,7 +427,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 b5b0467e1..5059a43b3 100644 --- a/stock_secondary_unit/tests/test_stock_secondary_unit.py +++ b/stock_secondary_unit/tests/test_stock_secondary_unit.py @@ -68,12 +68,7 @@ class TestProductSecondaryUnit(SavepointCase): secondary_unit = cls.env["product.secondary.unit"].search( [("product_tmpl_id", "=", cls.product_template.id)], limit=1 ) - cls.product_template.write( - { - "sale_secondary_uom_id": secondary_unit.id, - "stock_secondary_uom_id": secondary_unit.id, - } - ) + cls.product_template.write({"stock_secondary_uom_id": secondary_unit.id}) StockQuant = cls.env["stock.quant"] cls.quant_white = StockQuant.create( { @@ -95,7 +90,7 @@ class TestProductSecondaryUnit(SavepointCase): def test_02_stock_secondary_unit_variant(self): for variant in self.product_template.product_variant_ids.filtered( - "attribute_value_ids" + "product_template_attribute_value_ids" ): self.assertEqual(variant.secondary_unit_qty_available, 20) diff --git a/stock_secondary_unit/views/product_views.xml b/stock_secondary_unit/views/product_views.xml old mode 100755 new mode 100644 index fc24552f0..28441445a --- a/stock_secondary_unit/views/product_views.xml +++ b/stock_secondary_unit/views/product_views.xml @@ -45,11 +45,11 @@ ref="stock.product_form_view_procurement_button"/> - -