diff --git a/mrp_auto_create_lot/README.rst b/mrp_auto_create_lot/README.rst new file mode 100644 index 000000000..b8e0085a2 --- /dev/null +++ b/mrp_auto_create_lot/README.rst @@ -0,0 +1,93 @@ +=================== +MRP Auto Create 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%2Fmanufacture-lightgray.png?logo=github + :target: https://github.com/OCA/manufacture/tree/12.0/mrp_auto_create_lot + :alt: OCA/manufacture +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-mrp_auto_create_lot + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/129/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of mrp module to allow auto create lots. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module you need to: + +#. Go to a *Product > Inventory tab*. +#. Set a tracking option for this product. +#. Set auto create lot. +#. Go to *Manufacturing > Manufacturing Orders* and create or select one. +#. Create Workorders on this MO. +#. Done the Work Order of product with auto create lot. + +Changelog +========= + +12.0.1.0.0 (2020-01-02) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Start of the history. + +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 +~~~~~~~ + +* Ecosoft + +Contributors +~~~~~~~~~~~~ + +* Pimolnat Suntian + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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/manufacture `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mrp_auto_create_lot/__init__.py b/mrp_auto_create_lot/__init__.py new file mode 100644 index 000000000..7d44c9df1 --- /dev/null +++ b/mrp_auto_create_lot/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import models diff --git a/mrp_auto_create_lot/__manifest__.py b/mrp_auto_create_lot/__manifest__.py new file mode 100644 index 000000000..acfb6144d --- /dev/null +++ b/mrp_auto_create_lot/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "MRP Auto Create Lot", + "summary": "Auto create lots for work orders", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/manufacture", + "category": "Manufacturing", + "version": "12.0.1.0.0", + "license": "AGPL-3", + "depends": ["mrp", "stock_picking_auto_create_lot"], + "application": False, + "installable": True, + "maintainers": ["ps-tubtim"], +} diff --git a/mrp_auto_create_lot/models/__init__.py b/mrp_auto_create_lot/models/__init__.py new file mode 100644 index 000000000..600fc95ed --- /dev/null +++ b/mrp_auto_create_lot/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import mrp_workorder diff --git a/mrp_auto_create_lot/models/mrp_workorder.py b/mrp_auto_create_lot/models/mrp_workorder.py new file mode 100644 index 000000000..bee6a124f --- /dev/null +++ b/mrp_auto_create_lot/models/mrp_workorder.py @@ -0,0 +1,16 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo import api, models + + +class MrpWorkorder(models.Model): + _inherit = 'mrp.workorder' + + @api.multi + def record_production(self): + if self.product_id.auto_create_lot: + self.final_lot_id = self.env['stock.production.lot'].create({ + 'product_id': self.product_id.id, + }) + return super().record_production() diff --git a/mrp_auto_create_lot/readme/CONTRIBUTORS.rst b/mrp_auto_create_lot/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0ef1f84c3 --- /dev/null +++ b/mrp_auto_create_lot/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Pimolnat Suntian diff --git a/mrp_auto_create_lot/readme/DESCRIPTION.rst b/mrp_auto_create_lot/readme/DESCRIPTION.rst new file mode 100644 index 000000000..642386991 --- /dev/null +++ b/mrp_auto_create_lot/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module extends the functionality of mrp module to allow auto create lots. diff --git a/mrp_auto_create_lot/readme/HISTORY.rst b/mrp_auto_create_lot/readme/HISTORY.rst new file mode 100644 index 000000000..fbc7f200c --- /dev/null +++ b/mrp_auto_create_lot/readme/HISTORY.rst @@ -0,0 +1,4 @@ +12.0.1.0.0 (2020-01-02) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Start of the history. diff --git a/mrp_auto_create_lot/readme/USAGE.rst b/mrp_auto_create_lot/readme/USAGE.rst new file mode 100644 index 000000000..79865572f --- /dev/null +++ b/mrp_auto_create_lot/readme/USAGE.rst @@ -0,0 +1,8 @@ +To use this module you need to: + +#. Go to a *Product > Inventory tab*. +#. Set a tracking option for this product. +#. Set auto create lot. +#. Go to *Manufacturing > Manufacturing Orders* and create or select one. +#. Create Workorders on this MO. +#. Done the Work Order of product with auto create lot. diff --git a/mrp_auto_create_lot/static/description/icon.png b/mrp_auto_create_lot/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/mrp_auto_create_lot/static/description/icon.png differ diff --git a/mrp_auto_create_lot/static/description/index.html b/mrp_auto_create_lot/static/description/index.html new file mode 100644 index 000000000..357001c51 --- /dev/null +++ b/mrp_auto_create_lot/static/description/index.html @@ -0,0 +1,445 @@ + + + + + + +MRP Auto Create Lot + + + +
+

