From e086290eb047966f2e05959009ccaab1ef047ac4 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Wed, 22 Jan 2014 14:04:11 +0100 Subject: [PATCH 1/5] [FIX]inventory adjustment: should not show negative qty at start and prevent user should not input negative qty lp bug: https://launchpad.net/bugs/1271244 fixed bzr revid: csn@openerp.com-20140122130411-vab09j3bo5r7ks0f --- addons/stock/stock.py | 5 +++++ addons/stock/stock_view.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 91feb16bca5..66e40e8df5b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2018,6 +2018,7 @@ class stock_inventory(osv.osv): 'date': fields.datetime('Inventory Date', required=True, readonly=True, states={'draft': [('readonly', False)]}, help="Inventory Create Date."), 'date_done': fields.datetime('Date done', help="Inventory Validation Date."), 'line_ids': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=False, states={'done': [('readonly', True)]}, help="Inventory Lines."), + 'line_view_ids': fields.one2many('stock.inventory.line', 'inventory_id', 'Inventories', readonly=False, domain=['|',('th_qty', '>=', 0),('th_qty', '=', False)], states={'done': [('readonly', True)]}, help="Inventory Lines."), 'move_ids': fields.one2many('stock.move', 'inventory_id', 'Created Moves', help="Inventory Moves."), 'state': fields.selection([('draft', 'Draft'), ('cancel', 'Cancelled'), ('confirm', 'In Progress'), ('done', 'Validated')], 'Status', readonly=True, select=True), 'company_id': fields.many2one('res.company', 'Company', required=True, select=True, readonly=True, states={'draft': [('readonly', False)]}), @@ -2073,6 +2074,10 @@ class stock_inventory(osv.osv): context = {} move_obj = self.pool.get('stock.move') for inv in self.browse(cr, uid, ids, context=context): + if inv.line_ids: + for inventory_line in inv.line_ids: + if inventory_line.product_qty < 0 and inventory_line.th_qty >= 0: + raise osv.except_osv(_('Warning'),_('You cannot have a negative product quantity in an inventory line')) if not inv.move_ids: self.action_check(cr, uid, [inv.id], context=context) inv.refresh() diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 7ba08b1a6f1..bd77f6f40c9 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -119,7 +119,7 @@