← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~agilebg/openerp-manufacturing/adding_mrp_production_properties_7 into lp:openerp-manufacturing

 

Alex Comba - Agile BG has proposed merging lp:~agilebg/openerp-manufacturing/adding_mrp_production_properties_7 into lp:openerp-manufacturing.

Commit message:
[ADD] module mrp_production_properties

Requested reviews:
  Manufacture Core Editors (manufacture-core-editors)

For more details, see:
https://code.launchpad.net/~agilebg/openerp-manufacturing/adding_mrp_production_properties_7/+merge/219559

This branch contains the module 'mrp_production_properties' which adds the properties to the manufacturing order copying them from the related procurement order.
-- 
https://code.launchpad.net/~agilebg/openerp-manufacturing/adding_mrp_production_properties_7/+merge/219559
Your team Manufacture Core Editors is requested to review the proposed merge of lp:~agilebg/openerp-manufacturing/adding_mrp_production_properties_7 into lp:openerp-manufacturing.
=== added directory 'mrp_production_properties'
=== added file 'mrp_production_properties/__init__.py'
--- mrp_production_properties/__init__.py	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/__init__.py	2014-05-14 16:32:54 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#	 Author: Alex Comba <alex.comba@xxxxxxxxxxx>
+#    Copyright (C) 2014 Agile Business Group sagl
+#	 (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+from . import mrp

=== added file 'mrp_production_properties/__openerp__.py'
--- mrp_production_properties/__openerp__.py	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/__openerp__.py	2014-05-14 16:32:54 +0000
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Alex Comba <alex.comba@xxxxxxxxxxx>
+#    Copyright (C) 2014 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    '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
+}

=== added directory 'mrp_production_properties/i18n'
=== added file 'mrp_production_properties/i18n/it.po'
--- mrp_production_properties/i18n/it.po	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/i18n/it.po	2014-05-14 16:32:54 +0000
@@ -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 <alex.comba@xxxxxxxxxxx>\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"

=== added file 'mrp_production_properties/i18n/mrp_production_properties.pot'
--- mrp_production_properties/i18n/mrp_production_properties.pot	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/i18n/mrp_production_properties.pot	2014-05-14 16:32:54 +0000
@@ -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 ""
+

=== added file 'mrp_production_properties/mrp.py'
--- mrp_production_properties/mrp.py	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/mrp.py	2014-05-14 16:32:54 +0000
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Alex Comba <alex.comba@xxxxxxxxxxx>
+#    Copyright (C) 2014 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+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

=== added file 'mrp_production_properties/mrp_view.xml'
--- mrp_production_properties/mrp_view.xml	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/mrp_view.xml	2014-05-14 16:32:54 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="mrp_production_form_view" model="ir.ui.view">
+            <field name="name">mrp.production.form</field>
+            <field name="model">mrp.production</field>
+            <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
+            <field name="arch" type="xml">
+                <xpath expr="//field[@name='priority']" position="after">
+                        <field name="property_ids" widget="many2many_tags"/>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>
\ No newline at end of file

=== added directory 'mrp_production_properties/test'
=== added file 'mrp_production_properties/test/mrp_production_properties.yml'
--- mrp_production_properties/test/mrp_production_properties.yml	1970-01-01 00:00:00 +0000
+++ mrp_production_properties/test/mrp_production_properties.yml	2014-05-14 16:32:54 +0000
@@ -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 with those on the sale order line
+-
+    !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.'


Follow ups