← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/sale-wkfl/add-sale_dropshipping-jge into lp:sale-wkfl

 

Joël Grand-Guillaume @ camptocamp has proposed merging lp:~camptocamp/sale-wkfl/add-sale_dropshipping-jge into lp:sale-wkfl.

Commit message:
[ADD] module sale_dropshipping Makes it better to deal with purchases with known sale schemes, specially the following case:
1) normal
2) direct delivery (also called drop shipping)
3) direct invoice
4) direct delivery and direct invoice

Requested reviews:
  Sale Core Editors (sale-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/sale-wkfl/add-sale_dropshipping-jge/+merge/193601

Hi,


This proposal add the module sale_dropshiping (originally from Akretion). 

Makes it better to deal with purchases with known sale schemes, specially the following case:
1) normal
2) direct delivery (also called drop shipping)
3) direct invoice
4) direct delivery and direct invoice
See the attached diagram in images/purchase_to_sale.png to see the difference between those flows.

In all those specific MTO (by opposition of MTS) cases, it will link the sale order line and the purchase order lines together.

A good idea might be to use this module with the mrp_jit module if you want MTO flows to be automatically dealt with right
at the sale order validation.

You can also tell if product suppliers accept drop shipping or not. If they accept it and if sale order
line has more products than the virtual quantity available, then it selects drop shipping by default.

In the out going product list view, you can filter in or out drop shipping picking.


Regards,
-- 
https://code.launchpad.net/~camptocamp/sale-wkfl/add-sale_dropshipping-jge/+merge/193601
Your team Sale Core Editors is requested to review the proposed merge of lp:~camptocamp/sale-wkfl/add-sale_dropshipping-jge into lp:sale-wkfl.
=== added directory 'sale_dropshipping'
=== added file 'sale_dropshipping/__init__.py'
--- sale_dropshipping/__init__.py	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/__init__.py	2013-11-01 13:29:27 +0000
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 20010 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import purchase
+import sale
+import product
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'sale_dropshipping/__openerp__.py'
--- sale_dropshipping/__openerp__.py	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/__openerp__.py	2013-11-01 13:29:27 +0000
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 20010 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    "name" : "Sale Dropshipping",
+    "version": "1.0",
+    "author" : "Akretion",
+    "website" : "http://www.openerp.com";,
+    "category" : "Generic Modules/Purchase",
+    "depends" : ["purchase",
+                 "sale_stock",
+                 ],
+    "description": """
+Makes it better to deal with purchases with known sale schemes, specially the following case:
+1) normal
+2) direct delivery (also called drop shipping)
+3) direct invoice
+4) direct delivery and direct invoice
+See the attached diagram in images/purchase_to_sale.png to see the difference between those flows.
+
+In all those specific MTO (by opposition of MTS) cases, it will link the sale order line and the purchase order lines together.
+
+A good idea might be to use this module with the mrp_jit module if you want MTO flows to be automatically dealt with right
+at the sale order validation.
+
+You can also tell if product suppliers accept drop shipping or not. If they accept it and if sale order
+line has more products than the virtual quantity available, then it selects drop shipping by default.
+
+In the out going product list view, you can filter in or out drop shipping picking.
+
+TODO: eventually it might be interesting to do a chained move from supplier to internal location and
+from internal location to customer instead of supplier o customer directly.
+This would enable moves to properly generate accounting moves in the stock journal for better tracking.
+    """,
+    "init_xml" : [],
+    "demo_xml" : [],
+    "test" : [],
+    "update_xml": ["purchase_view.xml", "sale_view.xml", "product_view.xml", "stock_view.xml"],
+    'images': ['images/purchase_to_sale.png'],
+    'installable': True,
+    'active': False,
+    'certificate': None,
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added directory 'sale_dropshipping/i18n'
=== added file 'sale_dropshipping/i18n/pt_BR.po'
--- sale_dropshipping/i18n/pt_BR.po	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/i18n/pt_BR.po	2013-11-01 13:29:27 +0000
@@ -0,0 +1,89 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* purchase_to_sale
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.0.3\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
+"POT-Creation-Date: 2011-09-08 16:18+0000\n"
+"PO-Revision-Date: 2011-09-08 16:18+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: purchase_to_sale
+#: selection:purchase.order,sale_flow:0
+msgid "Direct Invoice"
+msgstr "Faturamento Direto"
+
+#. module: purchase_to_sale
+#: field:purchase.order,sale_id:0
+msgid "Related Sale Order"
+msgstr "Pedido de Venda Relacionado"
+
+#. module: purchase_to_sale
+#: field:purchase.order,sale_flow:0
+msgid "Sale Flow"
+msgstr "Fluxo de Venda"
+
+#. module: purchase_to_sale
+#: sql_constraint:purchase.order:0
+msgid "Order Reference must be unique !"
+msgstr "Referência de Pedido deve ser única !"
+
+#. module: purchase_to_sale
+#: selection:purchase.order,sale_flow:0
+msgid "Normal"
+msgstr "Normal"
+
+#. module: purchase_to_sale
+#: model:ir.module.module,description:purchase_to_sale.module_meta_information
+msgid "\n"
+"Makes it better to deal with purchases with known sale schemes, specially the following case:\n"
+"1) normal\n"
+"2) direct delivery\n"
+"3) direct invoice\n"
+"4) direct delivery and direct invoice\n"
+"    "
+msgstr "\n"
+"Makes it better to deal with purchases with known sale schemes, specially the following case:\n"
+"1) normal\n"
+"2) direct delivery\n"
+"3) direct invoice\n"
+"4) direct delivery and direct invoice\n"
+"    "
+
+#. module: purchase_to_sale
+#: field:purchase.order,analytic_account_id:0
+msgid "Analytic Account"
+msgstr "Centro do Custo"
+
+#. module: purchase_to_sale
+#: help:purchase.order,sale_flow:0
+msgid "Is this order tied to a sale order? How will it be delivered and invoiced then?"
+msgstr "Is this order tied to a sale order? How will it be delivered and invoiced then?"
+
+#. module: purchase_to_sale
+#: selection:purchase.order,sale_flow:0
+msgid "Direct Delivery"
+msgstr "Entrega Direta"
+
+#. module: purchase_to_sale
+#: model:ir.module.module,shortdesc:purchase_to_sale.module_meta_information
+msgid "Purchase To Sale"
+msgstr "Comprar para Venda"
+
+#. module: purchase_to_sale
+#: model:ir.model,name:purchase_to_sale.model_purchase_order
+msgid "Purchase Order"
+msgstr "Pedido de Compra"
+
+#. module: purchase_to_sale
+#: selection:purchase.order,sale_flow:0
+msgid "Direct Invoice/Indirect Delivery"
+msgstr "Faturamento Direto/Entrega Indireta"
+

