19
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
##############################################################################
23
22
from osv import fields, osv
24
23
from tools.translate import _
25
import decimal_precision as dp
30
25
from datetime import datetime, timedelta
31
26
from dateutil.relativedelta import relativedelta
38
30
class sale_order(osv.osv):
39
31
_inherit = "sale.order"
123
115
class sale_make_internal_ship_wizard(osv.osv_memory):
124
116
_name = "sale.make.internal.ship.wizard"
117
_logger = logging.getLogger(_name)
127
119
'location_id': fields.many2one('stock.location', 'Location', required=True, domain="[('usage', '=', 'internal')]"),
128
120
'location_dest_id': fields.many2one('stock.location', 'Destination Location', required=True, domain="[('usage', '=', 'internal')]"),
144
136
def make_internal_shippment(self, cr, uid, ids, context=None):
145
137
data = self.read(cr, uid, ids)[0]
146
print >> sys.stderr, 'data',data
138
self._logger.debug('data `%s`', data)
147
139
record_id = context and context.get('active_id', False)
148
140
order_obj = self.pool.get('sale.order')
149
141
order = order_obj.browse(cr, uid, record_id, context=context)
160
152
#reloacte the source of out picking
161
153
for i in order.picking_ids:
162
if i.type== 'out' and i.state not in ['done', 'cancel']:
163
#stock_pick_obj = self.pool.get('stock.picking')
164
stock_move_obj = self.pool.get('stock.move')
165
loc_id = data['location_dest_id'][0]
166
for move in i.move_lines:
167
print >> sys.stderr, 'stock_pick write', loc_id, move.id
168
stock_move_obj.write(cr, uid, [move.id], {'location_id' : loc_id } )
154
if i.type== 'out' and i.state not in ['done', 'cancel']:
155
#stock_pick_obj = self.pool.get('stock.picking')
156
stock_move_obj = self.pool.get('stock.move')
157
loc_id = data['location_dest_id'][0]
158
for move in i.move_lines:
159
self._logger.debug('stock_pick write `%s` `%s`', loc_id, move.id)
160
stock_move_obj.write(cr, uid, [move.id], {'location_id' : loc_id } )
170
161
order_obj.action_ship_internal_create(cr, uid, [record_id], data['location_id'][0], data['location_dest_id'][0])
173
#print >>sys.stderr, 'make_internal_shipment ',internal, data, context
174
# opene correct shipping window
164
# open correct shipping window
175
165
pool = pooler.get_pool(cr.dbname)
176
166
mod_obj = pool.get('ir.model.data')
177
167
act_obj = pool.get('ir.actions.act_window')