Skip to content

Commit

Permalink
[FIX] stock: On Hand on template form statbutton action + improve qua…
Browse files Browse the repository at this point in the history
…nt form view and help messages in picking type
  • Loading branch information
jco-odoo committed Sep 10, 2015
1 parent 1989495 commit 50c0778
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 22 deletions.
7 changes: 7 additions & 0 deletions addons/stock/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,13 @@ def _get_act_window_dict(self, cr, uid, name, context=None):
result = act_obj.read(cr, uid, [result], context=context)[0]
return result

def action_open_quants(self, cr, uid, ids, context=None):
products = self._get_products(cr, uid, ids, context=context)
result = self._get_act_window_dict(cr, uid, 'stock.product_open_quants', context=context)
result['domain'] = "[('product_id','in',[" + ','.join(map(str, products)) + "])]"
result['context'] = "{'search_default_locationgroup': 1, 'search_default_internal_loc': 1}"
return result

def action_view_orderpoints(self, cr, uid, ids, context=None):
products = self._get_products(cr, uid, ids, context=context)
result = self._get_act_window_dict(cr, uid, 'stock.product_open_orderpoint', context=context)
Expand Down
2 changes: 1 addition & 1 deletion addons/stock/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
</header>
<div name="button_box" position="inside">
<button type="object"
name="%(stock.product_template_open_quants)d"
name="action_open_quants"
attrs="{'invisible':[('type', '!=', 'product')]}"
class="oe_stat_button" icon="fa-building-o">
<field name="qty_available" widget="statinfo" string="On Hand"/>
Expand Down
27 changes: 21 additions & 6 deletions addons/stock/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2793,8 +2793,24 @@ def get_code_from_locs(self, cr, uid, move, location_id=False, location_dest_id=
code = 'incoming'
return code

def _get_taxes(self, cr, uid, move, context=None):
return []
def show_picking(self, cr, uid, ids, context=None):
assert len(ids) > 0
picking_id = self.browse(cr, uid, ids[0], context=context).picking_id.id
if picking_id:
data_obj = self.pool['ir.model.data']
view = data_obj.xmlid_to_res_id(cr, uid, 'stock.view_picking_form')
return {
'name': _('Transfer'),
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'views': [(view, 'form')],
'view_id': view,
'target': 'new',
'res_id': picking_id,
}


class stock_inventory(osv.osv):
_name = "stock.inventory"
Expand Down Expand Up @@ -4492,7 +4508,6 @@ def _check_lot(self, cr, uid, ids, context=None):
('uniq_lot_name', 'unique(operation_id, lot_name)', 'You have already mentioned this lot name in another line')]

def do_plus(self, cr, uid, ids, context=None):
#return {'type': 'ir.actions.act_window_close'}
for packlot in self.browse(cr, uid, ids, context=context):
self.write(cr, uid, [packlot.id], {'qty': packlot.qty + 1}, context=context)
pack = self.browse(cr, uid, ids[0], context=context).operation_id.id
Expand Down Expand Up @@ -4785,11 +4800,11 @@ def _default_warehouse(self, cr, uid, context=None):
'default_location_dest_id': fields.many2one('stock.location', 'Default Destination Location', help="This is the default destination location when you create a picking manually with this picking type. It is possible however to change it or that the routes put another location. If it is empty, it will check for the customer location on the partner. "),
'code': fields.selection([('incoming', 'Suppliers'), ('outgoing', 'Customers'), ('internal', 'Internal')], 'Type of Operation', required=True),
'return_picking_type_id': fields.many2one('stock.picking.type', 'Picking Type for Returns'),
'show_entire_packs': fields.boolean('Allow moving packs'),
'show_entire_packs': fields.boolean('Allow moving packs', help="If checked, this shows the packs to be moved as a whole in the Operations tab all the time, even if there was no entire pack reserved."),
'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', ondelete='cascade'),
'active': fields.boolean('Active'),
'use_create_lots': fields.boolean('Create New Lots'),
'use_existing_lots': fields.boolean('Use Existing Lots'),
'use_create_lots': fields.boolean('Create New Lots', help="If this is checked only, it will suppose you want to create new Serial Numbers / Lots, so you can provide them in a text field. "),
'use_existing_lots': fields.boolean('Use Existing Lots', help="If this is checked, you will be able to choose the Serial Number / Lots. You can also decide to not put lots in this picking type. This means it will create stock with no lot or not put a restriction on the lot taken. "),

# Statistics for the kanban view
'last_done_picking': fields.function(_get_tristate_values,
Expand Down
44 changes: 29 additions & 15 deletions addons/stock/stock_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@
<field name="partner_id" context="{'contact_display':'partner'}" />
<field name="move_dest_id" groups="base.group_no_one" readonly="1"/>
</group>
<group name="quants_grp" string="Reserved Quants" colspan="2" groups="base.group_no_one">
<group name="quants_grp" string="Reserved Quants" colspan="2" groups="base.group_no_one" attrs="{'invisible': [('state', '=', 'done')]}">
<field name="string_availability_info"/>
</group>
<group name="moved_quants_grp" string="Moved Quants" colspan="4" groups="base.group_no_one" attrs="{'invisible': [('state', '!=', 'done')]}">
Expand Down Expand Up @@ -1984,21 +1984,35 @@
<field eval="10" name="priority"/>
<field name="arch" type="xml">
<form string="Quants" create="false" edit="false">
<div class="oe_button_box" name="button_box">
<button name="action_view_quant_history" type="object" string="Quant History"/>
</div>
<group>
<field name="product_id"/>
<field name="qty"/>
<field name="product_uom_id" groups="product.group_uom"/>
<field name="lot_id" groups="stock.group_production_lot"/>
<field name="package_id" groups="stock.group_tracking_lot"/>
<field name="location_id"/>
<field name="in_date"/>
<field name="reservation_id"/>
<field name="propagated_from_id"/>
<field name="owner_id" groups="stock.group_tracking_owner"/>
<field name="inventory_value"/>
<group>
<field name="product_id"/>
<field name="qty"/>
<field name="product_uom_id" groups="product.group_uom"/>
<field name="lot_id" groups="stock.group_production_lot"/>
<field name="package_id" groups="stock.group_tracking_lot"/>
<field name="location_id"/>
<field name="owner_id" groups="stock.group_tracking_owner"/>
</group>
<group>
<field name="in_date"/>
<field name="reservation_id"/>
<field name="propagated_from_id"/>
<field name="inventory_value"/>
</group>
</group>
<group>
<field name="history_ids" string="History">
<tree readonly="1" default_order="date">
<field name="picking_id"/>
<button type="object" name="show_picking" icon="fa-list-alt" attrs="{'invisible': [('picking_id', '=', False)]}"/>
<field name="product_uom_qty"/>
<field name="date"/>
<field name="location_id" groups="stock.group_locations" string="Source Location Zone"/>
<field name="location_dest_id" groups="stock.group_locations" string="Destination Location Zone"/>
<field name="state" invisible="1"/>
</tree>
</field>
</group>
</form>
</field>
Expand Down

0 comments on commit 50c0778

Please sign in to comment.