designed a module mrp_subproduct, that adds a tab on the mrp.bom

object called 'sub product' with a one2many in editable list with a
few fields:
* product_id
* product_qty
* product_uom
 
When creating the mrp.production, added these products, in the finnished
products tab. kept this module in the profile_manufacturing configuration wizard.

bzr revid: nch@tinyerp.com-20081010133646-v2eb3s4p0yjy4fd8
This commit is contained in:
Naresh Choksy 2008-10-10 19:06:46 +05:30
parent c9da48bc5b
commit 8c307d7b1d
6 changed files with 174 additions and 1 deletions

View File

@ -0,0 +1 @@
import mrp_subproduct

View File

@ -0,0 +1,46 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 Tiny SPRL (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
###############################################################################
{
"name" : "MRP Sub Product",
"version" : "1.0",
"author" : "Tiny",
"website" : "http://tinyerp.com/module_stock.html",
"depends" : ["base","mrp"],
"category" : "Generic Modules/Production",
"init_xml" : [],
"demo_xml" : [],
"update_xml" : [
"mrp_subproduct_view.xml",
],
"active": False,
"installable": True
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,94 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# $Id$
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from osv import fields
from osv import osv
class mrp_subproduct(osv.osv):
_name = 'mrp.subproduct'
_description = 'Mrp Sub Product'
_columns={
'product_id': fields.many2one('product.product', 'Product', required=True),
'product_qty': fields.float('Product Qty', required=True),
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
'bom_id': fields.many2one('mrp.bom', 'BoM'),
}
def onchange_product_id(self, cr, uid, ids, product_id,context={}):
if product_id:
prod=self.pool.get('product.product').browse(cr,uid,product_id)
v = {'product_uom':prod.uom_id.id}
return {'value': v}
return {}
mrp_subproduct()
class mrp_bom(osv.osv):
_name = 'mrp.bom'
_description = 'Bill of Material'
_inherit='mrp.bom'
_columns={
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
}
mrp_bom()
class mrp_production(osv.osv):
_name = 'mrp.production'
_description = 'Production'
_inherit= 'mrp.production'
_columns={
}
def action_confirm(self, cr, uid, ids):
picking_id=super(mrp_production,self).action_confirm(cr, uid, ids)
for production in self.browse(cr, uid, ids):
source = production.product_id.product_tmpl_id.property_stock_production.id
for sub_product in production.bom_id.sub_products:
print "::::::::",sub_product.product_id.id,sub_product.product_uom.id,sub_product.product_qty,production.id
data = {
'name':'PROD:'+production.name,
'date_planned': production.date_planned,
'product_id': sub_product.product_id.id,
'product_qty': sub_product.product_qty,
'product_uom': sub_product.product_uom.id,
'product_uos_qty': production.product_uos and production.product_uos_qty or False,
'product_uos': production.product_uos and production.product_uos.id or False,
'location_id': source,
'location_dest_id': production.location_dest_id.id,
'move_dest_id': production.move_prod_id.id,
'state': 'waiting',
'production_id':production.id
}
sub_prod_ids=self.pool.get('stock.move').create(cr, uid,data)
return picking_id
mrp_production()

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_subproduct_view" model="ir.ui.view">
<field name="name">mrp.bom.sub.product</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_form_view"/>
<field name="type">form</field>
<field name="arch" type="xml">
<notebook>
<page string="sub products" position="inside">
<field colspan="4" name="sub_products" nolabel="1" widget="one2many_list">
<tree string="sub products" editable="top">
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="product_uom"/>
<field name="product_qty"/>
</tree>
<form string="sub products">
<field name="product_id" on_change="onchange_product_id(product_id)"/>
<field name="product_uom"/>
<field name="product_qty"/>
</form>
</field>
</page>
</notebook>
</field>
</record>
</data>
</openerp>

View File

@ -69,7 +69,9 @@ class profile_manufacturing_config_install_modules_wizard(osv.osv_memory):
"our frontend point of sale for a perfect ergonomy with touchscreen "\
"materials and payment processing hardware."),
'portal': fields.boolean('Portal',
help="This module allows you to manage a Portal system.")
help="This module allows you to manage a Portal system."),
'mrp_subproduct': fields.boolean('Mrp Sub Product',
help="This module allows you to add sub poducts in mrp bom.")
}
def action_cancel(self,cr,uid,ids,conect=None):
return {

View File

@ -11,6 +11,7 @@
<field name="stock_location"/>
<field name="mrp_jit"/>
<field name="mrp_operation"/>
<field name="mrp_subproduct"/>
<separator string="Sales Management" colspan="4"/>
<field name="point_of_sale"/>
<field name="sale_journal"/>