From 81e28432a4ccd13f7563e010c6587c02f794a199 Mon Sep 17 00:00:00 2001 From: xavierjimenez Date: Thu, 28 Jun 2018 09:10:09 +0200 Subject: [PATCH] [MIG][11.0] stock_inventory_preparation_filter --- stock_inventory_preparation_filter/README.rst | 77 +++- .../__init__.py | 1 - .../__manifest__.py | 5 +- .../models/__init__.py | 1 - .../models/stock_inventory.py | 9 +- .../readme/CONTRIBUTORS.rst | 7 + .../readme/DESCRIPTION.rst | 8 + .../static/description/index.html | 433 ++++++++++++++++++ .../tests/__init__.py | 1 - ...test_stock_inventory_preparation_filter.py | 26 +- .../views/stock_inventory_view.xml | 29 +- 11 files changed, 535 insertions(+), 62 deletions(-) create mode 100644 stock_inventory_preparation_filter/readme/CONTRIBUTORS.rst create mode 100644 stock_inventory_preparation_filter/readme/DESCRIPTION.rst create mode 100644 stock_inventory_preparation_filter/static/description/index.html diff --git a/stock_inventory_preparation_filter/README.rst b/stock_inventory_preparation_filter/README.rst index bae4ea0c8..b1751fbeb 100644 --- a/stock_inventory_preparation_filter/README.rst +++ b/stock_inventory_preparation_filter/README.rst @@ -1,10 +1,29 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 +====================================== +Extended Inventory Preparation Filters +====================================== -======================================== -More preparation filters for inventories -======================================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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_inventory_preparation_filter + :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_inventory_preparation_filter + :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 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| Includes more options for making an inventory out of: @@ -15,42 +34,54 @@ Includes more options for making an inventory out of: It also allows to make an inventory based on scanned products, adding a line with product code and quantity. -Usage -===== +**Table of contents** -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/10.0 +.. contents:: + :local: 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 smash it by providing detailed and welcomed feedback. +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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* AvanzOSC +* Tecnativa + Contributors ------------- +~~~~~~~~~~~~ * Oihane Crucelaegui -* Pedro M. Baeza -* David Vidal +* `Tecnativa `__: -Maintainer ----------- + * Pedro M. Baeza + * David Vidal + +* Xavier Jimenez + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +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_inventory_preparation_filter/__init__.py b/stock_inventory_preparation_filter/__init__.py index 21ff7c22f..a9e337226 100644 --- a/stock_inventory_preparation_filter/__init__.py +++ b/stock_inventory_preparation_filter/__init__.py @@ -1,3 +1,2 @@ -# -*- encoding: utf-8 -*- from . import models diff --git a/stock_inventory_preparation_filter/__manifest__.py b/stock_inventory_preparation_filter/__manifest__.py index 56366872b..686e4adf8 100644 --- a/stock_inventory_preparation_filter/__manifest__.py +++ b/stock_inventory_preparation_filter/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 AvanzOSC - Oihane Crucelaegi # Copyright 2015 Tecnativa - Pedro M. Baeza # Copyright 2017 Tecnativa - David Vidal @@ -6,7 +5,7 @@ { "name": "Extended Inventory Preparation Filters", - "version": "10.0.1.0.0", + "version": "11.0.1.0.0", "depends": [ "stock", ], @@ -14,7 +13,7 @@ "Tecnativa," "Odoo Community Association (OCA)", "category": "Inventory, Logistic, Storage", - "website": "http://github.com/OCA/stock-logistics-workflow", + "website": "http://github.com/OCA/stock-logistics-warehouse", "summary": "More filters for inventory adjustments", "data": [ "views/stock_inventory_view.xml", diff --git a/stock_inventory_preparation_filter/models/__init__.py b/stock_inventory_preparation_filter/models/__init__.py index 9525632ba..5f81629c4 100644 --- a/stock_inventory_preparation_filter/models/__init__.py +++ b/stock_inventory_preparation_filter/models/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from . import stock_inventory diff --git a/stock_inventory_preparation_filter/models/stock_inventory.py b/stock_inventory_preparation_filter/models/stock_inventory.py index 9bfe2dfff..3e2efbf85 100644 --- a/stock_inventory_preparation_filter/models/stock_inventory.py +++ b/stock_inventory_preparation_filter/models/stock_inventory.py @@ -1,9 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright 2015 AvanzOSC - Oihane Crucelaegi # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models +from odoo.addons import decimal_precision as dp class StockInventoryEmptyLines(models.Model): @@ -17,6 +17,7 @@ class StockInventoryEmptyLines(models.Model): string='Quantity', required=True, default=1.0, + digits=dp.get_precision('Product Unit of Measure'), ) inventory_id = fields.Many2one( comodel_name='stock.inventory', @@ -64,7 +65,7 @@ class StockInventory(models.Model): self.ensure_one() vals = [] product_obj = self.env['product.product'] - inventory = self.new(self._convert_to_write(self._cache)) + inventory = self.new(self._convert_to_write(self.read()[0])) if self.filter in ('categories', 'products'): if self.filter == 'categories': products = product_obj.search([ @@ -90,6 +91,8 @@ class StockInventory(models.Model): tmp_lines[line.product_code] += line.product_qty self.empty_line_ids.unlink() inventory.filter = 'product' + # HACK: Make sure location is preserved + inventory.location_id = self.location_id for product_code in tmp_lines.keys(): product = product_obj.search([ '|', @@ -111,5 +114,5 @@ class StockInventory(models.Model): }] vals += values else: - vals = super(StockInventory, self)._get_inventory_lines_values() + vals = super()._get_inventory_lines_values() return vals diff --git a/stock_inventory_preparation_filter/readme/CONTRIBUTORS.rst b/stock_inventory_preparation_filter/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..74d17e3f1 --- /dev/null +++ b/stock_inventory_preparation_filter/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Oihane Crucelaegui +* `Tecnativa `__: + + * Pedro M. Baeza + * David Vidal + +* Xavier Jimenez diff --git a/stock_inventory_preparation_filter/readme/DESCRIPTION.rst b/stock_inventory_preparation_filter/readme/DESCRIPTION.rst new file mode 100644 index 000000000..7eb4d0bf4 --- /dev/null +++ b/stock_inventory_preparation_filter/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +Includes more options for making an inventory out of: + +* Multiple products. +* Products of a category. +* Multiple lots + +It also allows to make an inventory based on scanned products, adding a line +with product code and quantity. diff --git a/stock_inventory_preparation_filter/static/description/index.html b/stock_inventory_preparation_filter/static/description/index.html new file mode 100644 index 000000000..4d4293fb3 --- /dev/null +++ b/stock_inventory_preparation_filter/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Extended Inventory Preparation Filters + + + +
+

