[IMP]stock: Improve a product kanban links with actions(without specific product domain)

bzr revid: dbr@tinyerp.com-20120502060749-sphn88ybq5gfvzg9
This commit is contained in:
DBR (OpenERP) 2012-05-02 11:37:49 +05:30
parent b86bdabfe9
commit 1064ec73b4
2 changed files with 20 additions and 27 deletions

View File

@ -26,21 +26,16 @@ import decimal_precision as dp
class product_product(osv.osv):
_inherit = "product.product"
def _total_reception(self, cr, uid, ids, field_name, arg, context=None):
total_reception={}
reception_pool=self.pool.get('stock.picking')
for id in ids:
reception_ids = reception_pool.search(cr, uid, [('move_lines.product_id','=',id),('type','=','in')])
total_reception[id] = len(reception_ids)
return total_reception
def _total_delivery(self, cr, uid, ids, field_name, arg, context=None):
total_delivery={}
delivery_pool=self.pool.get('stock.picking')
for id in ids:
delivery_ids = delivery_pool.search(cr, uid, [('move_lines.product_id', '=', id),('type','=','out')])
total_delivery[id] = len(delivery_ids)
return total_delivery
def _stock_picking_count(self, cr, uid, ids, field_name, arg, context=None):
count = dict.fromkeys(ids, 0)
stock_picking_pool=self.pool.get('stock.picking')
if field_name == 'reception_count':
stock_picking_ids = stock_picking_pool.search(cr, uid, [('move_lines.product_id','=',ids),('type','=','in')])
else:
stock_picking_ids = stock_picking_pool.search(cr, uid, [('move_lines.product_id','=',ids),('type','=','out')])
for stock_picking in stock_picking_pool.browse(cr, uid, stock_picking_ids):
count[stock_picking.move_lines[0].product_id.id] += 1
return count
def get_product_accounts(self, cr, uid, product_id, context=None):
""" To get the stock input account, stock output account and stock journal related to product.
@ -347,8 +342,8 @@ class product_product(osv.osv):
return res
_columns = {
'total_reception': fields.function(_total_reception , type='integer',string="Total Reception"),
'total_delivery': fields.function(_total_delivery , type='integer',string="Total Delivery"),
'reception_count': fields.function(_stock_picking_count , type='integer',string="Total Reception"),
'delivery_count': fields.function(_stock_picking_count , type='integer',string="Total Delivery"),
'qty_available': fields.function(_product_available, multi='qty_available',
type='float', digits_compute=dp.get_precision('Product UoM'),
string='Quantity On Hand',
@ -420,8 +415,8 @@ class product_product(osv.osv):
_defaults = {
'valuation': 'manual_periodic',
'total_reception': 0,
'total_delivery': 0,
'reception_count': 0,
'delivery_count': 0,
}
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

View File

@ -136,8 +136,8 @@
<field name="type"/>
<field name="product_image"/>
<field name="list_price"/>
<field name="total_reception"/>
<field name="total_delivery"/>
<field name="reception_count"/>
<field name="delivery_count"/>
<templates>
<t t-name="kanban-box">
<div class="oe_product_vignette">
@ -152,13 +152,11 @@
<li>Price: <field name="lst_price"></field></li>
<li>Cost: <field name="standard_price"></field></li>
</ul>
<a name="get_receptions" type="object">
<t t-if="record.total_reception.raw_value &lt;= 1">Reception(<t t-esc="record.total_reception.value"/>)</t>
<t t-if="record.total_reception.raw_value > 1">Receptions(<t t-esc="record.total_reception.value"/>)</t>
<a name="%(stock.action_picking_tree4)d" type="action">
<t t-if="record.reception_count.value">Receptions(<t t-esc="record.reception_count.value"/>)</t>
</a>
<a name="get_deliveries" type="object">
<t t-if="record.total_delivery.raw_value &lt;= 1">Delivery(<t t-esc="record.total_delivery.value"/>)</t>
<t t-if="record.total_delivery.raw_value > 1">Deliveries(<t t-esc="record.total_delivery.value"/>)</t>
<a name="%(stock.action_out_picking_move)d" type="action">
<t t-if="record.delivery_count.value">Deliveries(<t t-esc="record.delivery_count.value"/>)</t>
</a>
</div>
</div>