[FIX] Change two-one step wh, multi-comp wh, quantity field float, show product_uom_qty instead of product_qty in mrp production for moves

This commit is contained in:
Josse Colpaert 2014-08-07 17:08:16 +02:00
parent 4aa9ef8224
commit 5dea263e1b
5 changed files with 24 additions and 28 deletions

View File

@ -685,10 +685,10 @@
</div>
<group>
<group>
<field name="product_id" on_change="product_id_change(product_id, product_qty)" domain="[('bom_ids','!=',False),('bom_ids.type','!=','phantom')]" class="oe_inline" context='{"default_type": "product"}'/>
<label for="product_qty"/>
<field name="product_id" on_change="product_id_change(product_id, product_uom_qty)" domain="[('bom_ids','!=',False),('bom_ids.type','!=','phantom')]" class="oe_inline" context='{"default_type": "product"}'/>
<label for="product_uom_qty"/>
<div>
<field name="product_qty" class="oe_inline" on_change="product_id_change(product_id, product_qty)"/>
<field name="product_uom_qty" class="oe_inline" on_change="product_id_change(product_id, product_uom_qty)"/>
<field name="product_uom" groups="product.group_uom" class="oe_inline"/>
<button type="action"
name="%(mrp.action_change_production_qty)d"
@ -720,7 +720,7 @@
<field name="move_lines" nolabel="1" options="{'reload_on_button': true}">
<tree colors="blue:state == 'draft';black:state in ('ready','assigned','in_production');gray:state in ('cancel','done');red:state in ('confirmed','waiting')" string="Products to Consume">
<field name="product_id"/>
<field name="product_qty" string="Quantity"/>
<field name="product_uom_qty" string="Quantity"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="state" invisible="1"/>
<button name="%(mrp.move_consume)d"
@ -740,7 +740,7 @@
<tree colors="red:scrapped==True;blue:state == 'draft';black:state in ('confirmed','ready','in_production');gray:state == 'cancel' " string="Consumed Products" editable="bottom">
<field name="product_id" readonly="1"/>
<field name="restrict_lot_id" context="{'product_id': product_id}" groups="stock.group_production_lot"/>
<field name="product_qty" readonly="1"/>
<field name="product_uom_qty" readonly="1"/>
<field name="product_uom" readonly="1" string="Unit of Measure" groups="product.group_uom"/>
<field name="state" invisible="1"/>
<field name="scrapped" invisible="1"/>
@ -755,7 +755,7 @@
<field name="move_created_ids" nolabel="1" options="{'reload_on_button': true}">
<tree string="Products to Finish">
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom_qty"/>
<field name="product_uom" string="Unit of Measure" groups="product.group_uom"/>
<field name="state" invisible="1"/>
<!--TODO: should have a partial picking here-->
@ -766,7 +766,7 @@
<field name="move_created_ids2" nolabel="1" options="{'reload_on_button': true}">
<tree colors="red:scrapped==True;blue:state == 'draft';black:state in('confirmed','ready','in_production');gray:state in('cancel','done') " string="Finished Products">
<field name="product_id" readonly="1"/>
<field name="product_qty" readonly="1"/>
<field name="product_uom_qty" readonly="1"/>
<field name="restrict_lot_id" groups="stock.group_production_lot"/>
<field name="product_uom" readonly="1" string="Unit of Measure" groups="product.group_uom"/>
<field name="location_dest_id" readonly="1" string="Destination Loc." widget="selection" groups="stock.group_locations"/>

View File

@ -40,6 +40,7 @@
<field name="mobile" position="after">
<field name="purchase_order_count"/>
</field>
<xpath expr="//div[@class='oe_kanban_partner_links']" position="inside">
<a name="%(purchase.act_res_partner_2_purchase_order)d" type="action" t-if="record.purchase_order_count.value>0">
<t t-esc="record.purchase_order_count.value"/> Purchases
@ -80,7 +81,8 @@
<field string="Purchases" name="purchase_order_count" widget="statinfo"/>
</button>
<button class="oe_inline oe_stat_button" name="%(purchase.act_res_partner_2_supplier_invoices)d" type="action"
attrs="{'invisible': [('supplier', '=', False)]}" icon="fa-pencil-square-o" help="Supplier Invoices">
attrs="{'invisible': [('supplier', '=', False)]}" icon="fa-pencil-square-o" help="Supplier Invoices"
groups="account.group_account_user,account.group_account_manager">
<field string="Supplier Inv." name="supplier_invoice_count" widget="statinfo"/>
</button>
</xpath>

View File

