From e48574cf3b348ff2dda6039b15616a634b5a376b Mon Sep 17 00:00:00 2001 From: cubells Date: Mon, 12 Nov 2018 07:24:02 +0100 Subject: [PATCH] [MIG] stock_quant_manual_assign: Migration to 11.0 --- stock_quant_manual_assign/README.rst | 72 ++- stock_quant_manual_assign/__init__.py | 4 - stock_quant_manual_assign/__manifest__.py | 1 - .../readme/CONTRIBUTORS.rst | 8 + .../readme/DESCRIPTION.rst | 1 + stock_quant_manual_assign/readme/USAGE.rst | 5 + .../static/description/index.html | 440 ++++++++++++++++++ stock_quant_manual_assign/tests/__init__.py | 4 - .../tests/test_stock_quant_manual_assign.py | 13 +- stock_quant_manual_assign/wizard/__init__.py | 4 - .../wizard/assign_manual_quants.py | 42 +- .../wizard/assign_manual_quants_view.xml | 4 +- 12 files changed, 538 insertions(+), 60 deletions(-) create mode 100644 stock_quant_manual_assign/readme/CONTRIBUTORS.rst create mode 100644 stock_quant_manual_assign/readme/DESCRIPTION.rst create mode 100644 stock_quant_manual_assign/readme/USAGE.rst create mode 100644 stock_quant_manual_assign/static/description/index.html diff --git a/stock_quant_manual_assign/README.rst b/stock_quant_manual_assign/README.rst index 951dfa082..06840b0a1 100644 --- a/stock_quant_manual_assign/README.rst +++ b/stock_quant_manual_assign/README.rst @@ -1,13 +1,37 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - =============================== Stock - Manual Quant Assignment =============================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_quant_manual_assign + :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_quant_manual_assign + :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| + This module allows you to manually change the automatic quant selection. +**Table of contents** + +.. contents:: + :local: + Usage ===== @@ -17,46 +41,52 @@ To use this module, you need to: #. Open the wizard with the button "Manual Quants". #. Select the quants to assign (reserve), then Confirm. -.. 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/11.0 - 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. +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 ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* AvanzOSC +* Tecnativa +* Eficent +* Fanha Giang Contributors ------------- +~~~~~~~~~~~~ * Mikel Arregi * Pedro M. Baeza * Ana Juaristi * Oihane Crucelaegui * Fanha Giang +* `Tecnativa `_: -Maintainer ----------- + * Vicent Cubells + +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_quant_manual_assign/__init__.py b/stock_quant_manual_assign/__init__.py index cc3cf15e7..40272379f 100644 --- a/stock_quant_manual_assign/__init__.py +++ b/stock_quant_manual_assign/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## from . import wizard diff --git a/stock_quant_manual_assign/__manifest__.py b/stock_quant_manual_assign/__manifest__.py index 733228d53..a442a715d 100644 --- a/stock_quant_manual_assign/__manifest__.py +++ b/stock_quant_manual_assign/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Mikel Arregi - AvanzOSC # Copyright 2016 Tecnativa - Pedro M. Baeza # Copyright 2017 Eficent - Jordi Ballester diff --git a/stock_quant_manual_assign/readme/CONTRIBUTORS.rst b/stock_quant_manual_assign/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..c551e9c6b --- /dev/null +++ b/stock_quant_manual_assign/readme/CONTRIBUTORS.rst @@ -0,0 +1,8 @@ +* Mikel Arregi +* Pedro M. Baeza +* Ana Juaristi +* Oihane Crucelaegui +* Fanha Giang +* `Tecnativa `_: + + * Vicent Cubells diff --git a/stock_quant_manual_assign/readme/DESCRIPTION.rst b/stock_quant_manual_assign/readme/DESCRIPTION.rst new file mode 100644 index 000000000..59ef2218c --- /dev/null +++ b/stock_quant_manual_assign/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows you to manually change the automatic quant selection. diff --git a/stock_quant_manual_assign/readme/USAGE.rst b/stock_quant_manual_assign/readme/USAGE.rst new file mode 100644 index 000000000..433722ecd --- /dev/null +++ b/stock_quant_manual_assign/readme/USAGE.rst @@ -0,0 +1,5 @@ +To use this module, you need to: + +#. Click on the tags icon at the end of move line. +#. Open the wizard with the button "Manual Quants". +#. Select the quants to assign (reserve), then Confirm. diff --git a/stock_quant_manual_assign/static/description/index.html b/stock_quant_manual_assign/static/description/index.html new file mode 100644 index 000000000..4b73bcd24 --- /dev/null +++ b/stock_quant_manual_assign/static/description/index.html @@ -0,0 +1,440 @@ + + + + + + +Stock - Manual Quant Assignment + + + +
+

Stock - Manual Quant Assignment

+ + +

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

+

This module allows you to manually change the automatic quant selection.

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Click on the tags icon at the end of move line.
  2. +
  3. Open the wizard with the button “Manual Quants”.
  4. +
  5. Select the quants to assign (reserve), then Confirm.
  6. +
+
+
+

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
  • +
  • Eficent
  • +
  • Fanha Giang
  • +
+
+
+

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_quant_manual_assign/tests/__init__.py b/stock_quant_manual_assign/tests/__init__.py index ba4c7dd5c..5193a99e4 100644 --- a/stock_quant_manual_assign/tests/__init__.py +++ b/stock_quant_manual_assign/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# (c) 2015 Oihane Crucelaegui - AvanzOSC -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html - from . import test_stock_quant_manual_assign diff --git a/stock_quant_manual_assign/tests/test_stock_quant_manual_assign.py b/stock_quant_manual_assign/tests/test_stock_quant_manual_assign.py index 2fdd0270e..f73494d54 100644 --- a/stock_quant_manual_assign/tests/test_stock_quant_manual_assign.py +++ b/stock_quant_manual_assign/tests/test_stock_quant_manual_assign.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- -# (c) 2015 Oihane Crucelaegui - AvanzOSC +# Copyright 2015 Oihane Crucelaegui - AvanzOSC # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo.tests.common import TransactionCase -from odoo import exceptions +from odoo.exceptions import ValidationError class TestStockQuantManualAssign(TransactionCase): @@ -58,6 +57,8 @@ class TestStockQuantManualAssign(TransactionCase): 'None of the quants must have been selected') self.assertEqual(wizard.lines_qty, 0.0, 'None selected must give 0') + self.assertEqual(sum(line.qty for line in wizard.quants_lines), + self.move.reserved_availability) self.assertEqual(wizard.move_qty, self.move.product_uom_qty) def test_quant_assign_wizard_constraint(self): @@ -70,7 +71,7 @@ class TestStockQuantManualAssign(TransactionCase): 'None of the quants must have been selected') self.assertEqual(wizard.lines_qty, 0.0, 'None selected must give 0') - with self.assertRaises(exceptions.ValidationError): + with self.assertRaises(ValidationError): wizard.write({'quants_lines': [(1, wizard.quants_lines[:1].id, {'selected': True, 'qty': 500})]}) @@ -91,6 +92,8 @@ class TestStockQuantManualAssign(TransactionCase): self.assertEqual(wizard.lines_qty, 150.0) self.assertEqual(wizard.move_qty, 250.0) wizard.assign_quants() + self.assertAlmostEqual(len(self.move.move_line_ids), + len(wizard.quants_lines.filtered('selected'))) def test_quant_assign_wizard_after_availability_check(self): self.move._action_assign() @@ -105,3 +108,5 @@ class TestStockQuantManualAssign(TransactionCase): self.assertEqual(wizard.move_qty, 100.0) self.assertEqual(len(wizard.quants_lines.filtered('selected')), len(self.move.move_line_ids)) + self.assertEqual(sum(line.qty for line in wizard.quants_lines), + self.move.reserved_availability) diff --git a/stock_quant_manual_assign/wizard/__init__.py b/stock_quant_manual_assign/wizard/__init__.py index a7dec37e7..781c26d93 100644 --- a/stock_quant_manual_assign/wizard/__init__.py +++ b/stock_quant_manual_assign/wizard/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -############################################################################## -# For copyright and license notices, see __openerp__.py file in root directory -############################################################################## from . import assign_manual_quants diff --git a/stock_quant_manual_assign/wizard/assign_manual_quants.py b/stock_quant_manual_assign/wizard/assign_manual_quants.py index cf3bf55e3..b31dfbcab 100644 --- a/stock_quant_manual_assign/wizard/assign_manual_quants.py +++ b/stock_quant_manual_assign/wizard/assign_manual_quants.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# (c) 2015 Mikel Arregi - AvanzOSC -# (c) 2015 Oihane Crucelaegui - AvanzOSC +# Copyright 2015 Mikel Arregi - AvanzOSC +# Copyright 2015 Oihane Crucelaegui - AvanzOSC # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo import _, api, fields, models @@ -14,7 +13,7 @@ class AssignManualQuants(models.TransientModel): @api.multi @api.constrains('quants_lines') - def check_qty(self): + def _check_qty(self): precision_digits = self.env[ 'decimal.precision'].precision_get('Product Unit of Measure') move = self.env['stock.move'].browse(self.env.context['active_id']) @@ -27,7 +26,6 @@ class AssignManualQuants(models.TransientModel): @api.depends('quants_lines', 'quants_lines.qty') def _compute_qties(self): move = self.env['stock.move'].browse(self.env.context['active_id']) - lines_qty = sum(quant_line.qty for quant_line in self.quants_lines if quant_line.selected) self.lines_qty = lines_qty @@ -40,11 +38,15 @@ class AssignManualQuants(models.TransientModel): digits=dp.get_precision('Product Unit of Measure')) quants_lines = fields.One2many('assign.manual.quants.lines', 'assign_wizard', string='Quants') + move_id = fields.Many2one( + comodel_name='stock.move', + string='Move', + ) @api.multi def assign_quants(self): quant = self.env['stock.quant'] - move = self.env['stock.move'].browse(self.env.context['active_id']) + move = self.move_id move._do_unreserve() precision_digits = self.env[ 'decimal.precision'].precision_get('Product Unit of Measure') @@ -53,14 +55,15 @@ class AssignManualQuants(models.TransientModel): precision_digits=precision_digits) > 0: available_quantity = quant._get_available_quantity( move.product_id, - move.location_id, + line.location_id, lot_id=line.lot_id) if float_compare(available_quantity, 0.0, precision_digits=precision_digits) <= 0: continue move._update_reserved_quantity(line.qty, available_quantity, - move.location_id, + line.location_id, lot_id=line.lot_id, strict=True) + if move.has_move_lines: for ml in move.move_line_ids: ml.qty_done = ml.product_qty @@ -77,28 +80,27 @@ class AssignManualQuants(models.TransientModel): ('product_id', '=', move.product_id.id), ('quantity', '>', 0) ]) - quants_lines = [] - for x in available_quants: + for quant in available_quants: line = {} - line['quant'] = x.id - line['lot_id'] = x.lot_id.id - line['on_hand'] = x.quantity - line['in_date'] = x.in_date - line['package_id'] = x.package_id.id + line['quant'] = quant.id + line['lot_id'] = quant.lot_id.id + line['on_hand'] = quant.quantity + line['in_date'] = quant.in_date + line['package_id'] = quant.package_id.id line['selected'] = False line['qty'] = 0 move_lines = move.move_line_ids.filtered( lambda ml: - ml.location_id == x.location_id and ml.lot_id == x.lot_id) + ml.location_id == quant.location_id and + ml.lot_id == quant.lot_id) for ml in move_lines: line['qty'] = line['qty'] + ml.ordered_qty line['selected'] = True - line['reserved'] = x.reserved_quantity - line['qty'] - line['location_id'] = x.location_id.id + line['reserved'] = quant.reserved_quantity - line['qty'] + line['location_id'] = quant.location_id.id quants_lines.append(line) - - res.update({'quants_lines': quants_lines}) + res.update({'quants_lines': quants_lines, 'move_id': move.id}) res = self._convert_to_write(self._convert_to_cache(res)) return res diff --git a/stock_quant_manual_assign/wizard/assign_manual_quants_view.xml b/stock_quant_manual_assign/wizard/assign_manual_quants_view.xml index 9620f771f..f4f44342b 100644 --- a/stock_quant_manual_assign/wizard/assign_manual_quants_view.xml +++ b/stock_quant_manual_assign/wizard/assign_manual_quants_view.xml @@ -13,8 +13,8 @@ - - + +