Extended Inventory Preparation Filters

+ + +

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

+

Includes more options for making an inventory out of:

+
    +
  • Multiple products.
  • +
  • Products of a category.
  • +
  • Multiple lots
  • +
+

It also allows to make an inventory based on scanned products, adding a line +with product code and quantity.

+

Table of contents

+ +
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • AvanzOSC
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/stock_inventory_preparation_filter/tests/__init__.py b/stock_inventory_preparation_filter/tests/__init__.py index 9c3a513b0..76616c897 100644 --- a/stock_inventory_preparation_filter/tests/__init__.py +++ b/stock_inventory_preparation_filter/tests/__init__.py @@ -1,3 +1,2 @@ -# -*- encoding: utf-8 -*- from . import test_stock_inventory_preparation_filter diff --git a/stock_inventory_preparation_filter/tests/test_stock_inventory_preparation_filter.py b/stock_inventory_preparation_filter/tests/test_stock_inventory_preparation_filter.py index 3c1e483a2..be71c984a 100644 --- a/stock_inventory_preparation_filter/tests/test_stock_inventory_preparation_filter.py +++ b/stock_inventory_preparation_filter/tests/test_stock_inventory_preparation_filter.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 AvanzOSC - Oihane Crucelaegi # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -9,18 +8,15 @@ from odoo.tests import common @common.at_install(False) @common.post_install(True) class TestStockInventoryPreparationFilterCategories(common.TransactionCase): - def setUp(self): super(TestStockInventoryPreparationFilterCategories, self).setUp() self.inventory_model = self.env['stock.inventory'] # Create some categories self.category = self.env['product.category'].create({ 'name': 'Category for inventory', - 'type': 'normal', }) self.category2 = self.env['product.category'].create({ 'name': 'Category for inventory 2', - 'type': 'normal', }) # Create some products in the category self.product1 = self.env['product.product'].create({ @@ -96,7 +92,7 @@ class TestStockInventoryPreparationFilterCategories(common.TransactionCase): 'location_id': self.location.id, 'categ_ids': [(6, 0, [self.category.id])], }) - inventory.prepare_inventory() + inventory.action_start() self.assertEqual(len(inventory.line_ids), 2) line1 = inventory.line_ids[0] self.assertEqual(line1.product_id, self.product1) @@ -108,15 +104,13 @@ class TestStockInventoryPreparationFilterCategories(common.TransactionCase): self.assertEqual(line2.location_id, self.location) def test_inventory_products_filter(self): - inventory = self.inventory_model.create( - { - 'name': 'Products inventory', - 'filter': 'products', - 'location_id': self.location.id, - 'product_ids': [(6, 0, [self.product1.id, self.product2.id])], - } - ) - inventory.prepare_inventory() + inventory = self.inventory_model.create({ + 'name': 'Products inventory', + 'filter': 'products', + 'location_id': self.location.id, + 'product_ids': [(6, 0, [self.product1.id, self.product2.id])], + }) + inventory.action_start() self.assertEqual(len(inventory.line_ids), 2) line1 = inventory.line_ids[0] self.assertEqual(line1.product_id, self.product1) @@ -136,7 +130,7 @@ class TestStockInventoryPreparationFilterCategories(common.TransactionCase): 'lot_ids': [(6, 0, [self.lot.id, ])], } ) - inventory.prepare_inventory() + inventory.action_start() self.assertEqual(len(inventory.line_ids), 1) line1 = inventory.line_ids[0] self.assertEqual(line1.product_id, self.product_lot) @@ -168,7 +162,7 @@ class TestStockInventoryPreparationFilterCategories(common.TransactionCase): }), ], }) - inventory.prepare_inventory() + inventory.action_start() self.assertEqual(len(inventory.line_ids), 3) line1 = inventory.line_ids[0] self.assertEqual(line1.product_id, self.product1) diff --git a/stock_inventory_preparation_filter/views/stock_inventory_view.xml b/stock_inventory_preparation_filter/views/stock_inventory_view.xml index a00af66fc..40468dc80 100644 --- a/stock_inventory_preparation_filter/views/stock_inventory_view.xml +++ b/stock_inventory_preparation_filter/views/stock_inventory_view.xml @@ -10,22 +10,23 @@ - + {'invisible':[('state','=','draft')]} - - - - - - - + + + + + + + + +