Merge lp:~vauxoo/addons-vauxoo/mrp_production_make_wzd_dev_luis into lp:addons-vauxoo

Proposed by Luis Torres - http://www.vauxoo.com
Status: Merged
Merged at revision: 398
Proposed branch: lp:~vauxoo/addons-vauxoo/mrp_production_make_wzd_dev_luis
Merge into: lp:addons-vauxoo
Diff against target: 266 lines (+235/-0)
6 files modified
mrp_production_make_wzd/__init__.py (+26/-0)
mrp_production_make_wzd/__openerp__.py (+47/-0)
mrp_production_make_wzd/wizard/__init__.py (+26/-0)
mrp_production_make_wzd/wizard/mrp_view.xml (+27/-0)
mrp_production_make_wzd/wizard/wizard_production_make.py (+79/-0)
mrp_production_make_wzd/wizard/wizard_production_make.xml (+30/-0)
To merge this branch: bzr merge lp:~vauxoo/addons-vauxoo/mrp_production_make_wzd_dev_luis
Reviewer Review Type Date Requested Status
Julio Serna-http://www.vauxoo.com Needs Resubmitting
Luis Torres - http://www.vauxoo.com Needs Resubmitting
Moisés López - http://www.vauxoo.com Pending
Review via email: mp+119446@code.launchpad.net

Description of the change

Este modulo agrega un wizard para agregar varias ordenes de produccion indicando el producto que se desea fabricar.

To post a comment you must log in.
Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se cambio la sintaxis de algunas lineas

review: Needs Resubmitting
Revision history for this message
Julio Serna-http://www.vauxoo.com (hearthebreaker) wrote :

Luis,
En el __openerp__.py en la key name se te fue lo mismo que en tu modulo pasado hay que cambiarlo.
En el py del wizard cuando vas utilizar el browse y estas dentro de la misma funcion no es necesario que hagas esto: new_production_obj=self.pool.get('wizard.production.make')
       products=new_production_obj.browse(cr, uid, ids, context=context)[0]
si ya estas ahi mismo con el puro self funciona : new_production_obj=products=self.browse(cr,uid,ids,context=context)[0]
pero a si corre el riesgo de que te marque error si esa función la mandan a llamar fuera del wizard y en ids no te mandan una lista, hay que cambiarlo mejor para que itere dentro del for.

En esta if:
if product.categ_id.location_src_id.id:
  location_src=product.categ_id.location_src_id.id
else:
   location_src=products.location_src_id.id
if product.categ_id.location_dest_id.id:
    location_dest=product.categ_id.location_dest_id.id
else:
    location_dest=products.location_dest_id.id

los puedes reducir si utilizas un or ejemplo:

