+7
-5
@@ -397,10 +397,10 @@ class mrp_production(osv.osv):
|
||||
'priority': fields.selection([('0','Not urgent'),('1','Normal'),('2','Urgent'),('3','Very Urgent')], 'Priority'),
|
||||
|
||||
'product_id': fields.many2one('product.product', 'Product', required=True, domain=[('type','<>','service')]),
|
||||
'product_qty': fields.float('Product Qty', required=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
|
||||
'product_uos_qty': fields.float('Product UoS Qty'),
|
||||
'product_uos': fields.many2one('product.uom', 'Product UoS'),
|
||||
'product_qty': fields.float('Product Qty', required=True, states={'draft':[('readonly',False)]}, readonly=True),
|
||||
'product_uom': fields.many2one('product.uom', 'Product UOM', required=True, states={'draft':[('readonly',False)]}, readonly=True),
|
||||
'product_uos_qty': fields.float('Product UoS Qty', states={'draft':[('readonly',False)]}, readonly=True),
|
||||
'product_uos': fields.many2one('product.uom', 'Product UoS', states={'draft':[('readonly',False)]}, readonly=True),
|
||||
|
||||
'location_src_id': fields.many2one('stock.location', 'Raw Materials Location', required=True,
|
||||
help="Location where the system will look for products used in raw materials."),
|
||||
@@ -836,11 +836,13 @@ class mrp_procurement(osv.osv):
|
||||
|
||||
def check_move_cancel(self, cr, uid, ids, context={}):
|
||||
res = True
|
||||
ok = False
|
||||
for procurement in self.browse(cr, uid, ids, context):
|
||||
if procurement.move_id:
|
||||
ok = True
|
||||
if not procurement.move_id.state=='cancel':
|
||||
res = False
|
||||
return res
|
||||
return res and ok
|
||||
|
||||
def check_move_done(self, cr, uid, ids, context={}):
|
||||
res = True
|
||||
|
||||
@@ -451,7 +451,7 @@
|
||||
<field name="product_id" on_change="product_id_change(product_id)" select="1"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<button type="action" name="%(mrp.wizard_change_production_qty)d" string="Change Qty" states="ready,in_production"/>
|
||||
<button type="action" name="%(mrp.wizard_change_production_qty)d" string="Change Qty" states="ready,confirmed,in_production"/>
|
||||
<newline/>
|
||||
<label string="" colspan="2"/>
|
||||
<field name="product_uos_qty" groups="product.group_uos"/>
|
||||
|
||||
@@ -27,17 +27,21 @@ 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'),
|
||||
}
|
||||
'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),
|
||||
'subproduct_type': fields.selection([('fixed','Fixed'),('variable','Variable')], 'Quantity Type', required=True),
|
||||
'bom_id': fields.many2one('mrp.bom', 'BoM'),
|
||||
}
|
||||
_defaults={
|
||||
'subproduct_type': lambda *args: 'fixed'
|
||||
}
|
||||
def onchange_product_id(self, cr, uid, ids, product_id,context={}):
|
||||
if product_id:
|
||||
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 {}
|
||||
return {}
|
||||
|
||||
mrp_subproduct()
|
||||
|
||||
@@ -46,10 +50,8 @@ class mrp_bom(osv.osv):
|
||||
_description = 'Bill of Material'
|
||||
_inherit='mrp.bom'
|
||||
_columns={
|
||||
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
|
||||
}
|
||||
|
||||
|
||||
'sub_products':fields.one2many('mrp.subproduct', 'bom_id', 'sub_products'),
|
||||
}
|
||||
mrp_bom()
|
||||
|
||||
class mrp_production(osv.osv):
|
||||
@@ -61,15 +63,21 @@ class mrp_production(osv.osv):
|
||||
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:
|
||||
|
||||
for sub_product in production.bom_id.sub_products:
|
||||
qty1 = sub_product.product_qty
|
||||
qty2 = production.product_uos and production.product_uos_qty or False
|
||||
if sub_product.subproduct_type=='variable':
|
||||
if production.product_qty:
|
||||
qty1 *= production.product_qty / (sub_product.product_qty or 1.0)
|
||||
if production.product_uos_qty:
|
||||
qty2 *= production.product_uos_qty / (sub_product.product_qty or 1.0)
|
||||
data = {
|
||||
'name':'PROD:'+production.name,
|
||||
'date_planned': production.date_planned,
|
||||
'product_id': sub_product.product_id.id,
|
||||
'product_qty': sub_product.product_qty,
|
||||
'product_qty': qty1,
|
||||
'product_uom': sub_product.product_uom.id,
|
||||
'product_uos_qty': production.product_uos and production.product_uos_qty or False,
|
||||
'product_uos_qty': qty2,
|
||||
'product_uos': production.product_uos and production.product_uos.id or False,
|
||||
'location_id': source,
|
||||
'location_dest_id': production.location_dest_id.id,
|
||||
|
||||
@@ -1,28 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="mrp_subproduct_view" model="ir.ui.view">
|
||||
<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>
|
||||
<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"/>
|
||||
<field name="subproduct_type"/>
|
||||
</tree>
|
||||
<form string="Sub Products">
|
||||
<field name="product_id" on_change="onchange_product_id(product_id)"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="subproduct_type"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user