1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (c) 2009 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
6
# Jordi Esteve <jesteve@zikzakmedia.com>
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation, either version 3 of the License, or
12
# (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
24
from osv import osv, fields
25
from tools.sql import drop_view_if_exists
27
class stock_picking(osv.osv):
29
_inherit='stock.picking'
31
def _total_quantity(self, cr, uid, ids, name, args, context):
33
stock_move_obj = self.pool.get("stock.move")
36
stock_move_ids= stock_move_obj.search(cr, uid, [('picking_id','=',id)])
37
for move_id in stock_move_ids:
38
move_data = stock_move_obj.browse(cr, uid, move_id)
39
tot_qty += move_data.product_qty
43
def _scanned_quantity(self, cr, uid, ids, name, args, context):
47
scanned_data = self.browse(cr, uid, id)
48
for scanned_data in scanned_data.scaned_ids:
49
scanned_qty += scanned_data.scan_quantity
50
result[id] = scanned_qty
53
def _to_be_scanned_quantity(self, cr, uid, ids, name, args, context):
56
tobe_scanned_qty = 0.0
57
scanned_data = self.browse(cr, uid, id)
58
tobe_scanned_qty = scanned_data.total_quantity - scanned_data.scanned_quantity
59
result[id] = tobe_scanned_qty
63
'ean' : fields.char("EAN", size=64,),
64
'total_quantity':fields.function(_total_quantity, method=True, string='Total Quantity'),
65
'scanned_quantity': fields.function(_scanned_quantity, method=True, string='Scanned Quantity'),
66
'to_be_scanned_quantity':fields.function(_to_be_scanned_quantity, method=True, string='To Be Scanned Quantity'),
67
'tobe_scan_ids':fields.one2many('tobe.scanned.stock', 'tobe_picking_id', 'To Be'),
68
'scaned_ids':fields.one2many('scanned.stock', 'scanned_picking_id', 'Scanned Picking',),
71
'scanned_quantity' : lambda *a:0.0,
76
class stock_move(osv.osv):
77
_inherit = "stock.move"
79
'scaned_qty':fields.float("Scanned Qty"),
83
'scaned_qty' : lambda *a:0.0,
88
class tobe_scanned_stock(osv.osv):
89
_name = "tobe.scanned.stock"
92
'tobe_picking_id': fields.many2one('stock.picking', 'Stock Picking',),
93
'product_name':fields.many2one('product.product','Product Name', size=64),
94
'lot_number':fields.many2one('stock.production.lot','Lot Number', size=64),
95
'quantity':fields.float("Quantity"),
96
'scan_quantity':fields.float("Scan Quantity"),
100
drop_view_if_exists(cr, 'tobe_scanned_stock')
102
CREATE OR REPLACE VIEW tobe_scanned_stock AS (
105
l.picking_id AS tobe_picking_id,
106
sum(l.scaned_qty) AS scan_quantity,
107
sum(l.product_qty) AS quantity,
108
l.prodlot_id AS lot_number,
109
l.product_id AS product_name
113
l.scaned_qty != l.product_qty
115
l.product_id,l.prodlot_id,l.picking_id, l.id
120
class scanned_stock(osv.osv):
121
_name = "scanned.stock"
124
'scanned_picking_id': fields.many2one('stock.picking', 'Stock Picking',),
125
'product_name':fields.many2one('product.product','Product Name', size=64),
126
'lot_number':fields.many2one('stock.production.lot','Lot Number', size=64),
127
'quantity':fields.float("Quantity"),
128
'scan_quantity':fields.float("Scan Quantity"),
132
drop_view_if_exists(cr, 'scanned_stock')
134
CREATE OR REPLACE VIEW scanned_stock AS (
137
l.picking_id AS scanned_picking_id,
138
sum(l.scaned_qty) AS scan_quantity,
139
sum(l.product_qty) AS quantity,
140
l.prodlot_id AS lot_number,
141
l.product_id AS product_name
145
l.scaned_qty = l.product_qty
147
l.product_id,l.prodlot_id,l.picking_id, l.id
153
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
b'\\ No newline at end of file'