1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ##############################################################################
31 from osv import fields
34 class mrp_subproduct(osv.osv):
35 _name = 'mrp.subproduct'
36 _description = 'Mrp Sub Product'
38 'product_id': fields.many2one('product.product', 'Product', required=True),
39 'product_qty': fields.float('Product Qty', required=True),
40 'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
41 'bom_id': fields.many2one('mrp.bom', 'BoM'),
43 def onchange_product_id(self, cr, uid, ids, product_id,context={}):
45 prod=self.pool.get('product.product').browse(cr,uid,product_id)
46 v = {'product_uom':prod.uom_id.id}
52 class mrp_bom(osv.osv):
54 _description = 'Bill of Material'
57 'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
63 class mrp_production(osv.osv):
64 _name = 'mrp.production'
65 _description = 'Production'
66 _inherit= 'mrp.production'
70 def action_confirm(self, cr, uid, ids):
71 picking_id=super(mrp_production,self).action_confirm(cr, uid, ids)
72 for production in self.browse(cr, uid, ids):
73 source = production.product_id.product_tmpl_id.property_stock_production.id
74 for sub_product in production.bom_id.sub_products:
75 print "::::::::",sub_product.product_id.id,sub_product.product_uom.id,sub_product.product_qty,production.id
78 'name':'PROD:'+production.name,
79 'date_planned': production.date_planned,
80 'product_id': sub_product.product_id.id,
81 'product_qty': sub_product.product_qty,
82 'product_uom': sub_product.product_uom.id,
83 'product_uos_qty': production.product_uos and production.product_uos_qty or False,
84 'product_uos': production.product_uos and production.product_uos.id or False,
85 'location_id': source,
86 'location_dest_id': production.location_dest_id.id,
87 'move_dest_id': production.move_prod_id.id,
89 'production_id':production.id
91 sub_prod_ids=self.pool.get('stock.move').create(cr, uid,data)