[WIP] picking_type_id on picking instead of move (becomes related) and do not group moves into pickings for production and inventory, rule_id on stock move
bzr revid: jco@openerp.com-20130724170017-glk2b3vqlubzm86q
This commit is contained in:
@@ -895,7 +895,6 @@ class mrp_production(osv.osv):
|
||||
'move_dest_id': production.move_prod_id.id,
|
||||
'state': 'waiting',
|
||||
'company_id': production.company_id.id,
|
||||
'picking_type_id': self.pool.get("ir.model.data").get_object_reference(cr, uid, 'stock', 'picking_type_internal')[1],
|
||||
}
|
||||
move_id = stock_move.create(cr, uid, data, context=context)
|
||||
production.write({'move_created_ids': [(6, 0, [move_id])]}, context=context)
|
||||
@@ -925,7 +924,6 @@ class mrp_production(osv.osv):
|
||||
'state': 'waiting',
|
||||
'company_id': production.company_id.id,
|
||||
'procure_method': 'make_to_order',
|
||||
'picking_type_id': self.pool.get("ir.model.data").get_object_reference(cr, uid, 'stock', 'picking_type_internal')[1],
|
||||
})
|
||||
production.write({'move_lines': [(4, move_id)]}, context=context)
|
||||
return move_id
|
||||
|
||||
@@ -623,10 +623,10 @@ class purchase_order(osv.osv):
|
||||
|
||||
def _prepare_order_picking(self, cr, uid, order, context=None):
|
||||
type_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'picking_type_in')[1]
|
||||
type = self.pool.get("picking.type").browse(cr, uid, type_id, context=context)
|
||||
type = self.pool.get("stock.picking.type").browse(cr, uid, type_id, context=context)
|
||||
|
||||
return {
|
||||
'name': self.pool.get('ir.sequence').get(cr, uid, type.sequence_id.id, 'id'),
|
||||
'name': self.pool.get('ir.sequence').get_id(cr, uid, type.sequence_id.id, 'id'),
|
||||
'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
|
||||
'date': self.date_to_datetime(cr, uid, order.date_order, context),
|
||||
'partner_id': order.dest_address_id.id or order.partner_id.id,
|
||||
@@ -635,6 +635,7 @@ class purchase_order(osv.osv):
|
||||
'purchase_id': order.id,
|
||||
'company_id': order.company_id.id,
|
||||
'move_lines' : [],
|
||||
'picking_type_id': type_id,
|
||||
}
|
||||
|
||||
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
|
||||
@@ -657,7 +658,6 @@ class purchase_order(osv.osv):
|
||||
'purchase_line_id': order_line.id,
|
||||
'company_id': order.company_id.id,
|
||||
'price_unit': order_line.price_unit,
|
||||
'picking_type_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'picking_type_in')[1]
|
||||
}
|
||||
|
||||
def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
|
||||
|
||||
@@ -82,8 +82,8 @@ class procurement_order(osv.osv):
|
||||
'location_dest_id': procurement.rule_id.location_id.id,
|
||||
'move_dest_id': procurement.move_dest_id and procurement.move_dest_id.id or False,
|
||||
#'cancel_cascade': procurement.rule_id and procurement.rule_id.cancel_cascade or False,
|
||||
'group_id': procurement.group_id and procurement.group_id.id or False,
|
||||
'picking_type_id': procurement.rule_id.picking_type_id.id,
|
||||
'group_id': procurement.group_id and procurement.group_id.id or False,
|
||||
'rule_id': procurement.rule_id.id,
|
||||
}
|
||||
|
||||
def _run(self, cr, uid, procurement, context=None):
|
||||
|
||||
+16
-15
@@ -403,12 +403,8 @@ class stock_picking(osv.osv):
|
||||
|
||||
def create(self, cr, user, vals, context=None):
|
||||
if ('name' not in vals) or (vals.get('name') in ('/', False)):
|
||||
import pdb
|
||||
pdb.set_trace()
|
||||
if 'move_lines' in vals:
|
||||
if vals['move_lines'][0] and vals['move_lines'][0][2] and vals['move_lines'][0][2]['picking_type_id']:
|
||||
sequence_id = self.pool.get('stock.picking.type').browse(cr, user, vals['move_lines'][0][2]['picking_type_id'], context=context).sequence_id.id
|
||||
vals['name'] = self.pool.get('ir.sequence').get_id(cr, user, sequence_id, 'id', context=context)
|
||||
sequence_id = self.pool.get('stock.picking.type').browse(cr, user, vals['picking_type_id'], context=context).sequence_id.id
|
||||
vals['name'] = self.pool.get('ir.sequence').get_id(cr, user, sequence_id, 'id', context=context)
|
||||
return super(stock_picking, self).create(cr, user, vals, context)
|
||||
|
||||
|
||||
@@ -477,7 +473,10 @@ class stock_picking(osv.osv):
|
||||
'location_id': fields.related('move_lines', 'location_id', type='many2one', relation='stock.location', string='Location', readonly=True),
|
||||
'location_dest_id': fields.related('move_lines', 'location_dest_id', type='many2one', relation='stock.location', string='Destination Location', readonly=True),
|
||||
'group_id': fields.related('move_lines', 'group_id', type='many2one', relation='procurement.group', string='Procurement Group', readonly=True),
|
||||
'picking_type_id': fields.related('move_lines', 'picking_type_id', type='many2one', relation='stock.picking.type', string="Picking Type", readonly=True),
|
||||
#Picking type will be on the picking itself instead
|
||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', required=True),
|
||||
#related('move_lines', 'picking_type_id', type='many2one', relation='stock.picking.type', string="Picking Type", readonly=True),
|
||||
'rule_id': fields.related('move_lines', 'rule_id', type='many2one', relation='procurement.rule', string="Procurement Rule", readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'name': lambda self, cr, uid, context: '/',
|
||||
@@ -1000,12 +999,13 @@ class stock_move(osv.osv):
|
||||
|
||||
# used for colors in tree views:
|
||||
'scrapped': fields.related('location_dest_id','scrap_location',type='boolean',relation='stock.location',string='Scrapped', readonly=True),
|
||||
'picking_type_id': fields.many2one('stock.picking.type', 'Picking Type', help="The picking type will be used for composing the views and reports the related picking", required=True),
|
||||
#'type': fields.related('picking_id', 'type', type='selection', selection=[('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], string='Shipping Type'),
|
||||
|
||||
'picking_type_id': fields.related('picking_id', 'picking_type_id', type='many2one', relation='stock.picking.type', string="Picking type" ,readonly=True),
|
||||
'quant_ids': fields.many2many('stock.quant', 'stock_quant_move_rel', 'move_id', 'quant_id', 'Quants'),
|
||||
'reserved_quant_ids': fields.one2many('stock.quant', 'reservation_id', 'Reserved quants'),
|
||||
'remaining_qty': fields.function(_get_remaining_qty, type='float', string='Remaining Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), states={'done': [('readonly', True)]}),
|
||||
'group_id': fields.many2one('procurement.group', 'Procurement Group'),
|
||||
'rule_id': fields.many2one('procurement.rule', 'Procurement Rule'),
|
||||
}
|
||||
|
||||
def _check_location(self, cr, uid, ids, context=None):
|
||||
@@ -1329,7 +1329,8 @@ class stock_move(osv.osv):
|
||||
pick_obj.write(cr, uid, [original_picking.id], {'name': back_order_name})
|
||||
pick = pick_obj.copy(cr, uid, original_picking.id, {'name': new_picking_name,
|
||||
'move_lines': [],
|
||||
'state': 'draft'})
|
||||
'state': 'draft'
|
||||
})
|
||||
|
||||
pick_obj.message_post(cr, uid, original_picking.id, body=_("Back order <em>%s</em> has been <b>created</b>.") % (back_order_name), context=context)
|
||||
unlink_operation_order = [(2, op.id) for op in original_picking.pack_operation_ids]
|
||||
@@ -1338,12 +1339,13 @@ class stock_move(osv.osv):
|
||||
#a backorder picking doesn't exist yet, create a new one
|
||||
values = {'origin': move.origin,
|
||||
'company_id': move.company_id and move.company_id.id or False,
|
||||
# 'type': 'internal',
|
||||
'move_type': 'one',
|
||||
'partner_id': move.partner_id and move.partner_id.id or False,
|
||||
#'invoice_state': move.invoice_state
|
||||
'state': 'confirmed',
|
||||
'group_id': move.group_id and move.group_id.id or False}
|
||||
'group_id': move.group_id and move.group_id.id or False,
|
||||
'picking_type_id': move.rule_id and move.rule_id.picking_type_id.id or False,
|
||||
}
|
||||
pick = pick_obj.create(cr, uid, values, context=context)
|
||||
return pick
|
||||
|
||||
@@ -1372,7 +1374,7 @@ class stock_move(osv.osv):
|
||||
state = 'waiting'
|
||||
states[state].append(move.id)
|
||||
|
||||
if not move.picking_id:
|
||||
if not move.picking_id and move.location_id.usage not in ['production', 'inventory'] and move.location_dest_id.usage not in ['production', 'inventory']:
|
||||
pick = self._find_or_create_picking(cr, uid, move, context=context)
|
||||
move.write({'picking_id': pick})
|
||||
|
||||
@@ -1860,8 +1862,7 @@ class stock_inventory(osv.osv):
|
||||
'product_id': line.product_id.id,
|
||||
'product_uom': line.product_uom.id,
|
||||
'date': inv.date,
|
||||
'company_id': line.location_id.company_id.id,
|
||||
'picking_type_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'stock', 'picking_type_inventory')[1],
|
||||
'company_id': line.location_id.company_id.id,
|
||||
}
|
||||
|
||||
if change > 0:
|
||||
|
||||
@@ -67,10 +67,10 @@
|
||||
-
|
||||
!record {model: stock.picking, id: outgoing_shipment}:
|
||||
location_dest_id: location_delivery_counter
|
||||
picking_type_id: picking_type_out
|
||||
-
|
||||
!record {model: stock.move, id: outgoing_shipment_icecream}:
|
||||
picking_id: outgoing_shipment
|
||||
picking_type_id: picking_type_out
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
product_uom_qty: 130.0
|
||||
@@ -80,10 +80,10 @@
|
||||
!record {model: stock.picking, id: incomming_shipment}:
|
||||
partner_id: base.res_partner_address_9
|
||||
location_dest_id: location_refrigerator
|
||||
picking_type_id: picking_type_in
|
||||
-
|
||||
!record {model: stock.move, id: incomming_shipment_icecream}:
|
||||
picking_id: incomming_shipment
|
||||
picking_type_id: picking_type_in
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
product_uom_qty: 50.0
|
||||
|
||||
@@ -716,7 +716,7 @@
|
||||
<field name="name"/>
|
||||
<field name="picking_id" string="Reference"/>
|
||||
<field name="origin"/>
|
||||
<field name="picking_type_id" on_change="onchange_move_type(picking_type_id)"/>
|
||||
<field name="picking_type_id"/>
|
||||
<field name="create_date" invisible="1" groups="base.group_no_one"/>
|
||||
<field name="product_id" on_change="onchange_product_id(product_id,location_id,location_dest_id, False)"/>
|
||||
<field name="product_uom_qty" on_change="onchange_quantity(product_id, product_uom_qty, product_uom, product_uos)"/>
|
||||
@@ -805,7 +805,7 @@
|
||||
<group name="origin_grp" string="Origin">
|
||||
<field name="origin"/>
|
||||
<field name="picking_id" domain="[('picking_type_id','=',picking_type_id)]"/>
|
||||
<field name="picking_type_id" on_change="onchange_move_type(picking_type_id)"/>
|
||||
<field name="picking_type_id"/>
|
||||
<field name="location_id" groups="stock.group_locations"/>
|
||||
<field name="create_date" groups="base.group_no_one"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user