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

Proposed by Alex Comba - Agile BG
Status: Merged
Merged at revision: 7
Proposed branch: lp:~agilebg/openerp-manufacturing/adding_mrp_production_properties_7
Merge into: lp:openerp-manufacturing
Diff against target: 352 lines (+314/-0)
7 files modified
mrp_production_properties/__init__.py (+22/-0)
mrp_production_properties/__openerp__.py (+43/-0)
mrp_production_properties/i18n/it.po (+32/-0)
mrp_production_properties/i18n/mrp_production_properties.pot (+32/-0)
mrp_production_properties/mrp.py (+58/-0)
mrp_production_properties/mrp_view.xml (+17/-0)
mrp_production_properties/test/mrp_production_properties.yml (+110/-0)
To merge this branch: bzr merge lp:~agilebg/openerp-manufacturing/adding_mrp_production_properties_7
Reviewer Review Type Date Requested Status
Omar (Pexego) code review Approve
Lorenzo Battistini (community) code review Approve
Pedro Manuel Baeza code review Approve
Review via email: mp+219559@code.launchpad.net

Commit message

[ADD] module mrp_production_properties

Description of the change

This branch contains the module 'mrp_production_properties' which adds the properties to the manufacturing order copying them from the related procurement order.

To post a comment you must log in.
9. By Alex Comba - Agile BG

[FIX] header of __init__.py

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Alex, thanks for the MP.

LGTM, and PEP8 compliant.

Regards.

review: Approve (code review)
Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve (code review)
Revision history for this message
Omar (Pexego) (omar7r) wrote :

