diff --git a/procurement_mrp_no_confirm/README.rst b/procurement_mrp_no_confirm/README.rst new file mode 100644 index 000000000..994db3356 --- /dev/null +++ b/procurement_mrp_no_confirm/README.rst @@ -0,0 +1,76 @@ + .. 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 + +=============================== +Don't confirm MOs when procured +=============================== + +This module prevents the automatic confirmation of manufacturing order when +procurement orders are executed. + +Installation +============ + +To install this module, you need to: + +1. Clone the branch 8.0 of the repository https://github.com/OCA/manufacture +2. Add the path to this repository in your configuration (addons-path) +3. Update the module list +4. Go to menu *Setting -> Modules -> Local Modules* +5. Search For *Procurement MRP no Confirm* +6. Install the module + +Usage +===== + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/129/8.0 + + +Known issues / Roadmap +====================== + +* If the production order workflow has been altered in the transition + *prod_trans_draft_picking* to have another condition, when uninstalling this + module, you will need to restore the custom condition. + +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. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Pedro M. Baeza +* Ainara Galdona +* Oihane Crucelaegui +* Andhitia Rama + +Maintainer +---------- + +.. 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. diff --git a/procurement_mrp_no_confirm/__init__.py b/procurement_mrp_no_confirm/__init__.py new file mode 100644 index 000000000..87f9041b3 --- /dev/null +++ b/procurement_mrp_no_confirm/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models +from openerp import SUPERUSER_ID, api + + +def uninstall_hook(cr, registry): + """Restore workflow condition.""" + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + transition = env.ref('mrp.prod_trans_draft_picking') + transition.condition = True diff --git a/procurement_mrp_no_confirm/__openerp__.py b/procurement_mrp_no_confirm/__openerp__.py new file mode 100644 index 000000000..17ecb3835 --- /dev/null +++ b/procurement_mrp_no_confirm/__openerp__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Procurement MRP no Confirm", + "version": "8.0.1.0.0", + "depends": ["mrp"], + "author": "OdooMRP team," + "AvanzOSC," + "Tecnativa," + "Odoo Community Association (OCA)", + "category": "MRP", + "data": ["data/mrp_production_workflow.xml"], + "installable": True, + "auto_install": False, + "uninstall_hook": "uninstall_hook", +} diff --git a/procurement_mrp_no_confirm/data/mrp_production_workflow.xml b/procurement_mrp_no_confirm/data/mrp_production_workflow.xml new file mode 100644 index 000000000..38e2acdba --- /dev/null +++ b/procurement_mrp_no_confirm/data/mrp_production_workflow.xml @@ -0,0 +1,11 @@ + + + + + + + button_confirm + not no_confirm + + + diff --git a/procurement_mrp_no_confirm/i18n/es.po b/procurement_mrp_no_confirm/i18n/es.po new file mode 100644 index 000000000..6e7a9be85 --- /dev/null +++ b/procurement_mrp_no_confirm/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * procurement_mrp_no_confirm +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-20 16:56+0000\n" +"PO-Revision-Date: 2014-11-20 17:57+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_mrp_production +msgid "Manufacturing Order" +msgstr "Órden de fabricación" + +#. module: procurement_mrp_no_confirm +#: field:mrp.production,no_confirm:0 +msgid "No Confirm" +msgstr "No confirmar" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_procurement_order +msgid "Procurement" +msgstr "Abastecimiento" + diff --git a/procurement_mrp_no_confirm/i18n/it.po b/procurement_mrp_no_confirm/i18n/it.po new file mode 100644 index 000000000..7b4503d06 --- /dev/null +++ b/procurement_mrp_no_confirm/i18n/it.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * procurement_mrp_no_confirm +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: odoomrp-wip (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-20 18:10+0000\n" +"PO-Revision-Date: 2015-09-10 16:34+0000\n" +"Last-Translator: <>\n" +"Language-Team: Italian (http://www.transifex.com/oca/odoomrp-wip-8-0/language/it/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_mrp_production +msgid "Manufacturing Order" +msgstr "Ordine di produzione" + +#. module: procurement_mrp_no_confirm +#: field:mrp.production,no_confirm:0 +msgid "No Confirm" +msgstr "" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_procurement_order +msgid "Procurement" +msgstr "" diff --git a/procurement_mrp_no_confirm/i18n/pt_BR.po b/procurement_mrp_no_confirm/i18n/pt_BR.po new file mode 100644 index 000000000..a8a8c0515 --- /dev/null +++ b/procurement_mrp_no_confirm/i18n/pt_BR.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * procurement_mrp_no_confirm +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: odoomrp-wip (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-07 10:44+0000\n" +"PO-Revision-Date: 2015-10-09 03:37+0000\n" +"Last-Translator: danimaribeiro \n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/odoomrp-wip-8-0/language/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_mrp_production +msgid "Manufacturing Order" +msgstr "Ordem de Produção" + +#. module: procurement_mrp_no_confirm +#: field:mrp.production,no_confirm:0 +msgid "No Confirm" +msgstr "" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_procurement_order +msgid "Procurement" +msgstr "Aprovisionamento" diff --git a/procurement_mrp_no_confirm/i18n/ro.po b/procurement_mrp_no_confirm/i18n/ro.po new file mode 100644 index 000000000..f7fd04fe6 --- /dev/null +++ b/procurement_mrp_no_confirm/i18n/ro.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * procurement_mrp_no_confirm +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: odoomrp-wip (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-11-20 18:10+0000\n" +"PO-Revision-Date: 2015-09-10 16:34+0000\n" +"Last-Translator: <>\n" +"Language-Team: Romanian (http://www.transifex.com/oca/odoomrp-wip-8-0/language/ro/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: ro\n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_mrp_production +msgid "Manufacturing Order" +msgstr "Comandă fabricație" + +#. module: procurement_mrp_no_confirm +#: field:mrp.production,no_confirm:0 +msgid "No Confirm" +msgstr "" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_procurement_order +msgid "Procurement" +msgstr "Aprovizionare" diff --git a/procurement_mrp_no_confirm/i18n/sl.po b/procurement_mrp_no_confirm/i18n/sl.po new file mode 100644 index 000000000..bb9247b2d --- /dev/null +++ b/procurement_mrp_no_confirm/i18n/sl.po @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * procurement_mrp_no_confirm +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-20 16:56+0000\n" +"PO-Revision-Date: 2015-08-15 09:03+0200\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: sl\n" +"X-Generator: Poedit 1.8.4\n" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_mrp_production +msgid "Manufacturing Order" +msgstr "Proizvodni nalog" + +#. module: procurement_mrp_no_confirm +#: field:mrp.production,no_confirm:0 +msgid "No Confirm" +msgstr "Brez potrditve" + +#. module: procurement_mrp_no_confirm +#: model:ir.model,name:procurement_mrp_no_confirm.model_procurement_order +msgid "Procurement" +msgstr "Oskrbovanje" diff --git a/procurement_mrp_no_confirm/models/__init__.py b/procurement_mrp_no_confirm/models/__init__.py new file mode 100644 index 000000000..ad16e3060 --- /dev/null +++ b/procurement_mrp_no_confirm/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import procurement_order +from . import mrp_production diff --git a/procurement_mrp_no_confirm/models/mrp_production.py b/procurement_mrp_no_confirm/models/mrp_production.py new file mode 100644 index 000000000..282213262 --- /dev/null +++ b/procurement_mrp_no_confirm/models/mrp_production.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, fields + + +class MrpProduction(models.Model): + + _inherit = 'mrp.production' + + no_confirm = fields.Boolean('No Confirm') diff --git a/procurement_mrp_no_confirm/models/procurement_order.py b/procurement_mrp_no_confirm/models/procurement_order.py new file mode 100644 index 000000000..9057b0b9f --- /dev/null +++ b/procurement_mrp_no_confirm/models/procurement_order.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, api + + +class ProcurementOrder(models.Model): + + _inherit = 'procurement.order' + + @api.multi + def write(self, vals): + production_obj = self.env['mrp.production'] + if vals.get('production_id'): + production = production_obj.browse(vals['production_id']) + production.no_confirm = True + return super(ProcurementOrder, self).write(vals) + + @api.multi + def make_mo(self): + res = super(ProcurementOrder, self).make_mo() + for procurement in self: + if (procurement.production_id and + procurement.production_id.no_confirm): + procurement.production_id.no_confirm = False + return res diff --git a/procurement_mrp_no_confirm/static/description/icon.png b/procurement_mrp_no_confirm/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/procurement_mrp_no_confirm/static/description/icon.png differ diff --git a/procurement_mrp_no_confirm/tests/__init__.py b/procurement_mrp_no_confirm/tests/__init__.py new file mode 100644 index 000000000..5485d6ef2 --- /dev/null +++ b/procurement_mrp_no_confirm/tests/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_procurement diff --git a/procurement_mrp_no_confirm/tests/test_procurement.py b/procurement_mrp_no_confirm/tests/test_procurement.py new file mode 100644 index 000000000..9a0943876 --- /dev/null +++ b/procurement_mrp_no_confirm/tests/test_procurement.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# © 2015 AvanzOSC +# © 2015 Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.tests.common import TransactionCase +from datetime import datetime + + +class TestProcurement(TransactionCase): + + def setUp(self, *args, **kwargs): + result = super(TestProcurement, self).setUp(*args, **kwargs) + + self.product = self.env.ref("product.product_product_4b") + self.location = self.env.ref("stock.stock_location_stock") + + criteria = [ + ("location_id", "=", self.location.id), + ("action", "=", "manufacture"), + ] + + self.rule = self.env["procurement.rule"].search( + criteria)[0] + + self.proc_data = { + "name": "Test Procurement", + "product_id": self.product.id, + "location_id": self.location.id, + "product_qty": 1.0, + "product_uom": self.product.uom_id.id, + "date_planned": datetime.now().strftime("%Y-%m-%d %H:%M:%S"), + "rule_id": self.rule.id, + } + + return result + + def test_1(self): + proc = self.env["procurement.order"].create(self.proc_data) + + proc.run() + self.assertEqual( + proc.state, + "running") + + # procurement should generate MO + self.assertTrue(proc.production_id) + + # MO should in draft state + self.assertEqual( + proc.production_id.state, + "draft")