diff options
| author | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2014-02-14 16:21:06 +0100 |
|---|---|---|
| committer | Quentin (OpenERP) <qdp-launchpad@openerp.com> | 2014-02-14 16:21:06 +0100 |
| commit | b6eba5ad2d528f09bd2ae400267e10bbc31bbf0d (patch) | |
| tree | a563e9ddff7ff9793defc758d964ef255660a1e9 | |
| parent | 4ad9811a90f365c56ec525e6da47cf75aa114898 (diff) | |
| parent | 77467b306a6fa2c6034b61031cd77aa824a48768 (diff) | |
[FIX] stock: inventory now support the lines with negative theoretical quantities
bzr revid: qdp-launchpad@openerp.com-20140214152106-v8ysmxqajkdy8t70
| -rw-r--r-- | addons/stock/stock.py | 11 | ||||
| -rw-r--r-- | addons/stock/stock_view.xml | 2 |
2 files changed, 3 insertions, 10 deletions
diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 8b64e4ec678..49f03ba6a40 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2193,8 +2193,8 @@ class stock_inventory(osv.osv): move_obj = self.pool.get('stock.move') for inv in self.browse(cr, uid, ids, context=context): for inventory_line in inv.line_ids: - if inventory_line.product_qty < 0: - raise osv.except_osv(_('Warning'),_('You cannot set a negative product quantity in an inventory line')) + if inventory_line.product_qty < 0 and inventory_line.product_qty != inventory_line.th_qty: + raise osv.except_osv(_('Warning'),_('You cannot set a negative product quantity in an inventory line:\n\t%s - qty: %s' % (inventory_line.product_id.name, inventory_line.product_qty))) if not inv.move_ids: self.action_check(cr, uid, [inv.id], context=context) inv.refresh() @@ -2307,13 +2307,6 @@ class stock_inventory(osv.osv): for key, value in product_line.items(): if not value: product_line[key] = False - if product_line['product_qty'] < 0: - summary = _('Product: ') + product_obj.browse(cr, uid, product_line['product_id'], context=context).name + '\n' - summary += _('Location: ') + location_obj.browse(cr, uid, product_line['location_id'], context=context).complete_name + '\n' - summary += (_('Partner: ') + self.pool.get('res.partner').browse(cr, uid, product_line['partner_id'], context=context).name + '\n') if product_line['partner_id'] else '' - summary += (_('Lot: ') + self.pool.get('stock.production.lot').browse(cr, uid, product_line['prod_lot_id'], context=context).name + '\n') if product_line['prod_lot_id'] else '' - summary += (_('Package: ') + self.pool.get('stock.quant.package').browse(cr, uid, product_line['package_id'], context=context).name + '\n') if product_line['package_id'] else '' - raise osv.except_osv(_('Warning'),_('This inventory line has a theoretical negative quantity, please fix it before doing an inventory\n%s' % (summary))) product_line['inventory_id'] = inventory.id product_line['th_qty'] = product_line['product_qty'] if product_line['product_id']: diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index e693c85ea85..2e591db3a11 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -126,7 +126,7 @@ <page string="Inventory Details" > <button name="set_checked_qty" states="confirm" string="⇒ Set quantities to 0" type="object" class="oe_link oe_right" groups="stock.group_stock_user"/> <field name="line_ids" string="Inventory Details" context="{'default_location_id': location_id, 'default_product_id': product_id, 'default_prod_lot_id': lot_id, 'default_package_id': package_id, 'default_partner_id': partner_id}"> - <tree string="Inventory Details" editable="bottom" colors="blue: product_qty != th_qty"> + <tree string="Inventory Details" editable="bottom" colors="blue: product_qty != th_qty; red: th_qty < 0"> <field context="{'location':location_id, 'uom':product_uom_id, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom_id,partner_id,prod_lot_id,package_id)" domain="[('type','=','product')]"/> <field name="product_uom_id" groups="product.group_uom" on_change="on_change_product_id(location_id,product_id,product_uom_id,partner_id,prod_lot_id,package_id)"/> <field domain="[('usage','=','internal')]" name="location_id" groups="stock.group_locations" on_change="on_change_product_id(location_id,product_id,product_uom_id,partner_id,prod_lot_id,package_id)"/> |
