[IMP] stock: added stock dashboard + fix in read_group() call + small refactoring
bzr revid: qdp-launchpad@openerp.com-20140417141629-knp0fdm1rp0aieis
This commit is contained in:
commit
8e362b0112
|
@ -1,22 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_stock_graph_board" model="ir.ui.view">
|
||||
<field name="name">report.stock.move.graph</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Moves Analysis" type="bar">
|
||||
<field name="date"/>
|
||||
<field name="product_qty" operator="+"/>
|
||||
<field name="product_id" group="True"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_quant_graph_board" model="ir.ui.view">
|
||||
<field name="name">report.stock.quant.graph</field>
|
||||
<field name="model">stock.quant</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Actual Stock Analysis" type="bar">
|
||||
<field name="location_id" type="row"/>
|
||||
<field name="qty" type="measure"/>
|
||||
<field name="product_id" type="row"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_stock_incoming_product_delay">
|
||||
<field name="name">Incoming Products</field>
|
||||
<field name="res_model">stock.move</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('location_id.usage','!=','internal'), ('location_dest_id.usage','=','internal'), ('date','<=', time.strftime('%Y-%m-%d')),('date','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]</field>
|
||||
<field name="view_id" ref="view_stock_graph_board"></field>
|
||||
<field name="context">{}</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_stock_outgoing_product_delay">
|
||||
<field name="name">Outgoing Products</field>
|
||||
<field name="res_model">stock.move</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('location_id.usage','=','internal'), ('location_dest_id.usage', '!=', 'internal'), ('date','<=', time.strftime('%Y-%m-%d')),('date','>',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]</field>
|
||||
<field name="view_id" ref="view_stock_graph_board"></field>
|
||||
<field name="context">{}</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_stock_quants">
|
||||
<field name="name">Actual Stock</field>
|
||||
<field name="res_model">stock.quant</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('location_id.usage','=','internal')]</field>
|
||||
<field name="view_id" ref="view_stock_quant_graph_board"></field>
|
||||
<field name="context">{}</field>
|
||||
</record>
|
||||
<record id="board_warehouse_form" model="ir.ui.view">
|
||||
<field name="name">board.warehouse.form</field>
|
||||
<field name="model">board.board</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Warehouse board" version="7.0">
|
||||
<board style="1-1">
|
||||
<column name="left">
|
||||
<column>
|
||||
<action name="%(action_stock_incoming_product_delay)d" string="Incoming Products"/>
|
||||
<action name="%(action_stock_outgoing_product_delay)d" string="Outgoing Products"/>
|
||||
</column>
|
||||
<column name="right">
|
||||
<column>
|
||||
<action name="%(action_stock_quants)d" string="Actual Stock"/>
|
||||
<action name="%(procurement.procurement_exceptions)d" string="Procurements in Exception" domain="[('state','=','exception')]"/>
|
||||
</column>
|
||||
</board>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<record id="open_board_warehouse" model="ir.actions.act_window">
|
||||
<field name="name">Warehouse</field>
|
||||
<field name="res_model">board.board</field>
|
||||
|
|
|
@ -283,7 +283,7 @@ class stock_quant(osv.osv):
|
|||
|
||||
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False, lazy=True):
|
||||
''' Overwrite the read_group in order to sum the function field 'inventory_value' in group by'''
|
||||
res = super(stock_quant, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=True)
|
||||
res = super(stock_quant, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby, lazy=lazy)
|
||||
if 'inventory_value' in fields:
|
||||
for line in res:
|
||||
if '__domain' in line:
|
||||
|
@ -555,8 +555,10 @@ class stock_quant(osv.osv):
|
|||
if move.partially_available:
|
||||
self.pool.get("stock.move").write(cr, uid, [move.id], {'partially_available': False}, context=context)
|
||||
self.write(cr, SUPERUSER_ID, related_quants, {'reservation_id': False}, context=context)
|
||||
for quant in move.reserved_quant_ids:
|
||||
self._quant_reconcile_negative(cr, uid, quant, move, context=context)
|
||||
ancestors = self.find_move_ancestors(cr, uid, move, context=context)
|
||||
if move.state == 'waiting' or ancestors:
|
||||
for quant in move.reserved_quant_ids:
|
||||
self._quant_reconcile_negative(cr, uid, quant, move, context=context)
|
||||
|
||||
def _quants_get_order(self, cr, uid, location, product, quantity, domain=[], orderby='in_date', context=None):
|
||||
''' Implementation of removal strategies
|
||||
|
@ -2134,7 +2136,7 @@ class stock_move(osv.osv):
|
|||
pack_obj = self.pool.get("stock.quant.package")
|
||||
packs = set()
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
packs |= set([q.package_id.id for q in move.quant_ids if q.package_id and q.qty > 0])
|
||||
packs |= set([q.package_id for q in move.quant_ids if q.package_id and q.qty > 0])
|
||||
return pack_obj._check_location_constraint(cr, uid, list(packs), context=context)
|
||||
|
||||
def find_move_ancestors(self, cr, uid, move, context=None):
|
||||
|
@ -3513,13 +3515,13 @@ class stock_package(osv.osv):
|
|||
'name': lambda self, cr, uid, context: self.pool.get('ir.sequence').get(cr, uid, 'stock.quant.package') or _('Unknown Pack')
|
||||
}
|
||||
|
||||
def _check_location_constraint(self, cr, uid, ids, context=None):
|
||||
def _check_location_constraint(self, cr, uid, packs, context=None):
|
||||
'''checks that all quants in a package are stored in the same location. This function cannot be used
|
||||
as a constraint because it needs to be checked on pack operations (they may not call write on the
|
||||
package)
|
||||
'''
|
||||
quant_obj = self.pool.get('stock.quant')
|
||||
for pack in self.browse(cr, uid, ids, context=context):
|
||||
for pack in packs:
|
||||
parent = pack
|
||||
while parent.parent_id:
|
||||
parent = parent.parent_id
|
||||
|
|
Loading…
Reference in New Issue