~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to l10n_ve_stock/wizard/wiz_picking_valued.py

  • Committer: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#    Module Writen to OpenERP, Open Source Management Solution
5
5
#    Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>).
6
6
#    All Rights Reserved
7
 
###############Credits######################################################
 
7
# Credits######################################################
8
8
#    Coded by: javier@vauxoo.com
9
9
#    Planified by: Nhomar Hernandez
10
10
#    Audited by: Vauxoo C.A.
21
21
#
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
 
################################################################################
25
 
 
26
 
from osv import fields, osv
27
 
import tools
28
 
from tools.translate import _
 
24
##########################################################################
 
25
 
 
26
from openerp.osv import osv, fields
 
27
import openerp.tools as tools
 
28
from openerp.tools.translate import _
 
29
 
29
30
from tools import config
30
 
import netsvc
31
 
 
32
 
class picking_valued(osv.osv_memory):
 
31
import openerp.netsvc as netsvc
 
32
 
 
33
 
 
34
class picking_valued(osv.TransientModel):
33
35
    logger = netsvc.Logger()
34
36
    _name = "picking.valued"
35
37
    _columns = {
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([
47
 
            ('rep','Reparación'),
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'),
52
 
            ('otr','Otros')
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'),
 
54
            ('otr', 'Otros')
 
55
        ], 'Reason', select=True),
 
56
        'nro': fields.char('Number', 32, readonly=True),
55
57
    }
56
58
 
57
59
    _defaults = {
58
60
        'type': 'entrega'
59
61
    }
60
62
 
61
 
 
62
63
    def default_get(self, cr, uid, fields, context=None):
63
64
        """
64
65
         To get default values for the object.
71
72
        """
72
73
        if context is None:
73
74
            context = {}
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)
78
80
        if pick:
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]
82
 
                    if field=='note':
 
84
                    if field == 'note':
83
85
                        res['note2'] = context[field]
84
86
        return res
85
87
 
89
91
 
90
92
        data_pool = self.pool.get('ir.model.data')
91
93
        obj = self.browse(cr, uid, ids[0])
92
 
        if obj.sure==False:
 
94
        if obj.sure == False:
93
95
            raise osv.except_osv(_('Alert !'), _('Check the box!!!'))
94
96
        context.update({'type': obj.type})
95
97
 
96
98
        action = {}
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")
98
101
        if action_model:
99
102
            action_pool = self.pool.get(action_model)
100
103
            action = action_pool.read(cr, uid, action_id, context=context)
108
111
 
109
112
        data_pool = self.pool.get('ir.model.data')
110
113
        obj = self.browse(cr, uid, ids[0])
111
 
        if obj.sure2==False:
 
114
        if obj.sure2 == False:
112
115
            raise osv.except_osv(_('Alert !'), _('Check the box!!!'))
113
116
 
114
117
        context.update({'note': obj.note})
116
119
            return self.action_number(cr, uid, ids, context=context)
117
120
 
118
121
        action = {}
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")
122
127
        if action_model:
123
128
            action_pool = self.pool.get(action_model)
124
129
            action = action_pool.read(cr, uid, action_id, context=context)
127
132
        return action
128
133
 
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),))
133
138
 
134
139
        for (id, number) in cr.fetchall():
135
140
            if not number:
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))
139
145
 
140
146
        return number
141
147
 
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')
150
156
        motiv = {
151
 
                'rep':'Reparación',
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',
156
 
                'otr':'Otros'
 
157
            'rep': 'Reparació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',
 
162
            'otr': 'Otros'
157
163
        }
158
164
 
159
165
        record_id = context and context.get('active_id', False) or False
165
171
 
166
172
        context.update({'nro': number})
167
173
        action = {}
168
 
        action_model,action_id = data_pool.get_object_reference(cr, uid, 'l10n_ve_stock', "action_pick_end")
 
174
        action_model, action_id = data_pool.get_object_reference(
 
175
            cr, uid, 'l10n_ve_stock', "action_pick_end")
169
176
        if action_model:
170
177
            action_pool = self.pool.get(action_model)
171
178
            action = action_pool.read(cr, uid, action_id, context=context)
174
181
        return action
175
182
 
176
183
 
177
 
picking_valued()
178
184
 
179
185
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: