From eb70f0d56e9c250b00d4bf5bcdc0b8498c23940e Mon Sep 17 00:00:00 2001 From: cubells Date: Tue, 2 Oct 2018 14:01:09 +0200 Subject: [PATCH] [MIG] stock_lot_scrap: Migration to 11.0 --- stock_lot_scrap/README.rst | 84 ++-- stock_lot_scrap/__init__.py | 2 - stock_lot_scrap/__manifest__.py | 3 +- stock_lot_scrap/i18n/stock_lot_scrap.pot | 21 +- stock_lot_scrap/models/__init__.py | 2 - stock_lot_scrap/models/stock_scrap_lot.py | 18 +- stock_lot_scrap/readme/CONFIGURE.rst | 2 + stock_lot_scrap/readme/CONTRIBUTORS.rst | 6 + stock_lot_scrap/readme/DESCRIPTION.rst | 2 + stock_lot_scrap/readme/USAGE.rst | 3 + stock_lot_scrap/static/description/index.html | 421 ++++++++++++++++++ stock_lot_scrap/tests/__init__.py | 4 - stock_lot_scrap/tests/test_stock_lot_scrap.py | 6 +- 13 files changed, 526 insertions(+), 48 deletions(-) create mode 100644 stock_lot_scrap/readme/CONFIGURE.rst create mode 100644 stock_lot_scrap/readme/CONTRIBUTORS.rst create mode 100644 stock_lot_scrap/readme/DESCRIPTION.rst create mode 100644 stock_lot_scrap/readme/USAGE.rst create mode 100644 stock_lot_scrap/static/description/index.html diff --git a/stock_lot_scrap/README.rst b/stock_lot_scrap/README.rst index e4dbdef439f1..c3a56ac9c5f9 100644 --- a/stock_lot_scrap/README.rst +++ b/stock_lot_scrap/README.rst @@ -1,19 +1,43 @@ -.. 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 - -================== -Scrap Complete Lot -================== +==================== +Scrap Production Lot +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/11.0/stock_lot_scrap + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-11-0/stock-logistics-workflow-11-0-stock_lot_scrap + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/154/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module adds a button in *Production Lot/Serial Number* view form to *Scrap* all quants contained. +**Table of contents** + +.. contents:: + :local: + Configuration ============= -* Go to *Inventory > Configuration > Settings*. -* Enable *Track lots or serial numbers*. +* Go to *Inventory > Configuration > Settings > Traceability*. +* Enable *Lots & Serial Numbers*. Usage ===== @@ -22,39 +46,47 @@ Usage view form mode. * Click button *Scrap* -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/154/10.0 - Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. +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. +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 +~~~~~~~ + +* Tecnativa + Contributors ------------- -* Carlos Dauden -* Pedro M. Baeza -* David Vidal +~~~~~~~~~~~~ -Maintainer ----------- +* `Tecnativa `_: + + * Carlos Dauden + * Pedro M. Baeza + * David Vidal + * 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-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_lot_scrap/__init__.py b/stock_lot_scrap/__init__.py index cde864bae21a..0650744f6bc6 100644 --- a/stock_lot_scrap/__init__.py +++ b/stock_lot_scrap/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import models diff --git a/stock_lot_scrap/__manifest__.py b/stock_lot_scrap/__manifest__.py index 68724397ab20..995e8fe4c0e1 100644 --- a/stock_lot_scrap/__manifest__.py +++ b/stock_lot_scrap/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Carlos Dauden # Copyright 2016 Pedro M. Baeza # Copyright 2017 David Vidal @@ -7,7 +6,7 @@ 'name': 'Scrap Production Lot', 'summary': 'This module adds a button in Production Lot/Serial Number ' 'view form to Scrap all products contained.', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Stock', 'license': 'AGPL-3', 'author': 'Tecnativa,' diff --git a/stock_lot_scrap/i18n/stock_lot_scrap.pot b/stock_lot_scrap/i18n/stock_lot_scrap.pot index 4f0c8133d9bb..b1d727dd10bf 100644 --- a/stock_lot_scrap/i18n/stock_lot_scrap.pot +++ b/stock_lot_scrap/i18n/stock_lot_scrap.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-10-02 12:04+0000\n" +"PO-Revision-Date: 2018-10-02 12:04+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,26 +15,37 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: stock_lot_scrap +#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:18 +#, python-format +msgid "Lot was scrapped by %s." +msgstr "" + #. module: stock_lot_scrap #: model:ir.model,name:stock_lot_scrap.model_stock_production_lot msgid "Lot/Serial" msgstr "" #. module: stock_lot_scrap -#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:40 +#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:50 #, python-format msgid "Scrap" msgstr "" #. module: stock_lot_scrap -#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:67 +#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:76 #, python-format msgid "This lot doesn't contain any quant in internal location." msgstr "" #. module: stock_lot_scrap -#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:38 +#: code:addons/stock_lot_scrap/models/stock_scrap_lot.py:48 #, python-format msgid "This will scrap the whole lot. Are you sure you want to continue?" msgstr "" +#. module: stock_lot_scrap +#: model:ir.model,name:stock_lot_scrap.model_stock_scrap +msgid "stock.scrap" +msgstr "" + diff --git a/stock_lot_scrap/models/__init__.py b/stock_lot_scrap/models/__init__.py index 6e6854790e67..59efb40796ca 100644 --- a/stock_lot_scrap/models/__init__.py +++ b/stock_lot_scrap/models/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import stock_scrap_lot diff --git a/stock_lot_scrap/models/stock_scrap_lot.py b/stock_lot_scrap/models/stock_scrap_lot.py index c50fdbf02f06..1c4949555594 100644 --- a/stock_lot_scrap/models/stock_scrap_lot.py +++ b/stock_lot_scrap/models/stock_scrap_lot.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Carlos Dauden # Copyright 2016 Pedro M. Baeza # Copyright 2017 David Vidal @@ -9,6 +8,17 @@ from lxml import etree +class StockScrap(models.Model): + _inherit = 'stock.scrap' + + @api.multi + def action_validate(self): + self.ensure_one() + self.lot_id.message_post( + body=_("Lot was scrapped by %s.") % self.env.user.name) + return super(StockScrap, self).action_validate() + + class StockProductionLot(models.Model): _inherit = 'stock.production.lot' @@ -48,11 +58,10 @@ def _prepare_scrap_vals(self, quant, scrap_location_id): 'origin': quant.lot_id.name, 'product_id': quant.product_id.id, 'product_uom_id': quant.product_id.uom_id.id, - 'scrap_qty': quant.qty, + 'scrap_qty': quant.quantity, 'location_id': quant.location_id.id, 'scrap_location_id': scrap_location_id, 'lot_id': self.id, - 'picking_id': quant.history_ids[-1:].picking_id.id, 'package_id': quant.package_id.id, } @@ -69,8 +78,7 @@ def action_scrap_lot(self): scrap_obj = self.env['stock.scrap'] scraps = scrap_obj.browse() scrap_location_id = self.env.ref('stock.stock_location_scrapped').id - for quant in quants.sorted(key=lambda x: x.history_ids[-1:]. - picking_id.picking_type_id.warehouse_id.id): + for quant in quants: scrap = scrap_obj.create( self._prepare_scrap_vals(quant, scrap_location_id), ) diff --git a/stock_lot_scrap/readme/CONFIGURE.rst b/stock_lot_scrap/readme/CONFIGURE.rst new file mode 100644 index 000000000000..fb80a4d1e326 --- /dev/null +++ b/stock_lot_scrap/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +* Go to *Inventory > Configuration > Settings > Traceability*. +* Enable *Lots & Serial Numbers*. diff --git a/stock_lot_scrap/readme/CONTRIBUTORS.rst b/stock_lot_scrap/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..654e4b7c495b --- /dev/null +++ b/stock_lot_scrap/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* `Tecnativa `_: + + * Carlos Dauden + * Pedro M. Baeza + * David Vidal + * Vicent Cubells diff --git a/stock_lot_scrap/readme/DESCRIPTION.rst b/stock_lot_scrap/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..b8a77ce09dfd --- /dev/null +++ b/stock_lot_scrap/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module adds a button in *Production Lot/Serial Number* view form to +*Scrap* all quants contained. diff --git a/stock_lot_scrap/readme/USAGE.rst b/stock_lot_scrap/readme/USAGE.rst new file mode 100644 index 000000000000..b18b2e4c8f84 --- /dev/null +++ b/stock_lot_scrap/readme/USAGE.rst @@ -0,0 +1,3 @@ +* Go to *Inventory > Inventory Control > Serial Numbers / Lots*, and enter in + view form mode. +* Click button *Scrap* diff --git a/stock_lot_scrap/static/description/index.html b/stock_lot_scrap/static/description/index.html new file mode 100644 index 000000000000..6d19fcaccc46 --- /dev/null +++ b/stock_lot_scrap/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Scrap Production Lot + + + +
+

