Merged mrp_bom_hyerarchy into BoM module.

Changed the tree view of a BoM so that it uses the child_complete_id instead of the current one2many.

bzr revid: nch@tinyerp.com-20081010085913-6pev3fjzf0ag0j89
This commit is contained in:
Naresh Choksy 2008-10-10 14:29:13 +05:30
parent 7a4d5d9458
commit 03a8f3bfe9
3 changed files with 62 additions and 50 deletions

View File

@ -47,7 +47,8 @@
* Cost method by product: standard price, average price
* Easy analysis of troubles or needs
* Very flexible
* Allows to browse Bill of Materials in complete structure
that include child and phantom BoMs
It supports complete integration and planification of stockable goods,
consumable of services. Services are completly integrated with the rest
of the software. For instance, you can set up a sub-contracting service

View File

@ -39,7 +39,7 @@ from mx import DateTime
#----------------------------------------------------------
# Workcenters
#----------------------------------------------------------
# capacity_hour : capacity per hour. default: 1.0.
# capacity_hour : capacity per hour. default: 1.0.
# Eg: If 5 concurrent operations at one time: capacity = 5 (because 5 employees)
# unit_per_cycle : how many units are produced for one cycle
#
@ -115,7 +115,7 @@ class mrp_routing(osv.osv):
'note': fields.text('Description'),
'workcenter_lines': fields.one2many('mrp.routing.workcenter', 'routing_id', 'Workcenters'),
'location_id': fields.many2one('stock.location', 'Production Location',
'location_id': fields.many2one('stock.location', 'Production Location',
help="Keep empty if you produce at the location where the finnished products are needed." \
"Put a location if you produce at a fixed location. This can be a partner location " \
"if you subcontract the manufacturing operations."
@ -147,6 +147,17 @@ mrp_routing_workcenter()
class mrp_bom(osv.osv):
_name = 'mrp.bom'
_description = 'Bill of Material'
def _child_compute(self, cr, uid, ids, name, arg, context={}):
result = {}
for bom in self.browse(cr, uid, ids, context=context):
result[bom.id] = map(lambda x: x.id, bom.bom_lines)
ok = ((name=='child_complete_ids') and (bom.product_id.supply_method=='produce'))
if bom.type=='phantom' or ok:
sids = self.pool.get('mrp.bom').search(cr, uid, [('bom_id','=',False),('product_id','=',bom.product_id.id)])
if sids:
bom2 = self.pool.get('mrp.bom').browse(cr, uid, sids[0], context=context)
result[bom.id] += map(lambda x: x.id, bom2.bom_lines)
return result
def _compute_type(self, cr, uid, ids, field_name, arg, context):
res = dict(map(lambda x: (x,''), ids))
for line in self.browse(cr, uid, ids):
@ -185,7 +196,9 @@ class mrp_bom(osv.osv):
'routing_id': fields.many2one('mrp.routing', 'Routing', help="The list of operations (list of workcenters) to produce the finnished product. The routing is mainly used to compute workcenter costs during operations and to plan futur loads on workcenters based on production plannification."),
'property_ids': fields.many2many('mrp.property', 'mrp_bom_property_rel', 'bom_id','property_id', 'Properties'),
'revision_ids': fields.one2many('mrp.bom.revision', 'bom_id', 'BoM Revisions'),
'revision_type': fields.selection([('numeric','numeric indices'),('alpha','alphabetical indices')], 'indice type')
'revision_type': fields.selection([('numeric','numeric indices'),('alpha','alphabetical indices')], 'indice type'),
'child_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hyerarchy", type='many2many'),
'child_complete_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hyerarchy", type='many2many')
}
_defaults = {
'active': lambda *a: 1,
@ -198,6 +211,7 @@ class mrp_bom(osv.osv):
_sql_constraints = [
('bom_qty_zero', 'CHECK (product_qty>0)', 'All product quantities must be greater than 0 !'),
]
def _check_recursion(self, cr, uid, ids):
level = 500
while len(ids):
@ -211,7 +225,7 @@ class mrp_bom(osv.osv):
(_check_recursion, 'Error ! You can not create recursive BoM.', ['parent_id'])
]
def onchange_product_id(self, cr, uid, ids, product_id, name, context={}):
if product_id:
prod=self.pool.get('product.product').browse(cr,uid,[product_id])[0]
@ -283,7 +297,7 @@ class mrp_bom(osv.osv):
def set_indices(self, cr, uid, ids, context = {}):
if not ids or (ids and not ids[0]):
return True
return True
res = self.read(cr, uid, ids, ['revision_ids', 'revision_type'])
rev_ids = res[0]['revision_ids']
idx = 1
@ -310,7 +324,7 @@ class mrp_bom_revision(osv.osv):
'author_id': fields.many2one('res.users', 'Author'),
'bom_id': fields.many2one('mrp.bom', 'BoM', select=True),
}
_defaults = {
'author_id': lambda x,y,z,c: z,
'date': lambda *a: time.strftime('%Y-%m-%d'),
@ -603,7 +617,7 @@ class mrp_production(osv.osv):
'state': 'waiting'
}
res_final_id = self.pool.get('stock.move').create(cr, uid, data)
self.write(cr, uid, [production.id], {'move_created_ids': [(6, 'WTF', [res_final_id])]})
moves = []
for line in production.product_lines:
@ -973,14 +987,14 @@ class mrp_procurement(osv.osv):
newdate = newdate - DateTime.RelativeDateTime(days=company.po_lead)
context.update({'lang':partner.lang})
product=self.pool.get('product.product').browse(cr,uid,procurement.product_id.id,context=context)
line = {
'name': product.name,
'product_qty': qty,
'product_id': procurement.product_id.id,
'product_uom': uom_id,
'price_unit': price,
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
'move_dest_id': res_id,
'notes':product.description_purchase,
}
@ -991,7 +1005,7 @@ class mrp_procurement(osv.osv):
if partner_id:
taxep_id = self.pool.get('res.partner').property_get(cr, uid,partner_id,property_pref=['property_account_supplier_tax']).get('property_account_supplier_tax',False)
if taxep_id:
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
taxep=self.pool.get('account.tax').browse(cr, uid,taxep_id)
if not taxep or not taxep.id:
taxes_ids = [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id]
else:

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<menuitem icon="terp-mrp" id="menu_mrp_root" name="Manufacturing"/>
<!--
Property / Property Group
-->
<record id="mrp_property_group_form_view" model="ir.ui.view">
<field name="name">mrp.property.group.form</field>
<field name="model">mrp.property.group</field>
@ -30,7 +30,7 @@
<menuitem id="menu_mrp_configuration" name="Configuration" parent="menu_mrp_root"/>
<menuitem id="menu_mrp_property_group_action_prop" name="Properties" parent="menu_mrp_configuration"/>
<menuitem action="mrp_property_group_action" id="menu_mrp_property_group_action" parent="menu_mrp_property_group_action_prop"/>
<record id="mrp_property_tree_view" model="ir.ui.view">
<field name="name">mrp.property.tree</field>
<field name="model">mrp.property</field>
@ -66,11 +66,11 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem action="mrp_property_action" id="menu_mrp_property_action" parent="menu_mrp_property_group_action_prop"/>
<!--
Workcenters
-->
<record id="mrp_workcenter_tree_view" model="ir.ui.view">
<field name="name">mrp.workcenter.tree</field>
<field name="model">mrp.workcenter</field>
@ -129,11 +129,11 @@
<field name="view_id" ref="mrp_workcenter_tree_view"/>
</record>
<menuitem action="mrp_workcenter_action" id="menu_mrp_workcenter_action" parent="menu_mrp_configuration"/>
<!--
Routings
-->
<record id="mrp_routing_workcenter_tree_view" model="ir.ui.view">
<field name="name">mrp.routing.workcenter.tree</field>
<field name="model">mrp.routing.workcenter</field>
@ -147,7 +147,7 @@
</tree>
</field>
</record>
<record id="mrp_routing_workcenter_form_view" model="ir.ui.view">
<field name="name">mrp.routing.workcenter.form</field>
<field name="model">mrp.routing.workcenter</field>
@ -164,7 +164,7 @@
</form>
</field>
</record>
<record id="mrp_routing_form_view" model="ir.ui.view">
<field name="name">mrp.routing.form</field>
<field name="model">mrp.routing</field>
@ -203,11 +203,11 @@
<field name="view_id" ref="mrp_routing_tree_view"/>
</record>
<menuitem action="mrp_routing_action" id="menu_mrp_routing_action" parent="menu_mrp_configuration"/>
<!--
Bill of Materials
-->
<record id="mrp_bom_form_view" model="ir.ui.view">
<field name="name">mrp.bom.form</field>
<field name="model">mrp.bom</field>
@ -237,7 +237,7 @@
<field name="active" select="2"/>
<field name="sequence"/>
<field name="bom_id"/>
<field name="date_start" select="2"/>
<field name="date_stop" select="2"/>
<field name="product_rounding"/>
@ -248,11 +248,12 @@
</form>
</field>
</record>
<record id="mrp_bom_tree_view" model="ir.ui.view">
<record id="mrp_bom_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.tree</field>
<field name="model">mrp.bom</field>
<field name="type">tree</field>
<field name="field_parent">bom_lines</field>
<field name="field_parent">child_complete_ids</field>
<field name="arch" type="xml">
<tree string="BoM Structure">
<field name="product_id"/>
@ -274,7 +275,7 @@
<field name="view_id" ref="mrp_bom_tree_view"/>
</record>
<menuitem action="mrp_bom_form_action" id="menu_mrp_bom_form_action" parent="menu_mrp_configuration"/>
<record id="mrp_bom_tree_action" model="ir.actions.act_window">
<field name="name">Bill of Material Structure</field>
<field name="type">ir.actions.act_window</field>
@ -293,7 +294,7 @@
<field name="domain">[('bom_id','=',False)]</field>
</record>
<menuitem action="mrp_bom_form_action_new" id="menu_mrp_bom_form_action_new" parent="menu_mrp_bom_form_action"/>
<record id="mrp_bom_form_action2" model="ir.actions.act_window">
<field name="name">Bill of Materials Components</field>
<field name="type">ir.actions.act_window</field>
@ -311,14 +312,14 @@
<field name="view_type">tree</field>
<field name="view_id" ref="mrp_bom_tree_view"/>
</record>
<record id="ir_bom_architecture_open" model="ir.values">
<record id="ir_BOM_structure" model="ir.values">
<field eval="'client_action_multi'" name="key2"/>
<field eval="'mrp.bom'" name="model"/>
<field name="name">Bill of Materials Structure</field>
<field eval="'ir.actions.act_window,'+str(action2)" name="value"/>
<field eval="True" name="object"/>
</record>
<record id="mrp_bom_revision_tree" model="ir.ui.view">
<field name="name">mrp.bom.revision</field>
<field name="model">mrp.bom.revision</field>
@ -346,11 +347,11 @@
</form>
</field>
</record>
<!--
Production Management
-->
<record id="mrp_production_tree_view" model="ir.ui.view">
<field name="name">mrp.production.tree</field>
<field name="model">mrp.production</field>
@ -367,8 +368,7 @@
</tree>
</field>
</record>
<record id="view_production_calendar" model="ir.ui.view">
<field name="name">mrp.production.calendar</field>
<field name="model">mrp.production</field>
@ -393,8 +393,7 @@
</graph>
</field>
</record>
<record id="mrp_production_form_view" model="ir.ui.view">
<field name="name">mrp.production.form</field>
<field name="model">mrp.production</field>
@ -490,7 +489,7 @@
<field name="domain">[('state','=','confirmed')]</field>
</record>
<menuitem action="mrp_production_action4" id="menu_production_orders_waiting4" parent="mrp.menu_mrp_production_action"/>
<record id="mrp_production_new" model="ir.actions.act_window">
<field name="name">New Production Order</field>
<field name="type">ir.actions.act_window</field>
@ -499,7 +498,7 @@
<field name="view_mode">form,tree,calendar,graph</field>
</record>
<menuitem action="mrp_production_new" id="menu_production_orders_new" parent="mrp.menu_mrp_production_action"/>
<record id="mrp_production_workcenter_form_view" model="ir.ui.view">
<field name="name">mrp.production.workcenter.line.form</field>
<field name="model">mrp.production.workcenter.line</field>
@ -528,7 +527,7 @@
</tree>
</field>
</record>
<record id="mrp_production_lot_form_view" model="ir.ui.view">
<field name="name">mrp.production.lot.line.form</field>
<field name="model">mrp.production.lot.line</field>
@ -561,9 +560,7 @@
</tree>
</field>
</record>
<record id="mrp_production_product_form_view" model="ir.ui.view">
<field name="name">mrp.production.product.line.form</field>
<field name="model">mrp.production.product.line</field>
@ -593,11 +590,11 @@
</tree>
</field>
</record>
<!--
Procurement
-->
<record id="mrp_procurement_tree_view" model="ir.ui.view">
<field name="name">mrp.procurement.tree</field>
<field name="model">mrp.procurement</field>
@ -677,7 +674,7 @@
<field name="view_id" eval="False"/>
</record>
<menuitem action="mrp_procurement_action" id="menu_mrp_procurement_action" parent="mrp.menu_mrp_root" groups="base.group_extended" />
<record id="mrp_procurement_action2" model="ir.actions.act_window">
<field name="name">Draft procurements</field>
<field name="type">ir.actions.act_window</field>
@ -696,7 +693,7 @@
<field name="domain">[('state','=','confirmed')]</field>
</record>
<menuitem action="mrp_procurement_action3" id="menu_mrp_procurement_action3" parent="mrp.menu_mrp_procurement_action"/>
<record id="mrp_procurement_action5" model="ir.actions.act_window">
<field name="name">Exceptions procurements</field>
<field name="type">ir.actions.act_window</field>
@ -706,7 +703,7 @@
<field name="domain">[('state','=','exception')]</field>
</record>
<menuitem action="mrp_procurement_action5" id="menu_mrp_procurement_action5" parent="stock.menu_stock_root"/>
<record id="mrp_procurement_action4" model="ir.actions.act_window">
<field name="name">Exceptions procurements to fix</field>
<field name="type">ir.actions.act_window</field>
@ -716,7 +713,7 @@
<field name="domain">[('state','=','exception'), ('message', '&lt;&gt;', '')]</field>
</record>
<menuitem action="mrp_procurement_action4" id="menu_mrp_procurement_action4" parent="mrp.menu_mrp_procurement_action5"/>
<record id="mrp_procurement_action11" model="ir.actions.act_window">
<field name="name">Temporary Procurement Exceptions</field>
<field name="type">ir.actions.act_window</field>
@ -726,7 +723,7 @@
<field name="domain">[('state','=','exception'), ('message', '=', '')]</field>
</record>
<menuitem action="mrp_procurement_action11" id="menu_mrp_procurement_action11" parent="mrp.menu_mrp_procurement_action5"/>
<record id="mrp_procurement_new" model="ir.actions.act_window">
<field name="name">New Procurement</field>
<field name="type">ir.actions.act_window</field>
@ -735,7 +732,7 @@
<field name="view_mode">form,tree</field>
</record>
<menuitem action="mrp_procurement_new" id="menu_mrp_procurement_new" parent="mrp.menu_mrp_procurement_action"/>
<!-- Order Point -->
<record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
<field name="name">stock.warehouse.orderpoint.tree</field>