From 35610765951049d98cfc65c9b5d935fddc23459d Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Tue, 17 Sep 2013 16:13:46 +0200 Subject: [PATCH 01/21] [FIX] purchase, fifo_price.yml: negative quants created at the same second don't mess the order anymore since propagated_from_id has a higher priority than id bzr revid: qdp-launchpad@openerp.com-20130917141346-dzyzau2czh0uw0sr --- addons/stock/stock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 176d360569b..8fc8e9b6f0c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -379,8 +379,8 @@ class stock_quant(osv.osv): domain += [('product_id','=',product.id)] + domain res = [] offset = 0 - #id is added at the end of the order to make sure the order is always the same for quants created at the same second - orderby += ', id asc' + #'propagated_from_id' and 'id' are added at the end of the order to make sure the order is always the same for quants created at the same second + orderby += ', propagated_from_id, id' while quantity > 0: quants = self.search(cr, uid, domain, order=orderby, limit=10, offset=offset, context=context) if not quants: From 5b5472508b1b09f9fbee6d56e63f57d91a5e3302 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 18 Sep 2013 15:04:58 +0200 Subject: [PATCH 02/21] [FIX] stock: reconcile negative quants fixed bzr revid: qdp-launchpad@openerp.com-20130918130458-gcjaavfd9z7fzhj9 --- addons/stock/stock.py | 14 ++++++-------- addons/stock_account/stock_account.py | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 8fc8e9b6f0c..883248c1fa0 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -319,7 +319,7 @@ class stock_quant(osv.osv): def _reconcile_single_negative_quant(self, cr, uid, to_solve_quant, quant, quant_neg, qty, context=None): move = self._get_latest_move(cr, uid, to_solve_quant, context=context) - self._quant_split(cr, uid, quant, qty, context=context) + remaining_solving_quant = self._quant_split(cr, uid, quant, qty, context=context) remaining_to_solve_quant = self._quant_split(cr, uid, to_solve_quant, qty, context=context) remaining_neg_quant = self._quant_split(cr, uid, quant_neg, -qty, context=context) #if the reconciliation was not complete, we need to link together the remaining parts @@ -329,7 +329,7 @@ class stock_quant(osv.osv): self.unlink(cr, SUPERUSER_ID, [quant_neg.id, to_solve_quant.id], context=context) #call move_single_quant to ensure recursivity if necessary and do the stock valuation self.move_single_quant(cr, uid, quant, qty, move, context=context) - return remaining_to_solve_quant + return remaining_solving_quant, remaining_to_solve_quant def _quant_reconcile_negative(self, cr, uid, quant, context=None): """ @@ -339,15 +339,16 @@ class stock_quant(osv.osv): """ if quant.location_id.usage != 'internal': return False + solving_quant = quant quants = self.quants_get(cr, uid, quant.location_id, quant.product_id, quant.qty, [('qty', '<', '0')], context=context) for quant_neg, qty in quants: if not quant_neg: continue - to_solve_quant = self.search(cr, uid, [('propagated_from_id', '=', quant_neg.id), ('id', '!=', quant.id)], context=context) + to_solve_quant = self.search(cr, uid, [('propagated_from_id', '=', quant_neg.id), ('id', '!=', solving_quant.id)], context=context) if not to_solve_quant: continue to_solve_quant = self.browse(cr, uid, to_solve_quant[0], context=context) - self._reconcile_single_negative_quant(cr, uid, to_solve_quant, quant, quant_neg, qty, context=context) + solving_quant, dummy = self._reconcile_single_negative_quant(cr, uid, to_solve_quant, solving_quant, quant_neg, qty, context=context) def _price_update(self, cr, uid, quant, newprice, context=None): self.write(cr, uid, [quant.id], {'cost': newprice}, context=context) @@ -379,8 +380,6 @@ class stock_quant(osv.osv): domain += [('product_id','=',product.id)] + domain res = [] offset = 0 - #'propagated_from_id' and 'id' are added at the end of the order to make sure the order is always the same for quants created at the same second - orderby += ', propagated_from_id, id' while quantity > 0: quants = self.search(cr, uid, domain, order=orderby, limit=10, offset=offset, context=context) if not quants: @@ -1533,7 +1532,6 @@ class stock_move(osv.osv): """ context = context or {} quant_obj = self.pool.get("stock.quant") - uom_obj = self.pool.get("product.uom") done = [] for move in self.browse(cr, uid, ids, context=context): if move.state not in ('confirmed', 'waiting'): @@ -1548,7 +1546,7 @@ class stock_move(osv.osv): for q in m2.quant_ids: dp.append(str(q.id)) qty -= q.qty - domain = ['|', ('reservation_id', '=', False), ('reservation_id', '=', move.id)] + domain = ['|', ('reservation_id', '=', False), ('reservation_id', '=', move.id), ('qty', '>', 0)] quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain=domain, prefered_order = dp and ('id not in ('+','.join(dp)+')') or False, restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context) #Will only reserve physical quants, no negative quant_obj.quants_reserve(cr, uid, quants, move, context=context) diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 030171dd782..713d3aeaf49 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -190,13 +190,14 @@ class stock_quant(osv.osv): def _reconcile_single_negative_quant(self, cr, uid, to_solve_quant, quant, quant_neg, qty, context=None): move = self._get_latest_move(cr, uid, to_solve_quant, context=context) quant_neg_position = quant_neg.negative_dest_location_id.usage - remaining_to_solve_quant = super(stock_quant, self)._reconcile_single_negative_quant(cr, uid, to_solve_quant, quant, quant_neg, qty, context=context) + remaining_solving_quant, remaining_to_solve_quant = super(stock_quant, self)._reconcile_single_negative_quant(cr, uid, to_solve_quant, quant, quant_neg, qty, context=context) #update the standard price of the product, only if we would have done it if we'd have had enough stock at first, which means #1) there isn't any negative quant anymore #2) the product cost's method is 'real' #3) we just fixed a negative quant caused by an outgoing shipment if not remaining_to_solve_quant and move.product_id.cost_method == 'real' and quant_neg_position != 'internal': self.pool.get('stock.move')._store_average_cost_price(cr, uid, move, context=context) + return remaining_solving_quant, remaining_to_solve_quant class stock_move(osv.osv): _inherit = "stock.move" From b59fd430fd71fdc3081a846876ff4d465418fef7 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 18 Sep 2013 15:27:18 +0200 Subject: [PATCH 03/21] [FIX] purchase: added a delay of 1 second in fifo_price, as the behavior is not deterministic for quants created the same second bzr revid: qdp-launchpad@openerp.com-20130918132718-oap7zov1z8dqifs3 --- addons/purchase/test/fifo_price.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml index 63b42706191..1b8984c7f89 100644 --- a/addons/purchase/test/fifo_price.yml +++ b/addons/purchase/test/fifo_price.yml @@ -297,6 +297,11 @@ !python {model: stock.picking}: | picking_obj = self.browse(cr, uid, ref("outgoing_fifo_shipment_neg")) picking_obj.do_partial(context=context) +- + The behavior of fifo/lifo is not garantee if the quants are created at the same second, so i just wait one second +- + import time + time.sleep(1) - Let us create another out of 400 kg - @@ -392,4 +397,4 @@ quant_obj = self.pool.get("stock.quant") quants = quant_obj.search(cr, uid, [('product_id','=',ref("product_fifo_negative"))]) print "Quants:", [(x.qty, x.location_id.name, x.in_date, x.cost, x.id) for x in quant_obj.browse(cr, uid, quants)] - assert self.browse(cr, uid, ref("product_fifo_negative")).standard_price == 65.0, "Product price not updated accordingly. %s found instead of 65" %(self.browse(cr, uid, ref("product_fifo_negative")).standard_price,) \ No newline at end of file + assert self.browse(cr, uid, ref("product_fifo_negative")).standard_price == 65.0, "Product price not updated accordingly. %s found instead of 65" %(self.browse(cr, uid, ref("product_fifo_negative")).standard_price,) From b1db4f2f32f6535077eebcfe75be79a782a8adf3 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 18 Sep 2013 15:36:59 +0200 Subject: [PATCH 04/21] [FIX]stock: rename some menu and remove incoming/deliver products menu bzr revid: csn@openerp.com-20130918133659-eyivj1i3iyt2vu0i --- addons/stock/stock_view.xml | 61 ++----------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index c098abd0593..48c8f6ed36d 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -8,15 +8,14 @@ groups="group_stock_manager,group_stock_user" sequence="70"/> - - + - + @@ -1095,19 +1094,6 @@ - - - tree - - - - - - form - - - - stock.incoterms.tree @@ -1166,47 +1152,6 @@ - - - Deliver Products - stock.move - ir.actions.act_window - form - tree,form - - - {'search_default_future': True} - -