@ -2749,7 +2749,7 @@ class stock_warehouse(osv.osv):
'company_id': fields.many2one('res.company', 'Company', required=True, readonly=True, select=True),
'partner_id': fields.many2one('res.partner', 'Address'),
'view_location_id': fields.many2one('stock.location', 'View Location', required=True, domain=[('usage', '=', 'view')]),
'lot_stock_id': fields.many2one('stock.location', 'Location Stock', required=True, domain=[('usage', '=', 'internal')]),
'lot_stock_id': fields.many2one('stock.location', 'Location Stock', domain=[('usage', '=', 'internal')], required=True),
'code': fields.char('Short Name', size=5, required=True, help="Short name used to identify your warehouse"),
'route_ids': fields.many2many('stock.location.route', 'stock_route_warehouse', 'warehouse_id', 'route_id', 'Routes', domain="[('warehouse_selectable', '=', True)]", help='Defaults routes through the warehouse'),
'reception_steps': fields.selection([
@ -2825,7 +2825,7 @@ class stock_warehouse(osv.osv):
if wh.delivery_steps == 'ship_only':
output_loc = wh.lot_stock_id
# Create extra MTO rule (only for 'ship only' because in the other cases MTO rules already exists)
mto_pull_vals = self._get_mto_pull_rule(cr, uid, wh, [(output_loc, transit_location, wh.out_type_id.id)], context=context)
mto_pull_vals = self._get_mto_pull_rule(cr, uid, wh, [(output_loc, transit_location, wh.out_type_id.id)], context=context)[0]
pull_obj.create(cr, uid, mto_pull_vals, context=context)
inter_wh_route_vals = self._get_inter_wh_route(cr, uid, warehouse, wh, context=context)
inter_wh_route_id = route_obj.create(cr, uid, vals=inter_wh_route_vals, context=context)
@ -2837,17 +2837,8 @@ class stock_warehouse(osv.osv):
if default_resupply_wh and default_resupply_wh.id == wh.id:
self.write(cr, uid, [warehouse.id], {'route_ids': [(4, inter_wh_route_id)]}, context=context)
def _default_stock_id(self, cr, uid, context=None):
#lot_input_stock = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
try:
warehouse = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'warehouse0')
return warehouse.lot_stock_id.id
except:
return False
_defaults = {
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.inventory', context=c),
'lot_stock_id': _default_stock_id,
'reception_steps': 'one_step',
'delivery_steps': 'ship_only',
}
@ -2966,8 +2957,10 @@ class stock_warehouse(osv.osv):
def _get_mto_pull_rule(self, cr, uid, warehouse, values, context=None):
mto_route_id = self._get_mto_route(cr, uid, context=context)
from_loc, dest_loc, pick_type_id = values[0]
return {
res = []
for value in values:
from_loc, dest_loc, pick_type_id = value
res += [{
'name': self._format_rulename(cr, uid, warehouse, from_loc, dest_loc, context=context) + _(' MTO'),
'location_src_id': from_loc.id,
'location_id': dest_loc.id,
@ -2977,7 +2970,8 @@ class stock_warehouse(osv.osv):
'procure_method': 'make_to_order',
'active': True,
'warehouse_id': warehouse.id,
}
}]
return res
def _get_crossdock_route(self, cr, uid, warehouse, route_name, context=None):
return {
@ -3019,7 +3013,7 @@ class stock_warehouse(osv.osv):
for pull_rule in pull_rules_list:
pull_obj.create(cr, uid, vals=pull_rule, context=context)
#create MTO pull rule and link it to the generic MTO route
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, values, context=context)
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, values, context=context)[0]
mto_pull_id = pull_obj.create(cr, uid, mto_pull_vals, context=context)
#create a route for cross dock operations, that can be set on products and product categories
@ -3093,7 +3087,7 @@ class stock_warehouse(osv.osv):
#change MTO rule
dummy, values = routes_dict[new_delivery_step]
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, values, context=context)
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, values, context=context)[0]
pull_obj.write(cr, uid, warehouse.mto_pull_id.id, mto_pull_vals, context=context)
return True
@ -3295,7 +3289,7 @@ class stock_warehouse(osv.osv):
route_obj = self.pool.get("stock.location.route")
pull_obj = self.pool.get("procurement.rule")
routes = route_obj.search(cr, uid, [('supplier_wh_id','=', warehouse.id)], context=context)
pulls= pull_obj.search(cr, uid, ['&', ('route_id', 'in', routes), ('location_id.usage', '=', 'transit')], context=context)
pulls = pull_obj.search(cr, uid, ['&', ('route_id', 'in', routes), ('location_id.usage', '=', 'transit')], context=context)
if pulls:
pull_obj.write(cr, uid, pulls, {'location_src_id': new_location, 'procure_method': change_to_multiple and "make_to_order" or "make_to_stock"}, context=context)
# Create or clean MTO rules
@ -3307,7 +3301,8 @@ class stock_warehouse(osv.osv):
transfer_locs = list(set([x.location_id for x in pull_recs]))
vals = [(warehouse.lot_stock_id , x, warehouse.out_type_id.id) for x in transfer_locs]
mto_pull_vals = self._get_mto_pull_rule(cr, uid, warehouse, vals, context=context)
pull_obj.create(cr, uid, mto_pull_vals, context=context)
for mto_pull_val in mto_pull_vals:
pull_obj.create(cr, uid, mto_pull_val, context=context)
else:
# We need to delete all the MTO pull rules, otherwise they risk to be used in the system
pulls = pull_obj.search(cr, uid, ['&', ('route_id', '=', mto_route_id), ('location_id.usage', '=', 'transit'), ('location_src_id', '=', warehouse.lot_stock_id.id)], context=context)

View File

@ -524,7 +524,6 @@
<group>
<group>
<field name="code"/>
<field name="lot_stock_id" groups="stock.group_locations" string="Inventory Location" invisible="1"/>
</group>
<group>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>

View File

@ -84,7 +84,7 @@ class stock_history(osv.osv):
'company_id': fields.many2one('res.company', 'Company'),
'product_id': fields.many2one('product.product', 'Product', required=True),
'product_categ_id': fields.many2one('product.category', 'Product Category', required=True),
'quantity': fields.integer('Product Quantity'),
'quantity': fields.float('Product Quantity'),
'date': fields.datetime('Operation Date'),
'price_unit_on_quant': fields.float('Value'),
'inventory_value': fields.function(_get_inventory_value, string="Inventory Value", type='float', readonly=True),