=== added directory 'sale_dropshipping/images'
=== added file 'sale_dropshipping/images/purchase_to_sale.png'
Binary files sale_dropshipping/images/purchase_to_sale.png	1970-01-01 00:00:00 +0000 and sale_dropshipping/images/purchase_to_sale.png	2013-11-01 13:29:27 +0000 differ
=== added file 'sale_dropshipping/product.py'
--- sale_dropshipping/product.py	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/product.py	2013-11-01 13:29:27 +0000
@@ -0,0 +1,62 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2011 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+
+class product_supplierinfo(osv.osv):
+    _inherit = "product.supplierinfo"
+
+    _columns = {
+        "direct_delivery_flag" : fields.boolean('Drop Shipping?'),
+    }
+
+product_supplierinfo()
+
+
+class product_product(osv.osv):
+    _inherit = "product.product"
+
+    def _is_direct_delivery_from_product(self, cr, uid, ids, name, arg, context=None):
+        res = {}
+        def is_direct_delivery_from_suppliers(product):
+            cr.execute('select direct_delivery_flag from product_supplierinfo inner join res_partner on product_supplierinfo.name = res_partner.id where product_id=%d and active=true order by sequence ASC LIMIT 1;' %  product.product_tmpl_id)
+            result = cr.fetchone()
+            if result and result[0]:
+                return True
+            return False
+
+        for product in self.browse(cr, uid, ids):
+            if context.has_key('qty'):
+                if product.virtual_available < context['qty']: #TODO deal with partial availability?
+                    res[product.id] = is_direct_delivery_from_suppliers(product)
+                else: #available in stock
+                    res[product.id] = False
+            else: #no quantity mentioned so we answer for 'any' quantity
+                res[product.id] = is_direct_delivery_from_suppliers(product)
+        return res
+
+    _columns = {
+        'is_direct_delivery_from_product': fields.function(_is_direct_delivery_from_product, method=True, type='boolean', string="Is Supplier Direct Delivery Automatic?"),
+    }
+
+product_product()
+

