[IMP]stock: Instead of stock.picking set stock.move for product kanban links Reception & Deliveries

bzr revid: dbr@tinyerp.com-20120522070228-fzxz0j11qhivkb73
This commit is contained in:
DBR (OpenERP) 2012-05-22 12:32:28 +05:30
parent 38d3044665
commit d38c63e656
2 changed files with 41 additions and 33 deletions

View File

@ -26,16 +26,18 @@ import decimal_precision as dp
class product_product(osv.osv):
_inherit = "product.product"
def _stock_picking_count(self, cr, uid, ids, field_name, arg, context=None):
def _stock_move_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict([(id, {'reception_count': 0, 'delivery_count': 0}) for id in ids])
picking_pool=self.pool.get('stock.picking')
picking_ids = picking_pool.search(cr, uid, [('move_lines.product_id', 'in', ids)])
for picking in picking_pool.browse(cr, uid, picking_ids, context):
field = 'reception_count' if picking.type == 'in' else 'delivery_count'
product_ids = set([line.product_id.id for line in picking.move_lines])
for product_id in product_ids:
if product_id in ids:
res[product_id][field] += 1
move_pool=self.pool.get('stock.move')
move_ids = move_pool.search(cr, uid, [('product_id', 'in', ids)])
for move in move_pool.browse(cr, uid, move_ids, context):
product_id = move.product_id.id
if product_id in ids:
if move.picking_id.type == 'in':
field = 'reception_count'
elif move.picking_id.type == 'out':
field = 'delivery_count'
res[product_id][field] += 1
return res
def get_product_accounts(self, cr, uid, product_id, context=None):
@ -343,8 +345,8 @@ class product_product(osv.osv):
return res
_columns = {
'reception_count': fields.function(_stock_picking_count, string="Reception", type='integer', multi='pickings'),
'delivery_count': fields.function(_stock_picking_count, string="Delivery", type='integer', multi='pickings'),
'reception_count': fields.function(_stock_move_count, string="Reception", type='integer', multi='pickings'),
'delivery_count': fields.function(_stock_move_count, string="Delivery", type='integer', multi='pickings'),
'qty_available': fields.function(_product_available, multi='qty_available',
type='float', digits_compute=dp.get_precision('Product Unit of Measure'),
string='Quantity On Hand',

View File

@ -125,26 +125,32 @@
</group>
</field>
</record>
<act_window
id="act_product_2_reception"
name="Receptions"
view_mode="tree,form,calendar"
res_model="stock.picking"
src_model="product.product"
context="{'search_default_product_id': [active_id]}"
domain="[('type','=','in')]"
/>
<act_window
id="act_product_2_delivery"
name="Deliveries"
view_mode="tree,form,calendar"
res_model="stock.picking"
src_model="product.product"
context="{'search_default_product_id': [active_id]}"
domain="[('type', '=', 'out')]"
/>
<record id="action_receive_move" model="ir.actions.act_window">
<field name="name">Receive Products</field>
<field name="res_model">stock.move</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('picking_id.type','=','in')]</field>
<field name="view_id" ref="view_move_tree_reception_picking"/>
<field name="context" eval="'{\'search_default_product_id\': [active_id]}'"/>
<field name="search_view_id" ref="view_move_search_reception_incoming_picking"/>
<field name="help">Here you can receive individual products, no matter what purchase order or picking order they come from. You will find the list of all products you are waiting for. Once you receive an order, you can filter based on the name of the supplier or the purchase order reference. Then you can confirm all products received using the buttons on the right of each line.</field>
</record>
<record id="action_deliver_move" model="ir.actions.act_window">
<field name="name">Receive Products</field>
<field name="res_model">stock.move</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('picking_id.type','=','out')]</field>
<field name="view_id" ref="view_move_tree_reception_picking"/>
<field name="context" eval="'{\'search_default_product_id\': [active_id]}'"/>
<field name="search_view_id" ref="view_move_search_reception_outcoming_picking"/>
<field name="help">You will find in this list all products you have to deliver to your customers. You can process the deliveries directly from this list using the buttons on the right of each line. You can filter the products to deliver by customer, products or sale order (using the Origin field).</field>
</record>
<record model="ir.ui.view" id="product.product_kanban_view">
<field name="name">Product Kanban</field>
@ -173,10 +179,10 @@
<li>Price: <field name="lst_price"></field></li>
<li>Cost: <field name="standard_price"></field></li>
</ul>
<a name="%(act_product_2_reception)d" type="action">
<a name="%(action_receive_move)d" type="action">
<t t-if="record.reception_count.value">Receptions(<t t-esc="record.reception_count.value"/>)</t>
</a>
<a name="%(act_product_2_delivery)d" type="action">
<a name="%(action_deliver_move)d" type="action">
<t t-if="record.delivery_count.value">Deliveries(<t t-esc="record.delivery_count.value"/>)</t>
</a>
</div>