[ADD]mrp: add product category on manufacturing order and bill of materials
This commit is contained in:
committed by
Christophe Matthieu
parent
a150716fd2
commit
9fa38eeab2
@@ -151,6 +151,9 @@ class mrp_bom(osv.osv):
|
||||
_description = 'Bill of Material'
|
||||
_inherit = ['mail.thread']
|
||||
|
||||
def _get_bom_ids_from_product_template_ids(self, cr, uid, product_template_ids, context=None):
|
||||
return self.pool['mrp.bom'].search(cr, uid, [('product_tmpl_id', 'in', product_template_ids)], context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name'),
|
||||
'code': fields.char('Reference', size=16),
|
||||
@@ -163,6 +166,11 @@ class mrp_bom(osv.osv):
|
||||
domain="['&', ('product_tmpl_id','=',product_tmpl_id), ('type','!=', 'service')]",
|
||||
help="If a product variant is defined the BOM is available only for this product."),
|
||||
'bom_line_ids': fields.one2many('mrp.bom.line', 'bom_id', 'BoM Lines', copy=True),
|
||||
'categ_id': fields.related('product_tmpl_id', 'categ_id', type='many2one', relation='product.category', string='Product Category', readonly=True,
|
||||
store = {
|
||||
'mrp.bom': (lambda self, cr, uid, ids, c=None: ids, ['product_tmpl_id'], 10),
|
||||
'product.template': (_get_bom_ids_from_product_template_ids, ['categ_id'], 10)
|
||||
}),
|
||||
'product_qty': fields.float('Product Quantity', required=True, digits_compute=dp.get_precision('Product Unit of Measure')),
|
||||
'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True, help="Unit of Measure (Unit of Measure) is the unit of measurement for the inventory control"),
|
||||
'date_start': fields.date('Valid From', help="Validity of this BoM. Keep empty if it's always valid."),
|
||||
@@ -541,6 +549,9 @@ class mrp_production(osv.osv):
|
||||
res += self.pool.get("mrp.production").search(cr, uid, [('move_lines', 'in', move.id)], context=context)
|
||||
return res
|
||||
|
||||
def _get_mo_ids_from_product_template_ids(self, cr, uid, product_template_ids, context=None):
|
||||
return self.pool["mrp.production"].search(cr, uid , [('product_id.product_tmpl_id', 'in', product_template_ids)], context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Reference', required=True, readonly=True, states={'draft': [('readonly', False)]}, copy=False),
|
||||
'origin': fields.char('Source Document', readonly=True, states={'draft': [('readonly', False)]},
|
||||
@@ -606,6 +617,11 @@ class mrp_production(osv.osv):
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'ready_production': fields.function(_moves_assigned, type='boolean', string="Ready for production", store={'stock.move': (_mrp_from_move, ['state'], 10)}),
|
||||
'product_tmpl_id': fields.related('product_id', 'product_tmpl_id', type='many2one', relation='product.template', string='Product'),
|
||||
'categ_id': fields.related('product_tmpl_id', 'categ_id', type='many2one', relation='product.category', string='Product Category', readonly=True,
|
||||
store = {
|
||||
'mrp.production': (lambda self, cr, uid, ids, c=None: ids, ['product_tmpl_id'], 10),
|
||||
'product.template': (_get_mo_ids_from_product_template_ids, ['categ_id'], 10)
|
||||
}),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
||||
@@ -396,6 +396,7 @@
|
||||
will contain the raw materials, instead of the finished product.
|
||||
</p>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field name="categ_id"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
@@ -466,12 +467,14 @@
|
||||
<field name="product_tmpl_id" string="Product"/>
|
||||
<field name="product_id" string="Variant"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="categ_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'product_tmpl_id'}"/>
|
||||
<filter string='Default Unit of Measure' icon="terp-mrp" domain="[]" context="{'group_by' : 'product_uom'}"/>
|
||||
<filter string="Work Order Operations" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'routing_id'}"/>
|
||||
<filter string='Type' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'type'}"/>
|
||||
<filter string=" Valid From Month" icon="terp-go-month" domain="[]" context="{'group_by':'date_start'}" help="Valid From Date by Month"/>
|
||||
<filter string="Product Category" domain="[]" context="{'group_by':'categ_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
@@ -626,6 +629,7 @@
|
||||
<field name="routing_id" groups="mrp.group_mrp_routings"/>
|
||||
<field name="user_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'mrp.group_mrp_user']}"/>
|
||||
<field name="origin"/>
|
||||
<field name="categ_id"/>
|
||||
</group>
|
||||
<group groups="stock.group_locations">
|
||||
<field name="location_src_id" domain="[('usage','=','internal')]" on_change="location_id_change(location_src_id,location_dest_id)"/>
|
||||
@@ -864,11 +868,13 @@
|
||||
<field name="product_tmpl_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="routing_id" groups="mrp.group_mrp_routings"/>
|
||||
<field name="categ_id"/>
|
||||
<group expand="0" string="Group By...">
|
||||
<filter string="Product" icon="terp-accessories-archiver" domain="[]" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Work Order Operations" icon="terp-stock_align_left_24" domain="[]" context="{'group_by':'routing_id'}"/>
|
||||
<filter string="Status" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
<filter string="Scheduled Month" icon="terp-go-month" domain="[]" context="{'group_by':'date_planned'}" help="Scheduled Date by Month"/>
|
||||
<filter string="Product Category" domain="[]" context="{'group_by':'categ_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user