MRP Auto Create Lot

+ + +

Beta License: AGPL-3 OCA/manufacture Translate me on Weblate Try me on Runbot

+

This module extends the functionality of mrp module to allow auto create lots.

+

Table of contents

+ +
+

Usage

+

To use this module you need to:

+
    +
  1. Go to a Product > Inventory tab.
  2. +
  3. Set a tracking option for this product.
  4. +
  5. Set auto create lot.
  6. +
  7. Go to Manufacturing > Manufacturing Orders and create or select one.
  8. +
  9. Create Workorders on this MO.
  10. +
  11. Done the Work Order of product with auto create lot.
  12. +
+
+
+

Changelog

+
+

12.0.1.0.0 (2020-01-02)

+
    +
  • Start of the history.
  • +
+
+
+
+

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

+
    +
  • Ecosoft
  • +
+
+
+

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/manufacture project on GitHub.

+

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

+
+
+
+ + diff --git a/mrp_auto_create_lot/tests/__init__.py b/mrp_auto_create_lot/tests/__init__.py new file mode 100644 index 000000000..2e2c17ccc --- /dev/null +++ b/mrp_auto_create_lot/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from . import test_auto_create_lot diff --git a/mrp_auto_create_lot/tests/test_auto_create_lot.py b/mrp_auto_create_lot/tests/test_auto_create_lot.py new file mode 100644 index 000000000..c3e12ae18 --- /dev/null +++ b/mrp_auto_create_lot/tests/test_auto_create_lot.py @@ -0,0 +1,77 @@ +# Copyright 2020 Ecosoft Co., Ltd (http://ecosoft.co.th/) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +from odoo.tests.common import TransactionCase + + +class TestMrpAutoCreateLot(TransactionCase): + + def setUp(self, *args, **kwargs): + super(TestMrpAutoCreateLot, self).setUp(*args, **kwargs) + self.production_model = self.env['mrp.production'] + self.bom_model = self.env['mrp.bom'] + self.picking_model = self.env['stock.picking'] + self.stock_location_stock = self.env.ref('stock.stock_location_stock') + self.manufacture_route = self.env.ref('mrp.route_warehouse0_manufacture') + self.uom_unit = self.env.ref('uom.product_uom_unit') + + self.workcenter = self.env['mrp.workcenter'].create({ + 'costs_hour': 10, + 'name': 'Workcenter', + }) + self.routing_id = self.env['mrp.routing'].create({ + 'name': 'Routing', + }) + self.operation = self.env['mrp.routing.workcenter'].create({ + 'name': 'operation', + 'workcenter_id': self.workcenter.id, + 'routing_id': self.routing_id.id, + 'time_mode': 'manual', + 'time_cycle_manual': 20, + 'batch': 'no', + 'sequence': 1, + }) + + self.product_manuf = self.env['product.product'].create({ + 'name': 'Manuf', + 'type': 'product', + 'uom_id': self.uom_unit.id, + 'route_ids': [(6, 0, self.manufacture_route.ids)], + 'tracking': 'lot', + 'auto_create_lot': True, + }) + self.product_raw_material = self.env['product.product'].create({ + 'name': 'Raw Material', + 'type': 'product', + 'uom_id': self.uom_unit.id, + }) + + self.bom = self.env['mrp.bom'].create({ + 'product_id': self.product_manuf.id, + 'product_tmpl_id': self.product_manuf.product_tmpl_id.id, + 'type': 'normal', + 'routing_id': self.routing_id.id, + 'bom_line_ids': ([ + (0, 0, { + 'product_id': self.product_raw_material.id, + 'product_qty': 1, + 'product_uom_id': self.uom_unit.id, + }), + ]) + }) + + def test_01_manufacture_auto_create_lot(self): + production = self.production_model.create({ + 'product_id': self.product_manuf.id, + 'product_qty': 1, + 'product_uom_id': self.uom_unit.id, + 'bom_id': self.bom.id, + }) + production.button_plan() + self.assertEqual(production.workorder_count, 1) + + workorders = production.workorder_ids + for workorder in workorders: + workorder.button_start() + workorder.record_production() + self.assertEqual(workorder.state, 'done') diff --git a/oca_dependencies.txt b/oca_dependencies.txt index c3d6585a4..ee35006c0 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,3 +1,4 @@ # List the OCA project dependencies, one per line # Add a repository url and branch if you need a forked version stock-logistics-warehouse +stock-logistics-workflow