diff --git a/mrp_production_properties/__init__.py b/mrp_production_properties/__init__.py new file mode 100644 index 000000000..ed8e820b0 --- /dev/null +++ b/mrp_production_properties/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Alex Comba +# Copyright (C) 2014 Agile Business Group sagl +# () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from . import mrp diff --git a/mrp_production_properties/__openerp__.py b/mrp_production_properties/__openerp__.py new file mode 100644 index 000000000..4d94f79d7 --- /dev/null +++ b/mrp_production_properties/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Alex Comba +# Copyright (C) 2014 Agile Business Group sagl +# () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': "Mrp Production Properties", + 'version': '0.1', + 'category': 'Manufacturing', + 'description': """ +This module adds the properties to the manufacturing order copying them +from the related procurement order. + """, + 'author': 'Agile Business Group', + 'website': 'http://www.agilebg.com', + 'license': 'AGPL-3', + 'depends': [ + 'sale_mrp', + ], + 'data': [ + 'mrp_view.xml', + ], + 'test': [ + 'test/mrp_production_properties.yml', + ], + 'installable': True +} diff --git a/mrp_production_properties/i18n/it.po b/mrp_production_properties/i18n/it.po new file mode 100644 index 000000000..0941388b7 --- /dev/null +++ b/mrp_production_properties/i18n/it.po @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * mrp_production_properties +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-30 14:57+0000\n" +"PO-Revision-Date: 2014-04-30 16:57+0100\n" +"Last-Translator: Alex Comba \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" +"X-Generator: Poedit 1.5.4\n" + +#. module: mrp_production_properties +#: model:ir.model,name:mrp_production_properties.model_mrp_production +msgid "Manufacturing Order" +msgstr "Ordine di Produzione" + +#. module: mrp_production_properties +#: field:mrp.production,property_ids:0 +msgid "Properties" +msgstr "Proprietà" + +#. module: mrp_production_properties +#: model:ir.model,name:mrp_production_properties.model_procurement_order +msgid "Procurement" +msgstr "Approvvigionamento" diff --git a/mrp_production_properties/i18n/mrp_production_properties.pot b/mrp_production_properties/i18n/mrp_production_properties.pot new file mode 100644 index 000000000..eace65083 --- /dev/null +++ b/mrp_production_properties/i18n/mrp_production_properties.pot @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * mrp_production_properties +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-04-30 14:53+0000\n" +"PO-Revision-Date: 2014-04-30 14:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_production_properties +#: model:ir.model,name:mrp_production_properties.model_mrp_production +msgid "Manufacturing Order" +msgstr "" + +#. module: mrp_production_properties +#: field:mrp.production,property_ids:0 +msgid "Properties" +msgstr "" + +#. module: mrp_production_properties +#: model:ir.model,name:mrp_production_properties.model_procurement_order +msgid "Procurement" +msgstr "" + diff --git a/mrp_production_properties/mrp.py b/mrp_production_properties/mrp.py new file mode 100644 index 000000000..2967c5c04 --- /dev/null +++ b/mrp_production_properties/mrp.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Alex Comba +# Copyright (C) 2014 Agile Business Group sagl +# () +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class mrp_production(orm.Model): + _inherit = 'mrp.production' + + _columns = { + 'property_ids': fields.many2many( + 'mrp.property', + 'mrp_production_property_rel', + 'production_id', + 'property_id', + 'Properties' + ), + } + + +class procurement_order(orm.Model): + _inherit = "procurement.order" + + def make_mo(self, cr, uid, ids, context=None): + res = super(procurement_order, self).make_mo( + cr, uid, ids, context=context) + production_obj = self.pool.get('mrp.production') + for procurement_id, produce_id in res.iteritems(): + procurement = self.browse( + cr, uid, procurement_id, context=context) + production = production_obj.browse( + cr, uid, produce_id, context=context) + vals = { + 'property_ids': [ + (6, 0, [x.id for x in procurement.property_ids]) + ] + } + production.write(vals, context=context) + return res diff --git a/mrp_production_properties/mrp_view.xml b/mrp_production_properties/mrp_view.xml new file mode 100644 index 000000000..865526977 --- /dev/null +++ b/mrp_production_properties/mrp_view.xml @@ -0,0 +1,17 @@ + + + + + + mrp.production.form + mrp.production + + + + + + + + + + \ No newline at end of file diff --git a/mrp_production_properties/test/mrp_production_properties.yml b/mrp_production_properties/test/mrp_production_properties.yml new file mode 100644 index 000000000..d900bb403 --- /dev/null +++ b/mrp_production_properties/test/mrp_production_properties.yml @@ -0,0 +1,110 @@ +- + In order to test the mrp_production_properties, + I start by creating a new product 'Slider Mobile' +- + I create a product Slider Mobile +- + !record {model: product.product, id: product_product_slidermobile0}: + categ_id: product.product_category_1 + list_price: 200.0 + name: Slider Mobile + procure_method: make_to_order + standard_price: 189.0 + supply_method: produce + type: product + uom_id: product.product_uom_unit + uom_po_id: product.product_uom_unit +- + I create a Property Group named SM +- + !record {model: mrp.property.group, id: mrp_property_group_slidermobile}: + name: SM +- + I create the property 'QWERTY Slider Mobile Phone' belongs to SM Property Group +- + !record {model: mrp.property, id: mrp_property_slidermobile}: + name: QWERTY Slider Mobile Phone + group_id: mrp_property_group_slidermobile + composition: min +- + I create a Bill of Material record for Slider Mobile +- + !record {model: mrp.bom, id: mrp_bom_slidermobile0}: + company_id: base.main_company + name: Slider Mobile + product_efficiency: 1.0 + product_id: product_product_slidermobile0 + product_qty: 1.0 + product_uom: product.product_uom_unit + product_uos_qty: 0.0 + sequence: 0.0 + type: normal +- + I create a sale order for product Slider mobile +- + !record {model: sale.order, id: sale_order_so0}: + client_order_ref: ref1 + date_order: !eval time.strftime('%Y-%m-%d') + invoice_quantity: order + name: Test_SO001 + order_policy: manual + partner_id: base.res_partner_4 + partner_invoice_id: base.res_partner_address_7 + partner_shipping_id: base.res_partner_address_7 + picking_policy: direct + pricelist_id: product.list0 + shop_id: sale.sale_shop_1 +- + In the sale order I add one sale order line containing the Property 'QWERTY Slider Mobile Phone' +- + !record {model: sale.order.line, id: line}: + name: Slider Mobile + product_id: product_product_slidermobile0 + product_uom_qty: 500.0 + product_uom: 1 + price_unit: 200 + order_id: sale_order_so0 + type: make_to_order + property_ids: + - mrp_property_slidermobile +- + I confirm the sale order +- + !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0} +- + I verify that a procurement has been generated for sale order +- + !python {model: procurement.order}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) + proc_ids = self.search(cr, uid, [('origin','=',so.name)]) + assert proc_ids, 'No Procurements!' +- + Then I click on the "Run Procurement" button +- + !python {model: procurement.order}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) + import netsvc + wf_service = netsvc.LocalService("workflow") + proc_ids = self.search(cr, uid, [('origin','=',so.name)]) + for proc in proc_ids: + wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr) +- + I verify that a procurement state is "running" +- + !python {model: procurement.order}: | + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) + proc_ids = self.search(cr, uid, [('origin','=',so.name) and ('state','=','running')]) + assert proc_ids, 'Procurement is not in the running state!' +- + I verify that a manufacturing order has been generated, and its properties are matching +- + !python {model: sale.order}: | + mnf_obj = self.pool.get('mrp.production') + so = self.browse(cr, uid, ref("sale_order_so0")) + mnf_id = mnf_obj.search(cr, uid, [('origin','=',so.name)]) + assert mnf_id, 'Manufacturing order has not been generated' + mo = mnf_obj.browse(cr, uid, mnf_id)[0] + assert len(mo.property_ids) == 1 and mo.property_ids[0].name == so.order_line[0].property_ids[0].name, 'The property defined on the MO and the SO do not match.'