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
1=== added directory 'mrp_production_properties'
2=== added file 'mrp_production_properties/__init__.py'
3--- mrp_production_properties/__init__.py 1970-01-01 00:00:00 +0000
4+++ mrp_production_properties/__init__.py 2014-05-14 16:41:19 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Alex Comba <alex.comba@agilebg.com>
10+# Copyright (C) 2014 Agile Business Group sagl
11+# (<http://www.agilebg.com>)
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as published
15+# by the Free Software Foundation, either version 3 of the License, or
16+# (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+from . import mrp
28
29=== added file 'mrp_production_properties/__openerp__.py'
30--- mrp_production_properties/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ mrp_production_properties/__openerp__.py 2014-05-14 16:41:19 +0000
32@@ -0,0 +1,43 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Author: Alex Comba <alex.comba@agilebg.com>
37+# Copyright (C) 2014 Agile Business Group sagl
38+# (<http://www.agilebg.com>)
39+#
40+# This program is free software: you can redistribute it and/or modify
41+# it under the terms of the GNU Affero General Public License as published
42+# by the Free Software Foundation, either version 3 of the License, or
43+# (at your option) any later version.
44+#
45+# This program is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU Affero General Public License for more details.
49+#
50+# You should have received a copy of the GNU Affero General Public License
51+# along with this program. If not, see <http://www.gnu.org/licenses/>.
52+#
53+##############################################################################
54+{
55+ 'name': "Mrp Production Properties",
56+ 'version': '0.1',
57+ 'category': 'Manufacturing',
58+ 'description': """
59+This module adds the properties to the manufacturing order copying them
60+from the related procurement order.
61+ """,
62+ 'author': 'Agile Business Group',
63+ 'website': 'http://www.agilebg.com',
64+ 'license': 'AGPL-3',
65+ 'depends': [
66+ 'sale_mrp',
67+ ],
68+ 'data': [
69+ 'mrp_view.xml',
70+ ],
71+ 'test': [
72+ 'test/mrp_production_properties.yml',
73+ ],
74+ 'installable': True
75+}
76
77=== added directory 'mrp_production_properties/i18n'
78=== added file 'mrp_production_properties/i18n/it.po'
79--- mrp_production_properties/i18n/it.po 1970-01-01 00:00:00 +0000
80+++ mrp_production_properties/i18n/it.po 2014-05-14 16:41:19 +0000
81@@ -0,0 +1,32 @@
82+# Translation of OpenERP Server.
83+# This file contains the translation of the following modules:
84+# * mrp_production_properties
85+#
86+msgid ""
87+msgstr ""
88+"Project-Id-Version: OpenERP Server 7.0\n"
89+"Report-Msgid-Bugs-To: \n"
90+"POT-Creation-Date: 2014-04-30 14:57+0000\n"
91+"PO-Revision-Date: 2014-04-30 16:57+0100\n"
92+"Last-Translator: Alex Comba <alex.comba@agilebg.com>\n"
93+"Language-Team: \n"
94+"MIME-Version: 1.0\n"
95+"Content-Type: text/plain; charset=UTF-8\n"
96+"Content-Transfer-Encoding: 8bit\n"
97+"Plural-Forms: \n"
98+"X-Generator: Poedit 1.5.4\n"
99+
100+#. module: mrp_production_properties
101+#: model:ir.model,name:mrp_production_properties.model_mrp_production
102+msgid "Manufacturing Order"
103+msgstr "Ordine di Produzione"
104+
105+#. module: mrp_production_properties
106+#: field:mrp.production,property_ids:0
107+msgid "Properties"
108+msgstr "Proprietà"
109+
110+#. module: mrp_production_properties
111+#: model:ir.model,name:mrp_production_properties.model_procurement_order
112+msgid "Procurement"
113+msgstr "Approvvigionamento"
114
115=== added file 'mrp_production_properties/i18n/mrp_production_properties.pot'
116--- mrp_production_properties/i18n/mrp_production_properties.pot 1970-01-01 00:00:00 +0000
117+++ mrp_production_properties/i18n/mrp_production_properties.pot 2014-05-14 16:41:19 +0000
118@@ -0,0 +1,32 @@
119+# Translation of OpenERP Server.
120+# This file contains the translation of the following modules:
121+# * mrp_production_properties
122+#
123+msgid ""
124+msgstr ""
125+"Project-Id-Version: OpenERP Server 7.0\n"
126+"Report-Msgid-Bugs-To: \n"
127+"POT-Creation-Date: 2014-04-30 14:53+0000\n"
128+"PO-Revision-Date: 2014-04-30 14:53+0000\n"
129+"Last-Translator: <>\n"
130+"Language-Team: \n"
131+"MIME-Version: 1.0\n"
132+"Content-Type: text/plain; charset=UTF-8\n"
133+"Content-Transfer-Encoding: \n"
134+"Plural-Forms: \n"
135+
136+#. module: mrp_production_properties
137+#: model:ir.model,name:mrp_production_properties.model_mrp_production
138+msgid "Manufacturing Order"
139+msgstr ""
140+
141+#. module: mrp_production_properties
142+#: field:mrp.production,property_ids:0
143+msgid "Properties"
144+msgstr ""
145+
146+#. module: mrp_production_properties
147+#: model:ir.model,name:mrp_production_properties.model_procurement_order
148+msgid "Procurement"
149+msgstr ""
150+
151
152=== added file 'mrp_production_properties/mrp.py'
153--- mrp_production_properties/mrp.py 1970-01-01 00:00:00 +0000
154+++ mrp_production_properties/mrp.py 2014-05-14 16:41:19 +0000
155@@ -0,0 +1,58 @@
156+# -*- coding: utf-8 -*-
157+##############################################################################
158+#
159+# Author: Alex Comba <alex.comba@agilebg.com>
160+# Copyright (C) 2014 Agile Business Group sagl
161+# (<http://www.agilebg.com>)
162+#
163+# This program is free software: you can redistribute it and/or modify
164+# it under the terms of the GNU Affero General Public License as published
165+# by the Free Software Foundation, either version 3 of the License, or
166+# (at your option) any later version.
167+#
168+# This program is distributed in the hope that it will be useful,
169+# but WITHOUT ANY WARRANTY; without even the implied warranty of
170+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171+# GNU Affero General Public License for more details.
172+#
173+# You should have received a copy of the GNU Affero General Public License
174+# along with this program. If not, see <http://www.gnu.org/licenses/>.
175+#
176+##############################################################################
177+
178+from openerp.osv import orm, fields
179+
180+
181+class mrp_production(orm.Model):
182+ _inherit = 'mrp.production'
183+
184+ _columns = {
185+ 'property_ids': fields.many2many(
186+ 'mrp.property',
187+ 'mrp_production_property_rel',
188+ 'production_id',
189+ 'property_id',
190+ 'Properties'
191+ ),
192+ }
193+
194+
195+class procurement_order(orm.Model):
196+ _inherit = "procurement.order"
197+
198+ def make_mo(self, cr, uid, ids, context=None):
199+ res = super(procurement_order, self).make_mo(
200+ cr, uid, ids, context=context)
201+ production_obj = self.pool.get('mrp.production')
202+ for procurement_id, produce_id in res.iteritems():
203+ procurement = self.browse(
204+ cr, uid, procurement_id, context=context)
205+ production = production_obj.browse(
206+ cr, uid, produce_id, context=context)
207+ vals = {
208+ 'property_ids': [
209+ (6, 0, [x.id for x in procurement.property_ids])
210+ ]
211+ }
212+ production.write(vals, context=context)
213+ return res
214
215=== added file 'mrp_production_properties/mrp_view.xml'
216--- mrp_production_properties/mrp_view.xml 1970-01-01 00:00:00 +0000
217+++ mrp_production_properties/mrp_view.xml 2014-05-14 16:41:19 +0000
218@@ -0,0 +1,17 @@
219+<?xml version="1.0" encoding="utf-8"?>
220+<openerp>
221+ <data>
222+
223+ <record id="mrp_production_form_view" model="ir.ui.view">
224+ <field name="name">mrp.production.form</field>
225+ <field name="model">mrp.production</field>
226+ <field name="inherit_id" ref="mrp.mrp_production_form_view"/>
227+ <field name="arch" type="xml">
228+ <xpath expr="//field[@name='priority']" position="after">
229+ <field name="property_ids" widget="many2many_tags"/>
230+ </xpath>
231+ </field>
232+ </record>
233+
234+ </data>
235+</openerp>
236\ No newline at end of file
237
238=== added directory 'mrp_production_properties/test'
239=== added file 'mrp_production_properties/test/mrp_production_properties.yml'
240--- mrp_production_properties/test/mrp_production_properties.yml 1970-01-01 00:00:00 +0000
241+++ mrp_production_properties/test/mrp_production_properties.yml 2014-05-14 16:41:19 +0000
242@@ -0,0 +1,110 @@
243+-
244+ In order to test the mrp_production_properties,
245+ I start by creating a new product 'Slider Mobile'
246+-
247+ I create a product Slider Mobile
248+-
249+ !record {model: product.product, id: product_product_slidermobile0}:
250+ categ_id: product.product_category_1
251+ list_price: 200.0
252+ name: Slider Mobile
253+ procure_method: make_to_order
254+ standard_price: 189.0
255+ supply_method: produce
256+ type: product
257+ uom_id: product.product_uom_unit
258+ uom_po_id: product.product_uom_unit
259+-
260+ I create a Property Group named SM
261+-
262+ !record {model: mrp.property.group, id: mrp_property_group_slidermobile}:
263+ name: SM
264+-
265+ I create the property 'QWERTY Slider Mobile Phone' belongs to SM Property Group
266+-
267+ !record {model: mrp.property, id: mrp_property_slidermobile}:
268+ name: QWERTY Slider Mobile Phone
269+ group_id: mrp_property_group_slidermobile
270+ composition: min
271+-
272+ I create a Bill of Material record for Slider Mobile
273+-
274+ !record {model: mrp.bom, id: mrp_bom_slidermobile0}:
275+ company_id: base.main_company
276+ name: Slider Mobile
277+ product_efficiency: 1.0
278+ product_id: product_product_slidermobile0
279+ product_qty: 1.0
280+ product_uom: product.product_uom_unit
281+ product_uos_qty: 0.0
282+ sequence: 0.0
283+ type: normal
284+-
285+ I create a sale order for product Slider mobile
286+-
287+ !record {model: sale.order, id: sale_order_so0}:
288+ client_order_ref: ref1
289+ date_order: !eval time.strftime('%Y-%m-%d')
290+ invoice_quantity: order
291+ name: Test_SO001
292+ order_policy: manual
293+ partner_id: base.res_partner_4
294+ partner_invoice_id: base.res_partner_address_7
295+ partner_shipping_id: base.res_partner_address_7
296+ picking_policy: direct
297+ pricelist_id: product.list0
298+ shop_id: sale.sale_shop_1
299+-
300+ In the sale order I add one sale order line containing the Property 'QWERTY Slider Mobile Phone'
301+-
302+ !record {model: sale.order.line, id: line}:
303+ name: Slider Mobile
304+ product_id: product_product_slidermobile0
305+ product_uom_qty: 500.0
306+ product_uom: 1
307+ price_unit: 200
308+ order_id: sale_order_so0
309+ type: make_to_order
310+ property_ids:
311+ - mrp_property_slidermobile
312+-
313+ I confirm the sale order
314+-
315+ !workflow {model: sale.order, action: order_confirm, ref: sale_order_so0}
316+-
317+ I verify that a procurement has been generated for sale order
318+-
319+ !python {model: procurement.order}: |
320+ sale_order_obj = self.pool.get('sale.order')
321+ so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
322+ proc_ids = self.search(cr, uid, [('origin','=',so.name)])
323+ assert proc_ids, 'No Procurements!'
324+-
325+ Then I click on the "Run Procurement" button
326+-
327+ !python {model: procurement.order}: |
328+ sale_order_obj = self.pool.get('sale.order')
329+ so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
330+ import netsvc
331+ wf_service = netsvc.LocalService("workflow")
332+ proc_ids = self.search(cr, uid, [('origin','=',so.name)])
333+ for proc in proc_ids:
334+ wf_service.trg_validate(uid, 'procurement.order',proc,'button_check', cr)
335+-
336+ I verify that a procurement state is "running"
337+-
338+ !python {model: procurement.order}: |
339+ sale_order_obj = self.pool.get('sale.order')
340+ so = sale_order_obj.browse(cr, uid, ref("sale_order_so0"))
341+ proc_ids = self.search(cr, uid, [('origin','=',so.name) and ('state','=','running')])
342+ assert proc_ids, 'Procurement is not in the running state!'
343+-
344+ I verify that a manufacturing order has been generated, and its properties are matching with those on the sale order line
345+-
346+ !python {model: sale.order}: |
347+ mnf_obj = self.pool.get('mrp.production')
348+ so = self.browse(cr, uid, ref("sale_order_so0"))
349+ mnf_id = mnf_obj.search(cr, uid, [('origin','=',so.name)])
350+ assert mnf_id, 'Manufacturing order has not been generated'
351+ mo = mnf_obj.browse(cr, uid, mnf_id)[0]
352+ 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.'