[ADD] Stock : New two graph view added for board_warehouse module

bzr revid: vir@tinyerp.com-20100201125000-pawq65wc8m2erxy0
This commit is contained in:
Vir (Open ERP) 2010-02-01 18:20:00 +05:30
parent 1f407aacf4
commit 44b5c3cdd8
2 changed files with 145 additions and 23 deletions

View File

@ -474,7 +474,7 @@ class stock_picking(osv.osv):
("2binvoiced", "To Be Invoiced"),
("none", "Not from Picking")], "Invoice Status",
select=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
}
_defaults = {
'name': lambda self, cr, uid, context: '/',
@ -908,12 +908,12 @@ stock_production_lot()
class stock_split_production_lots(osv.osv_memory):
_name = "stock.split.production.lots"
_description = "Split Production Lots"
def _quantity_default_get(self, cr, uid, object=False, field=False, context=None):
cr.execute("select %s from %s where id=%s" %(field,object,context.get('active_id')))
res = cr.fetchone()[0]
return res
_columns = {
'name': fields.char('Lot Number/Prefix', size=64, required=True),
'qty': fields.float('Total Quantity'),
@ -922,13 +922,13 @@ class stock_split_production_lots(osv.osv_memory):
_defaults = {
'qty': lambda self,cr,uid,c: self.pool.get('stock.split.production.lots')._quantity_default_get(cr, uid, 'stock_move', 'product_qty',context=c) or 1,
}
def split_lines(self, cr, uid, ids, context={}):
data = self.read(cr, uid, ids[0])
prodlot_obj = self.pool.get('stock.production.lot')
move_obj = self.pool.get('stock.move')
move_browse = move_obj.browse(cr, uid, context['active_id'])
quantity = data['qty']
if quantity <= 0 or move_browse.product_qty == 0:
return {}
@ -936,12 +936,12 @@ class stock_split_production_lots(osv.osv_memory):
quantity_rest = move_browse.product_qty%quantity
uos_qty_rest = quantity_rest/move_browse.product_qty*move_browse.product_uos_qty
update_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
}
new_move = []
for idx in range(int(move_browse.product_qty//quantity)):
if idx:
@ -952,7 +952,7 @@ class stock_split_production_lots(osv.osv_memory):
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
if quantity_rest > 0:
idx = int(move_browse.product_qty//quantity)
update_val['product_qty'] = quantity_rest
@ -965,7 +965,7 @@ class stock_split_production_lots(osv.osv_memory):
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
return {}
stock_split_production_lots()
@ -1071,9 +1071,9 @@ class stock_move(osv.osv):
digits=(16, int(config['price_accuracy']))),
'company_id': fields.many2one('res.company', 'Company', required=True,select=1),
'partner_id': fields.related('picking_id','address_id','partner_id',type='many2one', relation="res.partner", string="Partner"),
'backorder_id': fields.related('picking_id','backorder_id',type='many2one', relation="stock.picking", string="Back Orders"),
'backorder_id': fields.related('picking_id','backorder_id',type='many2one', relation="stock.picking", string="Back Orders"),
'origin': fields.related('picking_id','origin',type='char', size=64, relation="stock.picking", string="Origin"),
'move_stock_return_history': fields.many2many('stock.move', 'stock_move_return_history', 'move_id', 'return_move_id', 'Move Return History',readonly=True),
'move_stock_return_history': fields.many2many('stock.move', 'stock_move_return_history', 'move_id', 'return_move_id', 'Move Return History',readonly=True),
}
_constraints = [
(_check_tracking,
@ -1115,19 +1115,19 @@ class stock_move(osv.osv):
'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.move', context=c)
}
def copy(self, cr, uid, id, default=None, context={}):
if default is None:
default = {}
default = default.copy()
default['move_stock_return_history'] = []
return super(stock_move, self).copy(cr, uid, id, default, context)
def create(self, cr, user, vals, context=None):
if vals.get('move_stock_return_history',False):
vals['move_stock_return_history'] = []
return super(stock_move, self).create(cr, user, vals, context)
def _auto_init(self, cursor, context):
res = super(stock_move, self)._auto_init(cursor, context)
cursor.execute('SELECT indexname \
@ -1444,11 +1444,11 @@ class stock_move(osv.osv):
'line_id': lines,
'ref': ref,
})
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
self.write(cr, uid, ids, {'state': 'done', 'date_planned': time.strftime('%Y-%m-%d %H:%M:%S')})
for pick in self.pool.get('stock.picking').browse(cr, uid, picking_ids):
if all(move.state == 'done' for move in pick.move_lines):
self.pool.get('stock.picking').action_done(cr, uid, [pick.id])
wf_service = netsvc.LocalService("workflow")
for id in ids:
wf_service.trg_trigger(uid, 'stock.move', id, cr)
@ -1502,7 +1502,7 @@ class stock_inventory(osv.osv):
'name': 'INV:' + str(line.inventory_id.id) + ':' + line.inventory_id.name,
'product_id': line.product_id.id,
'product_uom': line.product_uom.id,
'prodlot_id': lot_id,
'prodlot_id': lot_id,
'date': inv.date,
'date_planned': inv.date,
'state': 'assigned'
@ -1522,7 +1522,7 @@ class stock_inventory(osv.osv):
if lot_id:
value.update({
'prodlot_id': lot_id,
'product_qty': line.product_qty
'product_qty': line.product_qty
})
move_ids.append(self.pool.get('stock.move').create(cr, uid, value))
if len(move_ids):
@ -1641,4 +1641,53 @@ class stock_picking_move_wizard(osv.osv_memory):
stock_picking_move_wizard()
class report_products_to_received_planned(osv.osv):
_name = "report.products.to.received.planned"
_description = "Product to Received Vs Planned"
_auto = False
_columns = {
'date':fields.date('Date'),
'qty': fields.integer('Actual Qty'),
'planned_qty': fields.integer('Planned Qty'),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_products_to_received_planned')
cr.execute("""
create or replace view report_products_to_received_planned as (
select
distinct current_date as date,
min(id) as id,
(select sum(product_qty) from stock_move where to_char(date,'YYYY-MM-DD')::date = current_date ) as qty,
(select sum(product_qty) from stock_move where to_char(date_planned,'YYYY-MM-DD')::date = current_date) as planned_qty
from stock_move
)
""")
report_products_to_received_planned()
class report_delivery_products_planned(osv.osv):
_name = "report.delivery.products.planned"
_description = "Number of Delivery products vs planned"
_auto = False
_columns = {
'date':fields.date('Date'),
'qty': fields.integer('Actual Qty'),
'planned_qty': fields.integer('Planned Qty'),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'report_delivery_products_planned')
cr.execute("""
create or replace view report_delivery_products_planned as (
select
distinct current_date as date,
min(sm.id) as id,
(select sum(product_qty) from stock_move join stock_picking sp on (sm.picking_id = sp.id ) where to_char(sm.date,'YYYY-MM-DD')::date = current_date ) as qty,
(select sum(product_qty) from stock_move join stock_picking sp on (sm.picking_id = sp.id ) where to_char(sm.date_planned,'YYYY-MM-DD')::date = current_date) as planned_qty
from stock_move sm join stock_picking sp on (sm.picking_id = sp.id ) where sp.type = 'out' group by sm.picking_id, sm.date, sm.date_planned
)
""")
report_delivery_products_planned()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -72,7 +72,7 @@
<field context="location=location_id,uom=product_uom" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom)" select="1" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="prod_lot_id"/>
<field name="prod_lot_id"/>
<field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
</tree>
<form string="Inventory Lines">
@ -84,7 +84,7 @@
<field name="prod_lot_id"/>
<button name="%(split_inventory_lots)d" string="Split in Production Lots" type="action" icon="gtk-justify-fill"/>
</group>
</form>
</field>
</page><page string="Posted Inventory">
@ -532,7 +532,7 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="stock_picking_calendar">
<field name="name">stock.picking.calendar</field>
<field name="model">stock.picking</field>
@ -1299,7 +1299,7 @@
<field name="prodlot_id" string="Lot"/>
<field name="date_planned"/>
<field name="backorder_id"/>
<field name="state"/>
<field name="state"/>
<button name="%(partial_move)d" string="Partial" type="action" states="assigned" icon="gtk-justify-fill"/>
<button name="action_cancel" states="assigned,confirmed" string="Cancel" type="object" icon="gtk-cancel"/>
</tree>
@ -1375,7 +1375,7 @@
</group>
</search>
</field>
</record>
</record>
<record id="action_reception_picking_move" model="ir.actions.act_window">
<field name="name">Reception Picking Stock Move</field>
@ -1486,5 +1486,78 @@
<field eval="True" name="object"/>
</record>  
<!-- Graph Views -->
<!-- Products To Received Vs Planned -->
<record model="ir.ui.view" id="view_move_graph_reception_picking_tree">
<field name="name">Products To Received</field>
<field name="model">report.products.to.received.planned</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Products To Received" >
<field name="qty" />
<field name="planned_qty" />
<field name="date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_move_graph_reception_picking">
<field name="name">Products To Received</field>
<field name="model">report.products.to.received.planned</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Products To Received" type="bar" orientation="vertical">
<field name="date"/>
<field name="qty" operator="+"/>
<field name="planned_qty" operator="+"/>
</graph>
</field>
</record>
<record id="action_move_graph_reception_picking" model="ir.actions.act_window">
<field name="name">Reception Picking Stock Move</field>
<field name="res_model">report.products.to.received.planned</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_move_graph_reception_picking"/>
</record>
<!-- Delivery Product Vs Planned -->
<record model="ir.ui.view" id="view_move_delivery_products_planned_tree">
<field name="name">Delivery Products</field>
<field name="model">report.delivery.products.planned</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Products To Received" >
<field name="qty" />
<field name="planned_qty" />
<field name="date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_move_delivery_products_planned_graph">
<field name="name">Delivery Products</field>
<field name="model">report.delivery.products.planned</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Products To Received" type="bar" orientation="vertical">
<field name="date"/>
<field name="qty" operator="+"/>
<field name="planned_qty" operator="+"/>
</graph>
</field>
</record>
<record id="action_move_delivery_products_planned" model="ir.actions.act_window">
<field name="name">Delivery Products Vs Planned</field>
<field name="res_model">report.delivery.products.planned</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_move_delivery_products_planned_graph"/>
</record>
</data>
</openerp>