[FIX] stock, sale_stock, purchase: fixed the dropshipping flow
bzr revid: qdp-launchpad@openerp.com-20140327121140-18yxvp8wcdlqvaa5
This commit is contained in:
parent
bf07b75045
commit
b8b22532a6
|
@ -784,7 +784,7 @@ class purchase_order(osv.osv):
|
|||
|
||||
def action_picking_create(self, cr, uid, ids, context=None):
|
||||
for order in self.browse(cr, uid, ids):
|
||||
picking_id = self.pool.get('stock.picking').create(cr, uid, {'picking_type_id': order.picking_type_id.id, 'partner_id': order.partner_id.id}, context=context)
|
||||
picking_id = self.pool.get('stock.picking').create(cr, uid, {'picking_type_id': order.picking_type_id.id, 'partner_id': order.dest_address_id.id or order.partner_id.id}, context=context)
|
||||
self._create_stock_moves(cr, uid, order, order.order_line, picking_id, context=context)
|
||||
|
||||
def picking_done(self, cr, uid, ids, context=None):
|
||||
|
@ -1280,7 +1280,7 @@ class procurement_order(osv.osv):
|
|||
#look for any other draft PO for the same supplier, to attach the new line on instead of creating a new draft one
|
||||
available_draft_po_ids = po_obj.search(cr, uid, [
|
||||
('partner_id', '=', partner.id), ('state', '=', 'draft'), ('picking_type_id', '=', procurement.rule_id.picking_type_id.id),
|
||||
('location_id', '=', procurement.location_id.id), ('company_id', '=', procurement.company_id.id)], context=context)
|
||||
('location_id', '=', procurement.location_id.id), ('company_id', '=', procurement.company_id.id), ('dest_address_id', '=', procurement.partner_dest_id.id)], context=context)
|
||||
if available_draft_po_ids:
|
||||
po_id = available_draft_po_ids[0]
|
||||
#look for any other PO line in the selected PO with same product and UoM to sum quantities instead of creating a new po line
|
||||
|
@ -1308,6 +1308,7 @@ class procurement_order(osv.osv):
|
|||
'company_id': procurement.company_id.id,
|
||||
'fiscal_position': partner.property_account_position and partner.property_account_position.id or False,
|
||||
'payment_term_id': partner.property_supplier_payment_term.id or False,
|
||||
'dest_address_id': procurement.partner_dest_id.id,
|
||||
}
|
||||
po_id = self.create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context=context)
|
||||
po_line_id = po_obj.browse(cr, uid, po_id, context=context).order_line[0].id
|
||||
|
|
|
@ -84,10 +84,10 @@ class sale_order(osv.osv):
|
|||
vals = super(sale_order, self)._prepare_order_line_procurement(cr, uid, order, line, group_id=group_id, context=context)
|
||||
location_id = order.partner_shipping_id.property_stock_customer.id
|
||||
vals['location_id'] = location_id
|
||||
|
||||
routes = line.route_id and [(4, line.route_id.id)] or []
|
||||
vals['route_ids'] = routes
|
||||
vals['warehouse_id'] = order.warehouse_id and order.warehouse_id.id or False
|
||||
vals['partner_dest_id'] = order.partner_shipping_id.id
|
||||
return vals
|
||||
|
||||
_columns = {
|
||||
|
|
|
@ -96,6 +96,7 @@ class procurement_order(osv.osv):
|
|||
_inherit = "procurement.order"
|
||||
_columns = {
|
||||
'location_id': fields.many2one('stock.location', 'Procurement Location'), # not required because task may create procurements that aren't linked to a location with project_mrp
|
||||
'partner_dest_id': fields.many2one('res.partner', 'Customer Address', help="In case of dropshipping, we need to know the destination address more precisely"),
|
||||
'move_ids': fields.one2many('stock.move', 'procurement_id', 'Moves', help="Moves created by the procurement"),
|
||||
'move_dest_id': fields.many2one('stock.move', 'Destination Move', help="Move which caused (created) the procurement"),
|
||||
'route_ids': fields.many2many('stock.location.route', 'stock_location_route_procurement', 'procurement_id', 'route_id', 'Preferred Routes', help="Preferred route to be followed by the procurement order. Usually copied from the generating document (SO) but could be set up manually."),
|
||||
|
|
|
@ -1673,6 +1673,7 @@
|
|||
</xpath>
|
||||
<xpath expr="//field[@name='rule_id']" position="replace">
|
||||
<field name="rule_id" domain="['|', ('location_id', '=', False), ('location_id', '=', location_id)]"/>
|
||||
<field name="partner_dest_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue