From f4a9afdd31cbd6b16c68b3463e8e9d68202d4750 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 20 May 2015 16:41:01 +0200 Subject: [PATCH] [FIX] stock: add a default group_id if stock.move created from stock.picking The group_id of a picking is related to the group_id of the first stock.move related to it. When a stock.move is added to a picking manually, the group_id is normally not set. This can be an issue in a very specific case: - In Settings / Sales, tick "Allow setting a different address for delivery and invoicing " - Create a SO - Invoicing on delivery - Customer: Agrolait; Delivery address: Thomas Passot - Add a line: ice cream - Confirm the SO - In the DO, add a line , with an expected date higher than the one of the existing move - Save - Mark as todo - Force reservation - transfer - transfer - Create invoice => See that two invoices are created, one for Agrolait, one for Thomas passot ( the DELIVERY address ) opw-639955 --- addons/stock/stock.py | 8 ++++++++ addons/stock/stock_view.xml | 1 + 2 files changed, 9 insertions(+) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 7a9f8b80a68..d560edc18c8 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1824,6 +1824,13 @@ class stock_move(osv.osv): def _default_destination_address(self, cr, uid, context=None): return False + def _default_group_id(self, cr, uid, context=None): + context = context or {} + if context.get('default_picking_id', False): + picking = self.pool.get('stock.picking').browse(cr, uid, context['default_picking_id'], context=context) + return picking.group_id.id + return False + _defaults = { 'location_id': _default_location_source, 'location_dest_id': _default_location_destination, @@ -1838,6 +1845,7 @@ class stock_move(osv.osv): 'procure_method': 'make_to_stock', 'propagate': True, 'partially_available': False, + 'group_id': _default_group_id, } def _check_uom(self, cr, uid, ids, context=None): diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 828a63c53f8..f0e7019fa48 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -1064,6 +1064,7 @@ +