1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
8
############################################################################
9
# Coded by: fernandoL (fernando_ld@vauxoo.com)
10
############################################################################
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU Affero General Public License as
14
# published by the Free Software Foundation, either version 3 of the
15
# License, or (at your option) any later version.
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU Affero General Public License for more details.
22
# You should have received a copy of the GNU Affero General Public License
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
25
##############################################################################
27
from osv import osv, fields
28
import decimal_precision as dp
29
from tools.translate import _
31
class mrp_production_wizard(osv.osv_memory):
32
_name='mrp.production.wizard'
34
'product_id': fields.many2one('product.product', 'Product', required=True, ),
35
'wiz_data': fields.one2many('wizard.data', 'mrp_production_wiz', 'Prod lines'),
38
def pass_products_to_parent(self,cr,uid,ids,context={}):
41
wizard_data_data = self.browse(cr, uid, ids, context=context)
42
list_product_lines = []
44
for line in wizard_data_data:
45
product = line.product_id
46
for move in line.wiz_data:
49
'product_id' : move.product_id_consume.id,
50
'product_qty' : move.product_qty,
51
'product_uom' : move.product_uom.id}
52
list_product_lines.append(dict_line)
53
mrp_production_id = self.pool.get('mrp.production').create_production_wizard(cr, uid, product, list_product_lines, context=context)
55
mod_obj = self.pool.get('ir.model.data')
56
res = mod_obj.get_object_reference(cr, uid, 'mrp', 'mrp_production_form_view')
57
res_id = res and res[1] or False,
59
'name': _('Manufacturing orders'),
61
'view_mode': 'form,tree',
63
'res_model': 'mrp.production',
65
'type': 'ir.actions.act_window',
68
'res_id': mrp_production_id or False,
71
mrp_production_wizard()
73
class wizard_data(osv.osv_memory):
77
'mrp_production_wiz': fields.many2one('mrp.production.wizard', 'Padre'),
78
'name': fields.char('Name', size=64, required=True),
79
'product_id_consume': fields.many2one('product.product', 'Product', required=True),
80
'product_qty': fields.float('Product Qty', required=True),
81
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
84
def onchange_production_wizard_product_name(self, cr, uid, ids, product_id):
86
new_product_id = [product_id]
87
product_product_obj = self.pool.get('product.product')
88
product_product_data = product_product_obj.browse(cr, uid, new_product_id, context=None)
89
if product_product_data:
90
for line in product_product_data:
93
'product_uom' : line.uom_id.id,
94
'product_qty' : line.qty_available,
96
domain_uom = {'product_uom':[('category_id', '=', line.uom_id.category_id.id)]}
97
return {'value': val, 'domain': domain_uom}
b'\\ No newline at end of file'