=== added file 'sale_dropshipping/product_view.xml'
--- sale_dropshipping/product_view.xml	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/product_view.xml	2013-11-01 13:29:27 +0000
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<openerp>
+        <data>
+                <record model="ir.ui.view" id="product_supplierinfo_tree_view_partner_direct_delivery_tree">
+                        <field name="name">product.supplierinfo.tree.direct_delivery.inherit</field>
+                        <field name="model">product.supplierinfo</field>
+                        <field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
+                        <field name="type">tree</field>
+                        <field name="arch" type="xml">
+                                        <field position="after" name="name">
+                                                <field name="direct_delivery_flag"/>
+                                        </field>
+                        </field>
+                </record>
+          
+                <record model="ir.ui.view" id="product_supplierinfo_form_view_partner_direct_delivery_form">
+                        <field name="name">product.supplierinfo.form.direct_delivery.inherit</field>
+                        <field name="model">product.supplierinfo</field>
+                        <field name="inherit_id" ref="product.product_supplierinfo_form_view" />
+                        <field name="type">form</field>
+                        <field name="arch" type="xml">
+                                <field position="after" name="product_code">
+                                        <field name="direct_delivery_flag"/>
+                                </field>
+                        </field>
+                </record>
+        </data>
+</openerp>

=== added file 'sale_dropshipping/purchase.py'
--- sale_dropshipping/purchase.py	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/purchase.py	2013-11-01 13:29:27 +0000
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2010 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from tools.translate import _
+from osv import fields, osv
+import netsvc
+from datetime import datetime
+
+class purchase_order_line(osv.osv):
+    _inherit = "purchase.order.line"
+
+    _columns = {
+        'sale_order_line_id': fields.many2one('sale.order.line', 'Sale Order Line'),
+    }
+
+purchase_order_line()
+
+class purchase_order(osv.osv):
+    _inherit = "purchase.order"
+
+    _columns = {
+        'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'),
+        'sale_id': fields.many2one('sale.order', 'Related Sale Order'),
+        'sale_flow': fields.selection([('normal', 'Normal'), ('direct_delivery', 'Drop Shipping'), ('direct_invoice', 'Direct Invoice/Indirect Delivery'), ('direct_invoice_and_delivery', 'Direct Invoice')], 'Sale Flow', help="Is this order tied to a sale order? How will it be delivered and invoiced then?"),
+    }
+
+    _defaults = {
+        'sale_flow': 'normal',
+    }
+
+    def sale_flow_change(self, cr, uid, ids, sale_flow, sale_id,
+                         warehouse_id, context=None):
+        if sale_id:
+            sale_obj = self.pool.get('sale.order')
+            partner_obj = self.pool.get('res.partner')
+            warehouse_obj = self.pool.get('stock.warehouse')
+            sale = sale_obj.browse(cr, uid, sale_id, context=context)
+            partner_id = sale.partner_id.id
+            if sale_flow in ('direct_delivery', 'direct_invoice_and_delivery'):
+                partner = partner_obj.browse(cr, uid, partner_id,
+                                             context=context)
+                address = partner.address_get(['delivery'])['delivery']
+                vals = {'location_id': partner.property_stock_customer.id,
+                        'dest_address_id': address}
+                if sale_flow == 'direct_delivery':
+                    vals['invoice_method'] = 'order'
+                else:
+                    vals['invoice_method'] = 'picking'
+                return {'value': vals}
+            else:
+                warehouse = warehouse_obj.browse(cr, uid,
+                                                 warehouse_id, context=context)
+                company_partner = warehouse.company_id.partner_id
+                address = company_partner.address_get(['delivery'])['delivery']
+                vals = {'invoice_method': 'picking',
+                        'location_id': warehouse.lot_input_id.id,
+                        'dest_address_id': address}
+                if sale_flow == 'direct_invoice':
+                    vals['invoice_method'] = 'picking'
+                return {'value': vals}
+        return {}
+
+    def action_picking_create(self,cr, uid, ids, context=None):
+        res = super(purchase_order, self).action_picking_create(cr, uid, ids, context=context)
+        picking_obj = self.pool.get('stock.picking')
+        for purchase in self.browse(cr, uid, ids, context=context):
+            if res: #TODO bad code inherited from OpenERP, see bug https://bugs.launchpad.net/openobject-addons/+bug/788789
+                if purchase.sale_flow == 'direct_delivery':
+                    if purchase.sale_id and purchase.sale_id.order_policy == 'picking':
+                        invoice_control = '2binvoiced'
+                    else:
+                        invoice_control = 'none'
+                    picking_obj.write(
+                        cr, uid, res,
+                        {'type': 'out',
+                         'invoice_state': invoice_control,
+                         'sale_id': purchase.sale_id and purchase.sale_id.id},
+                        context=context)
+                elif purchase.sale_flow == 'direct_invoice':
+                    picking_obj.write(cr, uid, res,
+                                      {'invoice_state': 'none'},
+                                      context=context)
+                elif purchase.sale_flow == 'direct_invoice_and_delivery':
+                    picking_obj.write(
+                        cr, uid, res,
+                        {'type': 'out',
+                         'invoice_state': 'none',
+                         'sale_id': purchase.sale_id and purchase.sale_id.id},
+                        context=context)
+        return res
+
+
+purchase_order()
+

=== added file 'sale_dropshipping/purchase_view.xml'
--- sale_dropshipping/purchase_view.xml	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/purchase_view.xml	2013-11-01 13:29:27 +0000
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<record id="ir_ui_view_purchase_to_sale" model="ir.ui.view">
+                        <field name="model">purchase.order</field>
+			<field name="inherit_id" ref="purchase.purchase_order_form"/>
+			<field name="name">ir_ui_view_purchase_to_sale</field>
+			<field name="arch" type="xml">
+                                <field name="invoice_method" position="after">                    
+                                        <field name="sale_flow" on_change="sale_flow_change(sale_flow, sale_id, warehouse_id)"/>
+                                        <field name="sale_id" on_change="sale_flow_change(sale_flow, sale_id, warehouse_id)" attrs="{'invisible':[('sale_flow','in',['normal', 'direct_invoice'])]}"/>
+                                        <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
+                                </field>
+			</field>
+		</record>
+
+        <record id="ir_ui_view_purchase_to_sale_purchase" model="ir.ui.view">
+            <field name="model">purchase.order</field>
+            <field name="inherit_id" ref="purchase.view_purchase_order_filter"/>
+            <field name="name">ir_ui_view_purchase_to_sale_purchase</field>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <field name="partner_id" position="before">
+                    <field name="sale_flow"/>
+                </field>
+            </field>
+        </record>
+
+	</data>
+</openerp>

=== added file 'sale_dropshipping/sale.py'
--- sale_dropshipping/sale.py	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/sale.py	2013-11-01 13:29:27 +0000
@@ -0,0 +1,136 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2011 Akretion LDTA (<http://www.akretion.com>).
+#    @author Raphaël Valyi
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+from datetime import datetime, timedelta
+from dateutil.relativedelta import relativedelta
+from tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
+import netsvc
+
+class sale_order_line(osv.osv):
+    _inherit = "sale.order.line"
+
+    def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
+            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
+            lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
+        
+        result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty,
+            uom, qty_uos, uos, name, partner_id, lang, update_tax, date_order, packaging, fiscal_position, flag, context)
+
+        if product:
+            context = {'lang': lang, 'partner_id': partner_id, 'qty': qty}
+            product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context)
+            if product_obj.is_direct_delivery_from_product:
+                result['value'].update({'type': 'make_to_order', 'sale_flow': 'direct_delivery'})      
+        return result
+
+    def _purchase_order_line_id(self, cr, uid, ids, field_name, arg, context=None):
+        result = {}
+        po_line_class = self.pool.get('purchase.order.line')
+        for order_line in self.browse(cr, uid, ids, context=context):
+            po_line_ids = po_line_class.search(cr, uid, [('sale_order_line_id', '=', order_line.id), ('order_id.state', '!=', 'cancel')])
+            result[order_line.id] = po_line_ids and po_line_ids[0] or False
+        return result
+
+
+    _columns = {
+        'sale_flow': fields.selection([('normal', 'Normal'), ('direct_delivery', 'Drop Shipping'), ('direct_invoice', 'Direct Invoice/Indirect Delivery'), ('direct_invoice_and_delivery', 'Direct Invoice')], 'Sale Flow', help="Is this order tied to a sale order? How will it be delivered and invoiced then?"),
+        'purchase_order_line_id': fields.function(_purchase_order_line_id, type='many2one', relation='purchase.order.line', string='Purchase Order Line'),
+        'purchase_order_id': fields.related('purchase_order_line_id', 'order_id', type='many2one', relation='purchase.order', string='Purchase Order'),
+        'purchase_order_state': fields.related('purchase_order_id', 'state', type='char', size=64, string='Purchase Order State'),
+    }
+
+    _defaults = {
+        'sale_flow': 'normal',
+    }
+
+sale_order_line()
+
+
+class sale_order(osv.osv):
+    _inherit = "sale.order"
+
+    def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None):
+        res = super(sale_order, self)._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, context)
+        res['sale_order_line_id'] = line.id
+        if line.sale_flow in ['direct_delivery', 'direct_invoice_and_delivery']:
+            res['location_id'] = order.partner_id.property_stock_supplier.id
+        return res
+
+    def _create_procurements_direct_mto(self, cr, uid, order, order_lines,
+                                        context=None):
+        """ For make to order lines delivery as dropshipping, do not generate
+        moves but only create a procurement order. """
+        wf_service = netsvc.LocalService("workflow")
+        proc_obj = self.pool.get('procurement.order')
+        for line in order_lines:
+            date_planned = self._get_date_planned(cr, uid, order,
+                                                  line, order.date_order,
+                                                  context=context)
+            vals = self._prepare_order_line_procurement(
+                cr, uid, order, line, False, date_planned, context=context)
+            proc_id = proc_obj.create(cr, uid, vals, context=context)
+            line.write({'procurement_id': proc_id})
+            wf_service.trg_validate(uid, 'procurement.order',
+                                    proc_id, 'button_confirm', cr)
+
+    def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, context=None):
+        res = {}
+        normal_lines = []
+        dropship_lines = []
+        dropship_flows = ('direct_delivery', 'direct_invoice_and_delivery')
+        for line in order_lines:
+            if (line.type == 'make_to_order' and
+                    line.sale_flow in dropship_flows):
+                dropship_lines.append(line)
+            else:
+                normal_lines.append(line)
+        self._create_procurements_direct_mto(cr, uid, order, dropship_lines,
+                                             context=context)
+        res = super(sale_order, self)._create_pickings_and_procurements(
+            cr, uid, order, normal_lines, None, context)
+        return res
+
+sale_order()
+
+class procurement_order(osv.osv):
+    _inherit = 'procurement.order'
+
+    _columns = {
+        'sale_order_line_id': fields.many2one('sale.order.line', 'Sale Order Line'),
+    }
+
+    def create_procurement_purchase_order(self, cr, uid, procurement, po_vals, line_vals, context=None):
+        if procurement.sale_order_line_id:
+            warehouse_id = procurement.sale_order_line_id.order_id.shop_id.warehouse_id
+            sale_flow = procurement.sale_order_line_id.sale_flow
+            purchase_obj = self.pool.get('purchase.order')
+            vals = purchase_obj.sale_flow_change(
+                cr, uid, [], sale_flow,
+                procurement.sale_order_line_id.order_id.id,
+                warehouse_id.id, context=context)
+            po_vals.update(vals.get('value', {}))
+            po_vals.update({'sale_flow': sale_flow, 'sale_id': procurement.sale_order_line_id.order_id.id})
+            line_vals.update({'sale_order_line_id': procurement.sale_order_line_id and procurement.sale_order_line_id.id or False})
+        return super(procurement_order, self).create_procurement_purchase_order(cr, uid, procurement, po_vals, line_vals, context)
+
+procurement_order()

=== added file 'sale_dropshipping/sale_view.xml'
--- sale_dropshipping/sale_view.xml	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/sale_view.xml	2013-11-01 13:29:27 +0000
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<openerp>
+	<data>
+		<!--record model="ir.ui.view" id="view_sale_order_tree_direct_delivery">
+			<field name="name">sale.order.tree.direct_delivery</field>
+			<field name="model">sale.order</field>
+			<field name="inherit_id" ref="sale.view_order_tree" />
+			<field name="type">tree</field>
+			<field name="arch" type="xml">
+				<field name="partner_id" position="after">
+					<field name="has_supplier_direct_delivery" />
+				</field>
+			</field>
+		</record -->
+
+    <record model="ir.ui.view" id="view_order_form_sale_flow">
+        <field name="name">view_order_form_sale_flow</field>
+        <field name="model">sale.order</field>
+        <field name="inherit_id" ref="sale.view_order_form" />
+        <field name="arch" type="xml">
+            <xpath expr="/form/sheet//field[@name='order_line']/tree/field[@name='name']" position="before">
+                <field name="sale_flow" />
+            </xpath>
+            <xpath expr="/form/sheet//field[@name='order_line']/form//label[@for='name']" position="before">
+                <group attrs="{'invisible': [('type', '=', 'make_to_stock')]}" colspan="2" cols="2">
+                    <field name="sale_flow"/>
+                    <field name="purchase_order_line_id"/>
+                    <field name="purchase_order_id" readonly="1"/>
+                    <field name="purchase_order_state" readonly="1"/>
+                </group>
+            </xpath>
+        </field>
+    </record>
+
+
+		<!--record model="ir.ui.view" id="view_sale_order_line_form_direct_delivery2">
+			<field name="name">sale.order.line.form.direct_delivery2</field>
+			<field name="model">sale.order.line</field>
+			<field name="inherit_id" ref="sale.view_order_line_form2" />
+			<field name="type">form</field>
+			<field name="arch" type="xml">
+				<page string="Invoice Lines" position="after">
+					<page string="History">
+						<separator colspan="4" string="Supplier Direct Delivery" />
+						<field name="is_supplier_direct_delivery" />
+						<field name="is_supplier_direct_delivery_advised" />
+						<field name="purchase_order" readonly="1" />
+						<field name="purchase_order_line" readonly="1" />
+						<field name="purchase_order_state" readonly="1" />
+					</page>
+				</page>
+			</field>
+		</record -->
+
+		<!--record model="ir.ui.view" id="view_sale_order_line_tree_direct_delivery">
+			<field name="name">sale.order.line.tree.direct_delivery</field>
+			<field name="model">sale.order</field>
+			<field name="inherit_id" ref="sale.view_order_form" />
+			<field name="type">form</field>
+			<field name="arch" type="xml">
+				<xpath expr="/form/notebook/page/field/tree/field[@name='price_subtotal']" position="after">
+					<field name="is_supplier_direct_delivery" />
+				</xpath>
+			</field>
+		</record -->
+	</data>
+</openerp>

=== added file 'sale_dropshipping/stock_view.xml'
--- sale_dropshipping/stock_view.xml	1970-01-01 00:00:00 +0000
+++ sale_dropshipping/stock_view.xml	2013-11-01 13:29:27 +0000
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+	<data>
+		<record id="ir_ui_view_purchase_to_sale_stock" model="ir.ui.view">
+            <field name="model">stock.picking</field>
+			<field name="inherit_id" ref="stock.view_picking_out_search"/>
+			<field name="name">ir_ui_view_purchase_to_sale_stock</field>
+			<field name="type">search</field>
+            <field name="arch" type="xml">
+                <filter name="done" position="after"> 
+                    <filter icon="terp-accessories-archiver-minus" name="no_direct_delivery" string="Hide Drop Shipping" domain="[('purchase_id','=',False)]" />
+                </filter>
+			</field>
+		</record>
+
+        <record id="stock.action_picking_tree" model="ir.actions.act_window">
+            <field name="context">{'contact_display': 'partner_address', 'search_default_no_direct_delivery': 1}</field>
+        </record>
+
+	</data>
+</openerp>


Follow ups