1
# -*- encoding: utf-8 -*-
2
############################################################################
3
# Module Writen to OpenERP, Open Source Management Solution #
4
# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>). #
5
# All Rights Reserved #
6
# Credits######################################################
7
# Coded by: Miguel Delgado <miguel@openerp.com.ve> #
8
# Planified by: Nhomar Hernandez #
9
# Finance by: Corporacion AMD #
10
# Audited by: Humberto Arocha humberto@openerp.com.ve #
11
############################################################################
12
# This program is free software: you can redistribute it and/or modify #
13
# it under the terms of the GNU General Public License as published by #
14
# the Free Software Foundation, either version 3 of the License, or #
15
# (at your option) any later version. #
17
# This program is distributed in the hope that it will be useful, #
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
20
# GNU General Public License for more details. #
22
# You should have received a copy of the GNU General Public License #
23
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
24
############################################################################
25
from openerp.osv import osv, fields
26
from openerp.tools.translate import _
28
import decimal_precision as dp
31
class stock_production_lot(osv.Model):
33
def _serial_identification(self, cr, uid, ids, context=None):
36
spl_brw = self.browse(cr, uid, ids, context=context)
39
if spl.check_serial and spl.stock_available != 0:
43
_inherit = 'stock.production.lot'
46
'check_serial': fields.boolean('Check Serial'),
47
'ref': fields.char('Internal Reference', size=256,
48
help="""Internal reference number in case it
49
differs from the manufacturer's
54
(_serial_identification, _('Check this picking problem with serial'),
55
['Check Serial (check_serial)', 'Stock Available (stock_available)']),
58
def name_get(self, cr, uid, ids, context=None):
62
res = super(stock_production_lot, self).name_get(
63
cr, uid, ids, context=context)
65
ret.append((i[0], i[1].split(' ')[0]))
69
class stock_picking(osv.Model):
70
_inherit = "stock.picking"
72
def test_serial(self, cr, uid, ids):
74
spl_obj = self.pool.get('stock.production.lot')
75
for pick in self.browse(cr, uid, ids):
76
for move in pick.move_lines:
77
if move.product_id.track_serial_incoming and not \
78
move.prodlot_id and pick.type == 'in':
79
raise osv.except_osv(_('Error !'), _(
80
'This product %s should be serialized') %
82
if move.product_id.track_serial_outgoing and not \
83
move.prodlot_id and pick.type == 'out':
84
raise osv.except_osv(_('Error !'), _(
85
'This product %s should be serialized') %
88
if move.product_id.track_serial_incoming and \
89
move.product_id.track_serial_outgoing and\
91
spl_ids = spl_obj.search(cr, uid, [(
92
'product_id', '=', move.product_id.id),
93
('name', '=', move.prodlot_id.name)])
95
raise osv.except_osv(_('Error !'), _(
96
'This serial %s is not exist') %