22
22
# You should have received a copy of the GNU Affero General Public License
23
23
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
################################################################################
26
from osv import fields, osv
28
from tools.translate import _
24
##########################################################################
26
from openerp.osv import osv, fields
27
import openerp.tools as tools
28
from openerp.tools.translate import _
29
30
from tools import config
32
class picking_valued(osv.osv_memory):
31
import openerp.netsvc as netsvc
34
class picking_valued(osv.TransientModel):
33
35
logger = netsvc.Logger()
34
36
_name = "picking.valued"
36
38
'type': fields.selection([
37
('entrega','Nota de Entrega (Con Precios)'),
38
('despacho','Nota de Entrega (Sin Precios)'),
39
],'Type', required=True, select=True),
39
('entrega', 'Nota de Entrega (Con Precios)'),
40
('despacho', 'Nota de Entrega (Sin Precios)'),
41
], 'Type', required=True, select=True),
40
42
'sure': fields.boolean('Are you sure?'),
41
43
'sure2': fields.boolean('Are you sure?'),
42
44
'sure3': fields.boolean('Are you sure?'),
43
45
'sure4': fields.boolean('Are you sure?'),
44
'note':fields.char('Note',size=256, required=False, readonly=False ),
45
'note2':fields.char('Note',size=256, required=False, readonly=False ),
46
'note': fields.char('Note', size=256, required=False, readonly=False),
47
'note2': fields.char('Note', size=256, required=False, readonly=False),
46
48
'reason': fields.selection([
48
('tdep','Traslado a depósito'),
49
('talmo','Traslado almacenes o bodegas de otros'),
50
('talmp','Traslado almacenes o bodegas propios'),
51
('tdis','Traslado para su distribución'),
53
],'Reason', select=True),
54
'nro':fields.char('Number', 32, readonly=True),
49
('rep', 'Reparación'),
50
('tdep', 'Traslado a depósito'),
51
('talmo', 'Traslado almacenes o bodegas de otros'),
52
('talmp', 'Traslado almacenes o bodegas propios'),
53
('tdis', 'Traslado para su distribución'),
55
], 'Reason', select=True),
56
'nro': fields.char('Number', 32, readonly=True),
62
63
def default_get(self, cr, uid, fields, context=None):
64
65
To get default values for the object.
72
73
if context is None:
74
res = super(picking_valued, self).default_get(cr, uid, fields, context=context)
75
res = super(picking_valued, self).default_get(
76
cr, uid, fields, context=context)
75
77
record_id = context and context.get('active_id', False) or False
76
78
pick_obj = self.pool.get('picking.valued')
77
79
pick = pick_obj.browse(cr, uid, record_id, context=context)
79
for field in ('type','note','nro'):
81
for field in ('type', 'note', 'nro'):
80
82
if context.get(field, False):
81
83
res[field] = context[field]
83
85
res['note2'] = context[field]
90
92
data_pool = self.pool.get('ir.model.data')
91
93
obj = self.browse(cr, uid, ids[0])
93
95
raise osv.except_osv(_('Alert !'), _('Check the box!!!'))
94
96
context.update({'type': obj.type})
97
action_model,action_id = data_pool.get_object_reference(cr, uid, 'l10n_ve_stock', "action_pick_trans")
99
action_model, action_id = data_pool.get_object_reference(
100
cr, uid, 'l10n_ve_stock', "action_pick_trans")
99
102
action_pool = self.pool.get(action_model)
100
103
action = action_pool.read(cr, uid, action_id, context=context)
116
119
return self.action_number(cr, uid, ids, context=context)
119
action_model,action_id = data_pool.get_object_reference(cr, uid, 'l10n_ve_stock', "action_pick_note")
120
if obj.type=='despacho':
121
action_model,action_id = data_pool.get_object_reference(cr, uid, 'l10n_ve_stock', "action_pick_reason")
122
action_model, action_id = data_pool.get_object_reference(
123
cr, uid, 'l10n_ve_stock', "action_pick_note")
124
if obj.type == 'despacho':
125
action_model, action_id = data_pool.get_object_reference(
126
cr, uid, 'l10n_ve_stock', "action_pick_reason")
123
128
action_pool = self.pool.get(action_model)
124
129
action = action_pool.read(cr, uid, action_id, context=context)
129
134
def make_nro(self, cr, uid, ids, context=None):
130
cr.execute('SELECT id, number ' \
131
'FROM stock_picking ' \
132
'WHERE id IN %s',(tuple(ids),))
135
cr.execute('SELECT id, number '
136
'FROM stock_picking '
137
'WHERE id IN %s', (tuple(ids),))
134
139
for (id, number) in cr.fetchall():
136
number = self.pool.get('ir.sequence').get(cr, uid, 'stock.valued')
137
cr.execute('UPDATE stock_picking SET number=%s ' \
138
'WHERE id=%s', (number, id))
141
number = self.pool.get('ir.sequence').get(
142
cr, uid, 'stock.valued')
143
cr.execute('UPDATE stock_picking SET number=%s '
144
'WHERE id=%s', (number, id))
146
152
data_pool = self.pool.get('ir.model.data')
147
153
obj = self.browse(cr, uid, ids[0])
148
154
comment = obj.note2 or obj.note
149
razon = getattr(obj,'reason')
155
razon = getattr(obj, 'reason')
152
'tdep':'Traslado a depósito',
153
'talmo':'Traslado almacenes o bodegas de otros',
154
'talmp':'Traslado almacenes o bodegas propios',
155
'tdis':'Traslado para su distribución',
158
'tdep': 'Traslado a depósito',
159
'talmo': 'Traslado almacenes o bodegas de otros',
160
'talmp': 'Traslado almacenes o bodegas propios',
161
'tdis': 'Traslado para su distribución',
159
165
record_id = context and context.get('active_id', False) or False