diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index be1b7d66663..bf308f191b5 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -170,7 +170,6 @@ class stock_location(osv.osv):
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the stock location without removing it."),
'usage': fields.selection([('supplier', 'Supplier Location'), ('view', 'View'), ('internal', 'Internal Location'), ('customer', 'Customer Location'), ('inventory', 'Inventory'), ('procurement', 'Procurement'), ('production', 'Production'), ('transit', 'Transit Location for Inter-Companies Transfers')], 'Location Type', required=True),
'allocation_method': fields.selection([('fifo', 'FIFO'), ('lifo', 'LIFO'), ('nearest', 'Nearest')], 'Allocation Method', required=True),
-
'complete_name': fields.function(_complete_name, method=True, type='char', size=100, string="Location Name"),
'stock_real': fields.function(_product_qty_available, method=True, type='float', string='Real Stock', multi="stock"),
@@ -193,6 +192,8 @@ class stock_location(osv.osv):
"validated automatically. With 'Manual Operation', the stock move has to be validated "\
"by a worker. With 'Automatic No Step Added', the location is replaced in the original move."
),
+ 'chained_picking_type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal'), ('delivery', 'Delivery')], 'Shipping Type', help="Shipping type specify of the chained move, goods coming in or going out."),
+ 'chained_company_id': fields.many2one('res.company', 'Chained Company', help='Set here the belonging company of the chained move'),
'chained_delay': fields.integer('Chained lead time (days)'),
'address_id': fields.many2one('res.partner.address', 'Location Address'),
'icon': fields.selection(tools.icons, 'Icon', size=64),
@@ -237,7 +238,7 @@ class stock_location(osv.osv):
elif location.chained_location_type == 'fixed':
result = location.chained_location_id
if result:
- return result, location.chained_auto_packing, location.chained_delay, location.chained_journal_id and location.chained_journal_id.id or False
+ return result, location.chained_auto_packing, location.chained_delay, location.chained_journal_id and location.chained_journal_id.id or False, location.chained_company_id and location.chained_company_id.id or False, location.chained_picking_type
return result
def picking_type_get(self, cr, uid, from_location, to_location, context={}):
@@ -1572,11 +1573,10 @@ class stock_move(osv.osv):
def create_chained_picking(self, cr, uid, moves, context):
new_moves = []
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
- ptype = self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
+ ptype = todo[0][1][5] and todo[0][1][5] or self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
pick_name = ''
if ptype == 'delivery':
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.delivery')
- print todo
pickid = self.pool.get('stock.picking').create(cr, uid, {
'name': pick_name or picking.name,
'origin': str(picking.origin or ''),
@@ -1585,16 +1585,18 @@ class stock_move(osv.osv):
'move_type': picking.move_type,
'auto_picking': todo[0][1][1] == 'auto',
'stock_journal_id': todo[0][1][3],
+ 'company_id': todo[0][1][4],
'address_id': picking.address_id.id,
'invoice_state': 'none'
})
- for move, (loc, auto, delay, journal) in todo:
+ for move, (loc, auto, delay, journal, company_id, ptype) in todo:
new_id = self.pool.get('stock.move').copy(cr, uid, move.id, {
'location_id': move.location_dest_id.id,
'location_dest_id': loc.id,
'date_moved': time.strftime('%Y-%m-%d'),
'picking_id': pickid,
'state': 'waiting',
+ 'company_id': company_id,
'move_history_ids': [],
'date_planned': (datetime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + relativedelta(days=delay or 0)).strftime('%Y-%m-%d'),
'move_history_ids2': []}
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index c9a157a74b9..5733f8c9375 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -422,7 +422,9 @@
-
+
+
+
diff --git a/addons/stock_location/mrp_pull.py b/addons/stock_location/mrp_pull.py
index a8a5026bf4c..4f9c22a54cd 100644
--- a/addons/stock_location/mrp_pull.py
+++ b/addons/stock_location/mrp_pull.py
@@ -68,7 +68,7 @@ class procurement_order(osv.osv):
origin = (proc.origin or proc.name or '').split(':')[0] +':'+line.name
picking_id = self.pool.get('stock.picking').create(cr, uid, {
'origin': origin,
- 'company_id': line.company_id and line.company_id.id or False,
+ 'company_id': line.chained_company_id and line.chained_company_id.id or False,
'type': line.picking_type,
'stock_journal_id': line.journal_id and line.journal_id.id or False,
'move_type': 'one',
@@ -79,7 +79,7 @@ class procurement_order(osv.osv):
move_id = self.pool.get('stock.move').create(cr, uid, {
'name': line.name,
'picking_id': picking_id,
- 'company_id': line.company_id and line.company_id.id or False,
+ 'company_id': line.chained_company_id and line.chained_company_id.id or False,
'product_id': proc.product_id.id,
'date_planned': proc.date_planned,
'product_qty': proc.product_qty,
diff --git a/addons/stock_location/stock.py b/addons/stock_location/stock.py
index f3460fa7e30..d49b9ffbafa 100644
--- a/addons/stock_location/stock.py
+++ b/addons/stock_location/stock.py
@@ -40,6 +40,7 @@ class stock_location_path(osv.osv):
("none", "Not from Picking")], "Invoice Status",
required=True,),
'picking_type': fields.selection([('out','Sending Goods'),('in','Getting Goods'),('internal','Internal'),('delivery','Delivery')], 'Shipping Type', required=True, select=True, help="Depending on the company, choose whatever you want to receive or send products"),
+ 'chained_company_id': fields.many2one('res.company', 'Chained Company', help='Set here the belonging company of the chained move'),
'auto': fields.selection(
[('auto','Automatic Move'), ('manual','Manual Operation'),('transparent','Automatic No Step Added')],
'Automatic Move',
@@ -54,6 +55,7 @@ class stock_location_path(osv.osv):
'auto': lambda *arg: 'auto',
'delay': lambda *arg: 1,
'invoice_state': lambda *args: 'none',
+ 'picking_type':lambda *args:'out',
}
stock_location_path()
@@ -71,6 +73,7 @@ class product_pulled_flow(osv.osv):
'company_id': fields.many2one('res.company', 'Company', help="Is used to know to which company belong packings and moves"),
'partner_address_id': fields.many2one('res.partner.address', 'Partner Address'),
'picking_type': fields.selection([('out','Sending Goods'),('in','Getting Goods'),('internal','Internal'),('delivery','Delivery')], 'Shipping Type', required=True, select=True, help="Depending on the company, choose whatever you want to receive or send products"),
+ 'chained_company_id': fields.many2one('res.company', 'Chained Company', help='Set here the belonging company of the chained move'),
'product_id':fields.many2one('product.product','Product'),
'invoice_state': fields.selection([
("invoiced", "Invoiced"),
@@ -117,7 +120,7 @@ class stock_location(osv.osv):
if product:
for path in product.path_ids:
if path.location_from_id.id == location.id:
- return path.location_dest_id, path.auto, path.delay, path.journal_id.id
+ return path.location_dest_id, path.auto, path.delay, path.journal_id and path.journal_id.id or False, path.chained_company_id and path.chained_companyd_id.id or False, path.picking_type
return super(stock_location, self).chained_location_get(cr, uid, location, partner, product, context)
stock_location()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: