Your analysis matches ours, regarding the procurement logic.
Regarding the resolution, this is really an important topic for my current customer running 6.1 (hence the OPW I opened). The current situation for the sales team is a total mess of sales marked shipped, some of which are indeed shipped and others which are not, which makes giving information on the phone to the customers inquiring about the status of their orders quite painful (and with Christmas approaching people are indeed getting touchy on that topic, and the Sales period will start shortly after that in January). The invoicing situation is also awkward, as the invoicing policy is to send the invoice when the order is shipped, which results in invoices being sent before the goods are really shipped...
For the record, the Magento connector uses the following SQL query to find out which sale orders have been completely shipped (crossing fingers in hope the formatting will be preserved)
class sale_shop(osv.osv):
_inherit = 'sale.shop'
def _export_shipping_query(self, cr, uid, shop, context=None):
query = """
SELECT stock_picking.id AS picking_id, sale_order.id AS order_id, count(pickings.id) AS picking_number
FROM stock_picking
LEFT JOIN sale_order ON sale_order.id = stock_picking.sale_id
LEFT JOIN stock_picking as pickings ON (sale_order.id = pickings.sale_id AND pickings.type='out' AND pickings.state != 'cancel')
LEFT JOIN ir_model_data ON stock_picking.id = ir_model_data.res_id AND ir_model_data.model = 'stock.picking'
LEFT JOIN delivery_carrier ON delivery_carrier.id = stock_picking.carrier_id
WHERE shop_id = %(shop_id)s
AND ir_model_data.res_id ISNULL
AND stock_picking.state = 'done'
AND stock_picking.type = 'out'
AND NOT stock_picking.do_not_export
AND (NOT delivery_carrier.export_needs_tracking OR stock_picking.carrier_tracking_ref IS NOT NULL)
GROUP BY stock_picking.id, sale_order.id, delivery_carrier.export_needs_tracking, stock_picking.carrier_tracking_ref, stock_picking.backorder_id
ORDER BY sale_order.id ASC, COALESCE(stock_picking.backorder_id, NULL, 0) ASC"""
params = {'shop_id': shop.id}
return query, params
def export_shipping(self, cr, uid, ids, context):
picking_obj = self.pool.get('stock.picking')
for shop in self.browse(cr, uid, ids): cr.execute(*self._export_shipping_query( cr, uid, shop, context=context))
results = cr.dictfetchall()
if not results: _logger.info("There is no shipping to export for the shop '%s' to the external referential", shop.name) continue context['conn_obj'] = shop.referential_id.external_connection()
picking_cr = pooler.get_db(cr.dbname).cursor()
try:
for result in results: picking_id = result['picking_id']
Hello Olivier,
thanks for looking into this.
Your analysis matches ours, regarding the procurement logic.
Regarding the resolution, this is really an important topic for my current customer running 6.1 (hence the OPW I opened). The current situation for the sales team is a total mess of sales marked shipped, some of which are indeed shipped and others which are not, which makes giving information on the phone to the customers inquiring about the status of their orders quite painful (and with Christmas approaching people are indeed getting touchy on that topic, and the Sales period will start shortly after that in January). The invoicing situation is also awkward, as the invoicing policy is to send the invoice when the order is shipped, which results in invoices being sent before the goods are really shipped...
For the record, the Magento connector uses the following SQL query to find out which sale orders have been completely shipped (crossing fingers in hope the formatting will be preserved)
class sale_shop(osv.osv): shipping_ query(self, cr, uid, shop, context=None):
sale_order. id AS order_id,
count( pickings. id) AS picking_number
ON sale_order.id = stock_picking. sale_id
ON (sale_order.id = pickings.sale_id
AND pickings.type='out'
AND pickings.state != 'cancel')
ON stock_picking.id = ir_model_ data.res_ id
AND ir_model_data.model = 'stock.picking'
ON delivery_carrier.id = stock_picking. carrier_ id data.res_ id ISNULL do_not_ export carrier. export_ needs_tracking
OR stock_picking. carrier_ tracking_ ref IS NOT NULL)
sale_ order.id,
delivery_ carrier. export_ needs_tracking,
stock_ picking. carrier_ tracking_ ref,
stock_ picking. backorder_ id
COALESCE( stock_picking. backorder_ id, NULL, 0) ASC"""
_inherit = 'sale.shop'
def _export_
query = """
SELECT stock_picking.id AS picking_id,
FROM stock_picking
LEFT JOIN sale_order
LEFT JOIN stock_picking as pickings
LEFT JOIN ir_model_data
LEFT JOIN delivery_carrier
WHERE shop_id = %(shop_id)s
AND ir_model_
AND stock_picking.state = 'done'
AND stock_picking.type = 'out'
AND NOT stock_picking.
AND (NOT delivery_
GROUP BY stock_picking.id,
ORDER BY sale_order.id ASC,
params = {'shop_id': shop.id}
return query, params
def export_ shipping( self, cr, uid, ids, context): get('stock. picking' )
cr. execute( *self._ export_ shipping_ query(
cr, uid, shop, context=context))
_logger. info("There is no shipping to export for the shop '%s' to the external referential", shop.name)
continue
context[ 'conn_obj' ] = shop.referentia l_id.external_ connection( )
picking_obj = self.pool.
for shop in self.browse(cr, uid, ids):
results = cr.dictfetchall()
if not results:
try:
for result in results:
[...]
http:// bazaar. launchpad. net/~extra- addons- commiter/ e-commerce- addons/ oerp6.1- stable/ view/head: /base_sale_ multichannels/ sale.py# L387
Maybe a similar approach could be used in sales?