- Click to register a product delivery. -

-

- You will find in this list all products you have to deliver to - your customers. You can process the deliveries directly from - this list using the buttons on the right of each line. You can - filter the products to deliver by customer, products or sale - order (using the Origin field). -

-
-
- - - - tree - - - - - - form - - - - - - - - stock.picking.type.filter stock.picking.type @@ -1355,7 +1300,7 @@ - Inventory Moves + All Operations stock.picking.type ir.actions.act_window form From fd45b0b7a739522cd94e0fb0105fc569ee1d986e Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 18 Sep 2013 16:24:57 +0200 Subject: [PATCH 05/21] [FIX] purhcase: stupid error in yml test bzr revid: qdp-launchpad@openerp.com-20130918142457-dwwco06zsrq6t46z --- addons/purchase/test/fifo_price.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/purchase/test/fifo_price.yml b/addons/purchase/test/fifo_price.yml index 1b8984c7f89..c34f55fb03c 100644 --- a/addons/purchase/test/fifo_price.yml +++ b/addons/purchase/test/fifo_price.yml @@ -300,6 +300,7 @@ - The behavior of fifo/lifo is not garantee if the quants are created at the same second, so i just wait one second - + !python {model: stock.picking}: | import time time.sleep(1) - From 2e088579c04980b20d09b5f05e20e0423ed6451c Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 18 Sep 2013 17:10:57 +0200 Subject: [PATCH 06/21] [FIX]stock: rename some of menu item + work on picking type kanban bzr revid: csn@openerp.com-20130918151057-svh4qjr1bfddqa3a --- .../stock/static/src/js/stock_picking_type.js | 4 +- addons/stock/stock_view.xml | 50 ++++++++----------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/addons/stock/static/src/js/stock_picking_type.js b/addons/stock/static/src/js/stock_picking_type.js index 7cfb3e1b77e..49886b8e689 100644 --- a/addons/stock/static/src/js/stock_picking_type.js +++ b/addons/stock/static/src/js/stock_picking_type.js @@ -52,9 +52,9 @@ openerp.stock = function(openerp) { labelFontColor: '#000', label: label, levelColors: [ - "#ff0000", + "#a9d70b", "#f9c802", - "#a9d70b" + "#ff0000" ], }); }, diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 48c8f6ed36d..2665ccd6b19 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -99,7 +99,7 @@ stock.inventory.form stock.inventory -
+