location_src=product.categ_id.location_src_id.id or products.location_src_id.id

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'mrp_production_make_wzd'
2=== added file 'mrp_production_make_wzd/__init__.py'
3--- mrp_production_make_wzd/__init__.py 1970-01-01 00:00:00 +0000
4+++ mrp_production_make_wzd/__init__.py 2012-08-13 23:28:20 +0000
5@@ -0,0 +1,26 @@
6+# -*- encoding: utf-8 -*-
7+###########################################################################
8+# Module Writen to OpenERP, Open Source Management Solution
9+#
10+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
11+# All Rights Reserved.
12+# info Vauxoo (info@vauxoo.com)
13+############################################################################
14+# Coded by: Luis Torres (luis_t@vauxoo.com)
15+############################################################################
16+#
17+# This program is free software: you can redistribute it and/or modify
18+# it under the terms of the GNU Affero General Public License as
19+# published by the Free Software Foundation, either version 3 of the
20+# License, or (at your option) any later version.
21+#
22+# This program is distributed in the hope that it will be useful,
23+# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+# GNU Affero General Public License for more details.
26+#
27+# You should have received a copy of the GNU Affero General Public License
28+# along with this program. If not, see <http://www.gnu.org/licenses/>.
29+#
30+##############################################################################
31+import wizard
32
33=== added file 'mrp_production_make_wzd/__openerp__.py'
34--- mrp_production_make_wzd/__openerp__.py 1970-01-01 00:00:00 +0000
35+++ mrp_production_make_wzd/__openerp__.py 2012-08-13 23:28:20 +0000
36@@ -0,0 +1,47 @@
37+# -*- encoding: utf-8 -*-
38+###########################################################################
39+# Module Writen to OpenERP, Open Source Management Solution
40+#
41+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
42+# All Rights Reserved.
43+# info Vauxoo (info@vauxoo.com)
44+############################################################################
45+# Coded by: Luis Torres (luis_t@vauxoo.com)
46+############################################################################
47+#
48+# This program is free software: you can redistribute it and/or modify
49+# it under the terms of the GNU Affero General Public License as
50+# published by the Free Software Foundation, either version 3 of the
51+# License, or (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU Affero General Public License for more details.
57+#
58+# You should have received a copy of the GNU Affero General Public License
59+# along with this program. If not, see <http://www.gnu.org/licenses/>.
60+#
61+##############################################################################
62+
63+{
64+ "name" : "Production Make Wzd",
65+ "version" : "1.0",
66+ "author" : "Vauxoo",
67+ "category" : "Generic Modules",
68+ "description" : """
69+ This module add wizard for create order of production
70+ """,
71+ "website" : "http://www.vauxoo.com/",
72+ "license" : "AGPL-3",
73+ "depends" : ["mrp_default_location"
74+ ],
75+ "init_xml" : [],
76+ "demo_xml" : [],
77+ "update_xml" : [
78+ "wizard/wizard_production_make.xml",
79+ "wizard/mrp_view.xml",
80+ ],
81+ "installable" : True,
82+ "active" : False,
83+}
84
85=== added directory 'mrp_production_make_wzd/wizard'
86=== added file 'mrp_production_make_wzd/wizard/__init__.py'
87--- mrp_production_make_wzd/wizard/__init__.py 1970-01-01 00:00:00 +0000
88+++ mrp_production_make_wzd/wizard/__init__.py 2012-08-13 23:28:20 +0000
89@@ -0,0 +1,26 @@
90+# -*- encoding: utf-8 -*-
91+###########################################################################
92+# Module Writen to OpenERP, Open Source Management Solution
93+#
94+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
95+# All Rights Reserved.
96+# info Vauxoo (info@vauxoo.com)
97+############################################################################
98+# Coded by: Luis Torres (luis_t@vauxoo.com)
99+############################################################################
100+#
101+# This program is free software: you can redistribute it and/or modify
102+# it under the terms of the GNU Affero General Public License as
103+# published by the Free Software Foundation, either version 3 of the
104+# License, or (at your option) any later version.
105+#
106+# This program is distributed in the hope that it will be useful,
107+# but WITHOUT ANY WARRANTY; without even the implied warranty of
108+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
109+# GNU Affero General Public License for more details.
110+#
111+# You should have received a copy of the GNU Affero General Public License
112+# along with this program. If not, see <http://www.gnu.org/licenses/>.
113+#
114+##############################################################################
115+import wizard_production_make
116
117=== added file 'mrp_production_make_wzd/wizard/mrp_view.xml'
118--- mrp_production_make_wzd/wizard/mrp_view.xml 1970-01-01 00:00:00 +0000
119+++ mrp_production_make_wzd/wizard/mrp_view.xml 2012-08-13 23:28:20 +0000
120@@ -0,0 +1,27 @@
121+<?xml version="1.0" encoding="utf-8"?>
122+<openerp>
123+ <data>
124+ <record model="ir.ui.view" id="view_mrp_inherit_view_tree">
125+ <field name="name">view.mrp.inherit.view.tree</field>
126+ <field name="model">mrp.production</field>
127+ <field name="type">tree</field>
128+ <field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
129+ <field name="arch" type="xml">
130+ <xpath expr="/tree" position="replace">
131+ <tree colors="blue:state in ('draft','confirmed');red:date_planned&lt;current_date and state not in ('done','cancel');black:date_planned&gt;=current_date;gray:state in ('done','cancel') " string="Manufacturing Orders" editable="True">
132+ <field name="name"/>
133+ <field name="date_planned"/>
134+ <field name="product_id"/>
135+ <field name="product_qty" sum="Total Qty"/>
136+ <field name="product_uom"/>
137+ <field name="routing_id" groups="base.group_extended"/>
138+ <field name="hour_total" sum="Total Hours" groups="base.group_extended"/>
139+ <field name="cycle_total" sum="Total Cycles" groups="base.group_extended"/>
140+ <field name="origin"/>
141+ <field name="state"/>
142+ </tree>
143+ </xpath>
144+ </field>
145+ </record>
146+ </data>
147+</openerp>
148
149=== added file 'mrp_production_make_wzd/wizard/wizard_production_make.py'
150--- mrp_production_make_wzd/wizard/wizard_production_make.py 1970-01-01 00:00:00 +0000
151+++ mrp_production_make_wzd/wizard/wizard_production_make.py 2012-08-13 23:28:20 +0000
152@@ -0,0 +1,79 @@
153+# -*- encoding: utf-8 -*-
154+###########################################################################
155+# Module Writen to OpenERP, Open Source Management Solution
156+#
157+# Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
158+# All Rights Reserved.
159+# info Vauxoo (info@vauxoo.com)
160+############################################################################
161+# Coded by: Luis Torres (luis_t@vauxoo.com)
162+############################################################################
163+#
164+# This program is free software: you can redistribute it and/or modify
165+# it under the terms of the GNU Affero General Public License as
166+# published by the Free Software Foundation, either version 3 of the
167+# License, or (at your option) any later version.
168+#
169+# This program is distributed in the hope that it will be useful,
170+# but WITHOUT ANY WARRANTY; without even the implied warranty of
171+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
172+# GNU Affero General Public License for more details.
173+#
174+# You should have received a copy of the GNU Affero General Public License
175+# along with this program. If not, see <http://www.gnu.org/licenses/>.
176+#
177+##############################################################################
178+from osv import osv, fields
179+import decimal_precision as dp
180+import time
181+from tools.translate import _
182+
183+class wizard_production_make(osv.osv_memory):
184+ _name='wizard.production.make'
185+
186+ _columns = {
187+ 'products_ids': fields.many2many('product.product','production_make','product_id','production_make_id','Products'),
188+ 'date_planned': fields.datetime('Scheduled date', required=True, select=1),
189+ 'location_src_id': fields.many2one('stock.location', 'Raw Materials Location',
190+ readonly=False, help="Location where the system will look for components."),
191+ 'location_dest_id': fields.many2one('stock.location', 'Finished Products Location',
192+ readonly=False, help="Location where the system will stock the finished products."),
193+ }
194+ _defaults = {
195+ 'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
196+ }
197+
198+ def action_add_production(self, cr, uid, ids, context=None):
199+ production_obj=self.pool.get('mrp.production')
200+ product_obj=self.pool.get('product.product')
201+ wiz_product=self.browse(cr, uid, ids, context=context)
202+ list_orders=[]
203+ for products in wiz_product:
204+ for product in products.products_ids:
205+ data_product=product_obj.browse(cr, uid, product.id, context=context).uom_id.id
206+ if not product.categ_id.location_src_id.id and not products.location_src_id.id:
207+ raise osv.except_osv(_('Error!'),_("Not set a location of raw material for the product: "+product.name))
208+ if not product.categ_id.location_dest_id.id and not products.location_dest_id.id:
209+ raise osv.except_osv(_('Error!'),_("Not set a location of finished products for the product: "+product.name))
210+ location_src = product.categ_id.location_src_id.id or products.location_src_id.id
211+ location_dest=product.categ_id.location_dest_id.id or products.location_dest_id.id
212+ production_id=production_obj.create(cr, uid, {
213+ 'product_id': product.id,
214+ 'product_qty': '1.0',
215+ 'product_uom': data_product,
216+ 'date_planned': products.date_planned ,
217+ 'location_src_id':location_src,
218+ 'location_dest_id':location_dest,
219+ })
220+ list_orders.append(production_id)
221+ return {
222+ 'name': 'Customer Invoices',
223+ 'view_type': 'form',
224+ 'view_mode': 'tree,form',
225+ 'res_model': 'mrp.production',
226+ 'type': 'ir.actions.act_window',
227+ 'domain': [('id', 'in', list_orders)],
228+ }
229+
230+wizard_production_make()
231+
232
233=== added file 'mrp_production_make_wzd/wizard/wizard_production_make.xml'
234--- mrp_production_make_wzd/wizard/wizard_production_make.xml 1970-01-01 00:00:00 +0000
235+++ mrp_production_make_wzd/wizard/wizard_production_make.xml 2012-08-13 23:28:20 +0000
236@@ -0,0 +1,30 @@
237+<?xml version="1.0" encoding="utf-8"?>
238+<openerp>
239+ <data>
240+ <record model="ir.ui.view" id="view_wizard_production_make_form">
241+ <field name="name">view.wizard.production.make.form</field>
242+ <field name="model">wizard.production.make</field>
243+ <field name="type">form</field>
244+ <field name="arch" type="xml">
245+ <form string="Production Make">
246+ <field name="date_planned" />
247+ <newline/>
248+ <field name="location_src_id"/>
249+ <field name="location_dest_id"/>
250+ <field name="products_ids" nolabel="1" colspan="4"/>
251+ <button type="special" special="cancel" string="_Cancel" icon="gtk-cancel"/>
252+ <button type="object" string="Add Production" name="action_add_production" icon="gtk-ok"/>
253+ </form>
254+ </field>
255+ </record>
256+ <record id="act_mrp_product_produce_wizard" model="ir.actions.act_window">
257+ <field name="name">Production Make</field>
258+ <field name="type">ir.actions.act_window</field>
259+ <field name="res_model">wizard.production.make</field>
260+ <field name="view_type">form</field>
261+ <field name="view_mode">form</field>
262+ <field name="target">new</field>
263+ </record>
264+ <menuitem id="menu_action_mrp_product_produce_wizard_form" name="Add Many Manufacturing Orders" parent="mrp.menu_mrp_manufacturing" action="act_mrp_product_produce_wizard"/>
265+ </data>
266+</openerp>