LGTM

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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:41:19 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22from . import mrp
023
=== 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:41:19 +0000
@@ -0,0 +1,43 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22{
23 'name': "Mrp Production Properties",
24 'version': '0.1',
25 'category': 'Manufacturing',
26 'description': """
27This module adds the properties to the manufacturing order copying them
28from the related procurement order.
29 """,
30 'author': 'Agile Business Group',
31 'website': 'http://www.agilebg.com',
32 'license': 'AGPL-3',
33 'depends': [
34 'sale_mrp',
35 ],
36 'data': [
37 'mrp_view.xml',
38 ],
39 'test': [
40 'test/mrp_production_properties.yml',
41 ],
42 'installable': True
43}
044
=== 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:41:19 +0000
@@ -0,0 +1,32 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * mrp_production_properties
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-04-30 14:57+0000\n"
10"PO-Revision-Date: 2014-04-30 16:57+0100\n"
11"Last-Translator: Alex Comba <alex.comba@agilebg.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17"X-Generator: Poedit 1.5.4\n"
18
19#. module: mrp_production_properties
20#: model:ir.model,name:mrp_production_properties.model_mrp_production
21msgid "Manufacturing Order"
22msgstr "Ordine di Produzione"
23
24#. module: mrp_production_properties
25#: field:mrp.production,property_ids:0
26msgid "Properties"
27msgstr "Proprietà"
28
29#. module: mrp_production_properties
30#: model:ir.model,name:mrp_production_properties.model_procurement_order
31msgid "Procurement"
32msgstr "Approvvigionamento"
033
=== 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:41:19 +0000
@@ -0,0 +1,32 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * mrp_production_properties
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-04-30 14:53+0000\n"
10"PO-Revision-Date: 2014-04-30 14:53+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: mrp_production_properties
19#: model:ir.model,name:mrp_production_properties.model_mrp_production
20msgid "Manufacturing Order"
21msgstr ""
22
23#. module: mrp_production_properties
24#: field:mrp.production,property_ids:0
25msgid "Properties"
26msgstr ""
27
28#. module: mrp_production_properties
29#: model:ir.model,name:mrp_production_properties.model_procurement_order
30msgid "Procurement"
31msgstr ""
32
033
=== 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:41:19 +0000
@@ -0,0 +1,58 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from openerp.osv import orm, fields
24
25
26class mrp_production(orm.Model):
27 _inherit = 'mrp.production'
28
29 _columns = {
30 'property_ids': fields.many2many(
31 'mrp.property',
32 'mrp_production_property_rel',
33 'production_id',
34 'property_id',
35 'Properties'
36 ),
37 }
38
39
40class procurement_order(orm.Model):
41 _inherit = "procurement.order"
42
43 def make_mo(self, cr, uid, ids, context=None):
44 res = super(procurement_order, self).make_mo(
45 cr, uid, ids, context=context)
46 production_obj = self.pool.get('mrp.production')
47 for procurement_id, produce_id in res.iteritems():
48 procurement = self.browse(
49 cr, uid, procurement_id, context=context)
50 production = production_obj.browse(
51 cr, uid, produce_id, context=context)
52 vals = {
53 'property_ids': [
54 (6, 0, [x.id for x in procurement.property_ids])
55 ]
56 }
57 production.write(vals, context=context)
58 return res
059
=== 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:41:19 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="mrp_production_form_view" model="ir.ui.view">
6 <field name="name">mrp.production.form</field>
7 <field name="model">mrp.production</field>
8 <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
9 <field name="arch" type="xml">
10 <xpath expr="//field[@name='priority']" position="after">
11 <field name="property_ids" widget="many2many_tags"/>
12 </xpath>
13 </field>
14 </record>
15
16 </data>
17</openerp>
0\ No newline at end of file18\ No newline at end of file
119
=== 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:41:19 +0000
@@ -0,0 +1,110 @@
1-
2 In order to test the mrp_production_properties,
3 I start by creating a new product 'Slider Mobile'
4-
5 I create a product Slider Mobile
6-
7 !record {model: product.product, id: product_product_slidermobile0}:
8 categ_id: product.product_category_1
9 list_price: 200.0
10 name: Slider Mobile
11 procure_method: make_to_order
12 standard_price: 189.0
13 supply_method: produce
14 type: product
15 uom_id: product.product_uom_unit
16 uom_po_id: product.product_uom_unit
17-
18 I create a Property Group named SM
19-
20 !record {model: mrp.property.group, id: mrp_property_group_slidermobile}:
21 name: SM
22-
23 I create the property 'QWERTY Slider Mobile Phone' belongs to SM Property Group
24-
25 !record {model: mrp.property, id: mrp_property_slidermobile}:
26 name: QWERTY Slider Mobile Phone
27 group_id: mrp_property_group_slidermobile
28 composition: min
29-
30 I create a Bill of Material record for Slider Mobile
31-
32 !record {model: mrp.bom, id: mrp_bom_slidermobile0}:
33 company_id: base.main_company
34 name: Slider Mobile
35 product_efficiency: 1.0
36 product_id: product_product_slidermobile0
37 product_qty: 1.0
38 product_uom: product.product_uom_unit
39 product_uos_qty: 0.0
40 sequence: 0.0
41 type: normal
42-
43 I create a sale order for product Slider mobile
44-
45 !record {model: sale.order, id: sale_order_so0}:
46 client_order_ref: ref1
47 date_order: !eval time.strftime('%Y-%m-%d')
48 invoice_quantity: order
49 name: Test_SO001
50 order_policy: manual
51 partner_id: base.res_partner_4
52 partner_invoice_id: base.res_partner_address_7
53 partner_shipping_id: base.res_partner_address_7
54 picking_policy: direct
55 pricelist_id: product.list0
56 shop_id: sale.sale_shop_1
57-
58 In the sale order I add one sale order line containing the Property 'QWERTY Slider Mobile Phone'
59-
60 !record {model: sale.order.line, id: line}:
61 name: Slider Mobile
62 product_id: product_product_slidermobile0
63 product_uom_qty: 500.0
64 product_uom: 1
65 price_unit: 200
66 order_id: sale_order_so0
67 type: make_to_order
68 property_ids:
69 - mrp_property_slidermobile
70-
71 I confirm the sale order
72-
73 !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
74-
75 I verify that a procurement has been generated for sale order
76-
77 !python {model: procurement.order}: |
78 sale_order_obj = self.pool.get('sale.order')
79 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
80 proc_ids = self.search(cr, uid, [('origin','=',so.name)])
81 assert proc_ids, 'No Procurements!'
82-
83 Then I click on the "Run Procurement" button
84-
85 !python {model: procurement.order}: |
86 sale_order_obj = self.pool.get('sale.order')
87 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
88 import netsvc
89 wf_service = netsvc.LocalService("workflow")
90 proc_ids = self.search(cr, uid, [('origin','=',so.name)])
91 for proc in proc_ids:
92 wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
93-
94 I verify that a procurement state is "running"
95-
96 !python {model: procurement.order}: |
97 sale_order_obj = self.pool.get('sale.order')
98 so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
99 proc_ids = self.search(cr, uid, [('origin','=',so.name) and ('state','=','running')])
100 assert proc_ids, 'Procurement is not in the running state!'
101-
102 I verify that a manufacturing order has been generated, and its properties are matching with those on the sale order line
103-
104 !python {model: sale.order}: |
105 mnf_obj = self.pool.get('mrp.production')
106 so = self.browse(cr, uid, ref("sale_order_so0"))
107 mnf_id = mnf_obj.search(cr, uid, [('origin','=',so.name)])
108 assert mnf_id, 'Manufacturing order has not been generated'
109 mo = mnf_obj.browse(cr, uid, mnf_id)[0]
110 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.'