Scrap Production Lot

+ + +

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

+

This module adds a button in Production Lot/Serial Number view form to +Scrap all quants contained.

+

Table of contents

+ +
+

Configuration

+
    +
  • Go to Inventory > Configuration > Settings > Traceability.
  • +
  • Enable Lots & Serial Numbers.
  • +
+
+
+

Usage

+
    +
  • Go to Inventory > Inventory Control > Serial Numbers / Lots, and enter in +view form mode.
  • +
  • Click button Scrap
  • +
+
+
+

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

+
    +
  • 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-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_lot_scrap/tests/__init__.py b/stock_lot_scrap/tests/__init__.py index 079ccd53060e..3a433a8ace6b 100644 --- a/stock_lot_scrap/tests/__init__.py +++ b/stock_lot_scrap/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# © 2016 Carlos Dauden -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import test_stock_lot_scrap diff --git a/stock_lot_scrap/tests/test_stock_lot_scrap.py b/stock_lot_scrap/tests/test_stock_lot_scrap.py index 65adfa4d2523..3800ca750d11 100644 --- a/stock_lot_scrap/tests/test_stock_lot_scrap.py +++ b/stock_lot_scrap/tests/test_stock_lot_scrap.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2016 Carlos Dauden # Copyright 2016 Pedro M. Baeza # Copyright 2017 David Vidal @@ -17,19 +16,20 @@ def setUpClass(cls): super(TestStockLotScrap, cls).setUpClass() cls.product = cls.env['product.product'].create({ 'name': 'Test product', + 'type': 'product', }) cls.lot010 = cls.env['stock.production.lot'].create({ 'name': "0000010", 'product_id': cls.product.id }) cls.quant1 = cls.env['stock.quant'].create({ - 'qty': 5000.0, + 'quantity': 5000.0, 'location_id': cls.env.ref('stock.stock_location_stock').id, 'product_id': cls.product.id, 'lot_id': cls.lot010.id, }) cls.quant2 = cls.env['stock.quant'].create({ - 'qty': 325.0, + 'quantity': 325.0, 'location_id': cls.env.ref('stock.stock_location_stock').id, 'product_id': cls.product.id, 'lot_id': cls.lot010.id,