From 05e9122d25f163f0f5fae161cfefc39c4f4d3c26 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 17 Nov 2016 23:28:10 +0100 Subject: [PATCH 01/66] [MIG] stock_no_negative: Migration to 10.0 --- stock_no_negative/README.rst | 56 +++++++++++++++++++++++ stock_no_negative/__init__.py | 3 ++ stock_no_negative/__manifest__.py | 18 ++++++++ stock_no_negative/i18n/fr.po | 59 +++++++++++++++++++++++++ stock_no_negative/models/__init__.py | 4 ++ stock_no_negative/models/product.py | 27 +++++++++++ stock_no_negative/models/stock_quant.py | 34 ++++++++++++++ stock_no_negative/views/product.xml | 34 ++++++++++++++ 8 files changed, 235 insertions(+) create mode 100644 stock_no_negative/README.rst create mode 100644 stock_no_negative/__init__.py create mode 100644 stock_no_negative/__manifest__.py create mode 100644 stock_no_negative/i18n/fr.po create mode 100644 stock_no_negative/models/__init__.py create mode 100644 stock_no_negative/models/product.py create mode 100644 stock_no_negative/models/stock_quant.py create mode 100644 stock_no_negative/views/product.xml diff --git a/stock_no_negative/README.rst b/stock_no_negative/README.rst new file mode 100644 index 000000000000..2bfcfe470519 --- /dev/null +++ b/stock_no_negative/README.rst @@ -0,0 +1,56 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +======================= +Stock Disallow Negative +======================= + +By default, Odoo allows negative stock. The advantage of negative stock is that, if some stock levels are wrong in the ERP, you will not be blocked when validating the picking for a customer... so you will still be able to ship the products on time (it's an example !). The problem is that, after you forced the stock level to negative, you are supposed to fix the stock level later via an inventory ; but this action is often forgotten by users, so you end up with negative stock levels in your ERP and it can stay like this forever (or at least until the next full inventory). + +If you disallow negative stock in Odoo with this module, you will be blocked when trying to validate a stock operation that will set the stock level of a product as negative. So you will have to fix the wrong stock level of that product without delay, in order to validate the stock operation in Odoo... you can't forget it anymore ! + +Configuration +============= + +By default, the stockable products will not be allowed to have a negative stock. If you want to make some exceptions for some products or some product categories, you can activate the option *Allow Negative Stock* on some products or some products categories. + +Usage +===== + +When you validate a stock operation (a stock move, a picking, a manufacturing order, etc.) that will set the stock level of a stockable product as negative, you will be blocked by an error message. The consumable products can still have a negative stock level. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/154/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Alexis de Lattre + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/stock_no_negative/__init__.py b/stock_no_negative/__init__.py new file mode 100644 index 000000000000..cde864bae21a --- /dev/null +++ b/stock_no_negative/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py new file mode 100644 index 000000000000..f9a5233a807a --- /dev/null +++ b/stock_no_negative/__manifest__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +{ + 'name': 'Stock Disallow Negative', + 'version': '8.0.1.0.2', + 'category': 'Inventory, Logistic, Storage', + 'license': 'AGPL-3', + 'summary': 'Disallow negative stock levels by default', + 'author': 'Akretion,Odoo Community Association (OCA)', + 'website': 'http://www.akretion.com', + 'depends': ['stock'], + 'data': ['views/product.xml'], + 'installable': True, +} diff --git a/stock_no_negative/i18n/fr.po b/stock_no_negative/i18n/fr.po new file mode 100644 index 000000000000..bc81a14fe407 --- /dev/null +++ b/stock_no_negative/i18n/fr.po @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_no_negative +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-10-07 09:43+0000\n" +"PO-Revision-Date: 2015-10-07 09:43+0000\n" +"Last-Translator: Alexis de Lattre \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_no_negative +#: field:product.category,allow_negative_stock:0 +#: field:product.template,allow_negative_stock:0 +msgid "Allow Negative Stock" +msgstr "Autoriser le stock n??gatif" + +#. module: stock_no_negative +#: help:product.category,allow_negative_stock:0 +msgid "Allow negative stock levels for the stockable products attached to this category. The options doesn't apply to products attached to sub-categories of this category." +msgstr "Autorise les niveaux de stock n??gatif pour les articles stockables attach??s ?? cette cat??gorie. Cette option ne s'applique pas aux articles attach??s ?? des sous-cat??gories de cette cat??gorie." + +#. module: stock_no_negative +#: help:product.template,allow_negative_stock:0 +msgid "If this option is not active on this product nor on its product category and that this product is a stockable product, then the validation of the related stock moves will be blocked if the stock level becomes negative with the stock move." +msgstr "Si cette option n'est pas activ??e sur cet article ni sur la cat??gorie ?? laquelle il est rattach?? et que cet article est un produit stockable, alors la validation des mouvements de stock sera bloqu??e si le niveau de stock devient n??gatif avec ce mouvement de stock." + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_category +msgid "Product Category" +msgstr "Cat??gorie d'articles" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_template +msgid "Product Template" +msgstr "Mod??le d'article" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_stock_quant +msgid "Quants" +msgstr "Quants" + +#. module: stock_no_negative +#: view:product.template:stock_no_negative.product_template_form_view +msgid "Stock and Expected Variations" +msgstr "Stock et variations pr??vues" + +#. module: stock_no_negative +#: code:addons/stock_no_negative/stock_no_negative.py:60 +#, python-format +msgid "You cannot valide this stock operation because the stock level of the product '%s' would become negative on the stock location '%s' and negative stock is not allowed for this product." +msgstr "Vous ne pouvez pas valider cette op??ration de stock car le niveau de stock de l'article '%s' deviendrait n??gatif sur l'emplacement de stock '%s' et le stock n??gatif n'est pas autoris?? pour cet article." + diff --git a/stock_no_negative/models/__init__.py b/stock_no_negative/models/__init__.py new file mode 100644 index 000000000000..17fb297ed29f --- /dev/null +++ b/stock_no_negative/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import product +from . import stock_quant diff --git a/stock_no_negative/models/product.py b/stock_no_negative/models/product.py new file mode 100644 index 000000000000..13a6a141ef98 --- /dev/null +++ b/stock_no_negative/models/product.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields + + +class ProductCategory(models.Model): + _inherit = 'product.category' + + allow_negative_stock = fields.Boolean( + string='Allow Negative Stock', + help="Allow negative stock levels for the stockable products " + "attached to this category. The options doesn't apply to products " + "attached to sub-categories of this category.") + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + allow_negative_stock = fields.Boolean( + string='Allow Negative Stock', + help="If this option is not active on this product nor on its " + "product category and that this product is a stockable product, " + "then the validation of the related stock moves will be blocked if " + "the stock level becomes negative with the stock move.") diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py new file mode 100644 index 000000000000..840e3f24f9b4 --- /dev/null +++ b/stock_no_negative/models/stock_quant.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# ?? 2015-2017 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, api, _ +from odoo.exceptions import ValidationError +from odoo.tools import float_compare + + +class StockQuant(models.Model): + _inherit = 'stock.quant' + + @api.multi + @api.constrains('product_id', 'qty') + def check_negative_qty(self): + p = self.env['decimal.precision'].precision_get( + 'Product Unit of Measure') + for quant in self: + if ( + float_compare(quant.qty, 0, precision_digits=p) == -1 and + quant.product_id.type == 'product' and + not quant.product_id.allow_negative_stock and + not quant.product_id.categ_id.allow_negative_stock): + msg_add = '' + if quant.lot_id: + msg_add = _(" lot '%s'") % quant.lot_id.name_get()[0][1] + raise ValidationError(_( + "You cannot validate this stock operation because the " + "stock level of the product '%s'%s would become negative " + "(%s) on the stock location '%s' and negative stock is " + "not allowed for this product.") % ( + quant.product_id.name, msg_add, quant.qty, + quant.location_id.complete_name)) diff --git a/stock_no_negative/views/product.xml b/stock_no_negative/views/product.xml new file mode 100644 index 000000000000..3142608c5ea9 --- /dev/null +++ b/stock_no_negative/views/product.xml @@ -0,0 +1,34 @@ + + + + + + + stock_no_negative.product.template.form + product.template + + + + + + + + + + stock_no_negative.product.category.form + product.category + + + + + + + + + From 367d23eb4a824362520addc2f9059f0ba90b5753 Mon Sep 17 00:00:00 2001 From: darshan-serpent Date: Thu, 5 Jan 2017 16:59:32 +0530 Subject: [PATCH 02/66] [ADD] test cases --- stock_no_negative/README.rst | 2 + stock_no_negative/__init__.py | 3 + stock_no_negative/__manifest__.py | 2 +- stock_no_negative/models/__init__.py | 3 + stock_no_negative/tests/__init__.py | 9 ++ .../tests/test_stock_no_negative.py | 91 +++++++++++++++++++ 6 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 stock_no_negative/tests/__init__.py create mode 100644 stock_no_negative/tests/test_stock_no_negative.py diff --git a/stock_no_negative/README.rst b/stock_no_negative/README.rst index 2bfcfe470519..a12f4658b4a4 100644 --- a/stock_no_negative/README.rst +++ b/stock_no_negative/README.rst @@ -39,6 +39,8 @@ Contributors ------------ * Alexis de Lattre +* Eficent Business and IT Consulting Services S.L. +* Serpent Consulting Services Pvt. Ltd. Maintainer ---------- diff --git a/stock_no_negative/__init__.py b/stock_no_negative/__init__.py index cde864bae21a..39a34783a31b 100644 --- a/stock_no_negative/__init__.py +++ b/stock_no_negative/__init__.py @@ -1,3 +1,6 @@ # -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py index f9a5233a807a..0ba98fe7326d 100644 --- a/stock_no_negative/__manifest__.py +++ b/stock_no_negative/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Stock Disallow Negative', - 'version': '8.0.1.0.2', + 'version': '10.0.1.0.2', 'category': 'Inventory, Logistic, Storage', 'license': 'AGPL-3', 'summary': 'Disallow negative stock levels by default', diff --git a/stock_no_negative/models/__init__.py b/stock_no_negative/models/__init__.py index 17fb297ed29f..bca2f92912bb 100644 --- a/stock_no_negative/models/__init__.py +++ b/stock_no_negative/models/__init__.py @@ -1,4 +1,7 @@ # -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import product from . import stock_quant diff --git a/stock_no_negative/tests/__init__.py b/stock_no_negative/tests/__init__.py new file mode 100644 index 000000000000..80a18a0dc5d9 --- /dev/null +++ b/stock_no_negative/tests/__init__.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# ?? 2016 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# ?? 2016 Serpent Consulting Services Pvt. Ltd. () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_stock_no_negative diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py new file mode 100644 index 000000000000..491c5ed80527 --- /dev/null +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +# ?? 2015-2016 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# ?? 2016 Eficent Business and IT Consulting Services S.L. +# (http://www.eficent.com) +# ?? 2016 Serpent Consulting Services Pvt. Ltd. () +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + + +from odoo.tests.common import TransactionCase +from odoo.exceptions import ValidationError + + +class TestStockNoNegative(TransactionCase): + + def setUp(self): + super(TestStockNoNegative, self).setUp() + self.product_model = self.env['product.product'] + self.product_ctg_model = self.env['product.category'] + self.picking_type_id = self.env.ref('stock.picking_type_out') + self.location_id = self.env.ref('stock.stock_location_stock') + self.location_dest_id = self.env.ref('stock.stock_location_customers') + # Create product category + self.product_ctg = self._create_product_category() + # Create a Product + self.product = self._create_product('test_product1') + self._create_picking() + + def _create_product_category(self): + product_ctg = self.product_ctg_model.create({ + 'name': 'test_product_ctg', + }) + return product_ctg + + def _create_product(self, name): + product = self.product_model.create({ + 'name': name, + 'categ_id': self.product_ctg.id, + 'type': 'product', + }) + return product + + def _create_picking(self): + self.stock_picking = self.env['stock.picking'].create({ + 'picking_type_id': self.picking_type_id.id, + 'move_type': 'direct', + 'location_id': self.location_id.id, + 'location_dest_id': self.location_dest_id.id + }) + + self.stock_move = self.env['stock.move'].create({ + 'name': 'Test Move', + 'product_id': self.product.id, + 'product_uom_qty': 100.0, + 'product_uom': self.product.uom_id.id, + 'picking_id': self.stock_picking.id, + 'state': 'draft', + 'location_id': self.location_id.id, + 'location_dest_id': self.location_dest_id.id + }) + + def test_check_constrains(self): + """Assert that constraint is raised when user + tries to validate the stock operation which would + make the stock level of the product negative """ + self.stock_picking.action_confirm() + self.stock_picking.action_assign() + self.stock_picking.force_assign() + self.stock_picking.do_new_transfer() + self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ + create({'pick_id': self.stock_picking.id}) + with self.assertRaises(ValidationError): + self.stock_immediate_transfer.process() + + def test_true_allow_negative_stock(self): + """Assert that negative stock levels are allowed when + the allow_negative_stock is set active in the product""" + self.product.product_tmpl_id.write({'allow_negative_stock': True}) + self.stock_picking.action_confirm() + self.stock_picking.action_assign() + self.stock_picking.force_assign() + self.stock_picking.do_new_transfer() + self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ + create({'pick_id': self.stock_picking.id}) + self.stock_immediate_transfer.process() + quant = self.env['stock.quant'].search([('product_id', '=', + self.product.id), + ('location_id', '=', + self.location_id.id)]) + self.assertEqual(quant.qty, + -self.stock_move.product_uom_qty) From b01d79490690a673d6b336592d7095c471c97886 Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 30 Aug 2017 17:49:16 +0200 Subject: [PATCH 03/66] [IMP] stock_no_negative: Behave correctly on other tests --- stock_no_negative/__manifest__.py | 2 +- stock_no_negative/models/stock_quant.py | 11 ++++++++--- stock_no_negative/tests/test_stock_no_negative.py | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py index 0ba98fe7326d..c66dc114d50c 100644 --- a/stock_no_negative/__manifest__.py +++ b/stock_no_negative/__manifest__.py @@ -6,7 +6,7 @@ { 'name': 'Stock Disallow Negative', - 'version': '10.0.1.0.2', + 'version': '10.0.1.0.0', 'category': 'Inventory, Logistic, Storage', 'license': 'AGPL-3', 'summary': 'Disallow negative stock levels by default', diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index 840e3f24f9b4..94e795b9ec47 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -5,7 +5,7 @@ from odoo import models, api, _ from odoo.exceptions import ValidationError -from odoo.tools import float_compare +from odoo.tools import config, float_compare class StockQuant(models.Model): @@ -16,9 +16,14 @@ class StockQuant(models.Model): def check_negative_qty(self): p = self.env['decimal.precision'].precision_get( 'Product Unit of Measure') + check_negative_qty = ( + config['test_enable'] and self.env.context.get( + 'test_stock_no_negative')) or ( + 'test_enable' not in config.options) + if not check_negative_qty: + return for quant in self: - if ( - float_compare(quant.qty, 0, precision_digits=p) == -1 and + if (float_compare(quant.qty, 0, precision_digits=p) == -1 and quant.product_id.type == 'product' and not quant.product_id.allow_negative_stock and not quant.product_id.categ_id.allow_negative_stock): diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index 491c5ed80527..9a1b0d0fdfba 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -70,7 +70,8 @@ def test_check_constrains(self): self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ create({'pick_id': self.stock_picking.id}) with self.assertRaises(ValidationError): - self.stock_immediate_transfer.process() + self.stock_immediate_transfer.with_context( + test_stock_no_negative=True).process() def test_true_allow_negative_stock(self): """Assert that negative stock levels are allowed when @@ -82,7 +83,8 @@ def test_true_allow_negative_stock(self): self.stock_picking.do_new_transfer() self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ create({'pick_id': self.stock_picking.id}) - self.stock_immediate_transfer.process() + self.stock_immediate_transfer.with_context( + test_stock_no_negative=True).process() quant = self.env['stock.quant'].search([('product_id', '=', self.product.id), ('location_id', '=', From cc73ffa271fbb686ab46e7703d9fdcf53ded35b2 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Tue, 19 Dec 2017 09:58:29 +0100 Subject: [PATCH 04/66] [MIG] stock_no_negative: Migration to 11.0 --- stock_no_negative/models/stock_quant.py | 6 ++--- .../tests/test_stock_no_negative.py | 24 +++++++++---------- stock_no_negative/views/product.xml | 3 +-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index 94e795b9ec47..a0510f1b292d 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -12,7 +12,7 @@ class StockQuant(models.Model): _inherit = 'stock.quant' @api.multi - @api.constrains('product_id', 'qty') + @api.constrains('product_id', 'quantity') def check_negative_qty(self): p = self.env['decimal.precision'].precision_get( 'Product Unit of Measure') @@ -23,7 +23,7 @@ def check_negative_qty(self): if not check_negative_qty: return for quant in self: - if (float_compare(quant.qty, 0, precision_digits=p) == -1 and + if (float_compare(quant.quantity, 0, precision_digits=p) == -1 and quant.product_id.type == 'product' and not quant.product_id.allow_negative_stock and not quant.product_id.categ_id.allow_negative_stock): @@ -35,5 +35,5 @@ def check_negative_qty(self): "stock level of the product '%s'%s would become negative " "(%s) on the stock location '%s' and negative stock is " "not allowed for this product.") % ( - quant.product_id.name, msg_add, quant.qty, + quant.product_id.name, msg_add, quant.quantity, quant.location_id.complete_name)) diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index 9a1b0d0fdfba..812ee0c7d763 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -66,9 +66,10 @@ def test_check_constrains(self): self.stock_picking.action_confirm() self.stock_picking.action_assign() self.stock_picking.force_assign() - self.stock_picking.do_new_transfer() - self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ - create({'pick_id': self.stock_picking.id}) + res = self.stock_picking.button_validate() + self.stock_immediate_transfer = self.env[ + 'stock.immediate.transfer' + ].browse(res['res_id']) with self.assertRaises(ValidationError): self.stock_immediate_transfer.with_context( test_stock_no_negative=True).process() @@ -80,14 +81,13 @@ def test_true_allow_negative_stock(self): self.stock_picking.action_confirm() self.stock_picking.action_assign() self.stock_picking.force_assign() - self.stock_picking.do_new_transfer() - self.stock_immediate_transfer = self.env['stock.immediate.transfer'].\ - create({'pick_id': self.stock_picking.id}) + res = self.stock_picking.button_validate() + self.stock_immediate_transfer = self.env[ + 'stock.immediate.transfer' + ].browse(res['res_id']) self.stock_immediate_transfer.with_context( test_stock_no_negative=True).process() - quant = self.env['stock.quant'].search([('product_id', '=', - self.product.id), - ('location_id', '=', - self.location_id.id)]) - self.assertEqual(quant.qty, - -self.stock_move.product_uom_qty) + quant = self.env['stock.quant'].search([ + ('product_id', '=', self.product.id), + ('location_id', '=', self.location_id.id)]) + self.assertEqual(quant.quantity, -self.stock_move.product_uom_qty) diff --git a/stock_no_negative/views/product.xml b/stock_no_negative/views/product.xml index 3142608c5ea9..252fbdf98371 100644 --- a/stock_no_negative/views/product.xml +++ b/stock_no_negative/views/product.xml @@ -25,8 +25,7 @@ - + From 204c93606f739037fbedfc636ca4342ba45af593 Mon Sep 17 00:00:00 2001 From: rgarnau Date: Wed, 20 Dec 2017 09:32:15 +0100 Subject: [PATCH 05/66] minor fixes --- stock_no_negative/README.rst | 4 ++-- stock_no_negative/__init__.py | 1 - stock_no_negative/__manifest__.py | 3 +-- stock_no_negative/models/__init__.py | 1 - stock_no_negative/models/product.py | 1 - stock_no_negative/models/stock_quant.py | 5 ++--- stock_no_negative/tests/__init__.py | 1 - stock_no_negative/tests/test_stock_no_negative.py | 1 - 8 files changed, 5 insertions(+), 12 deletions(-) diff --git a/stock_no_negative/README.rst b/stock_no_negative/README.rst index a12f4658b4a4..d11f95e9919a 100644 --- a/stock_no_negative/README.rst +++ b/stock_no_negative/README.rst @@ -1,5 +1,5 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 ======================= @@ -22,7 +22,7 @@ When you validate a stock operation (a stock move, a picking, a manufacturing or .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/154/10.0 + :target: https://runbot.odoo-community.org/runbot/154/11.0 Bug Tracker =========== diff --git a/stock_no_negative/__init__.py b/stock_no_negative/__init__.py index 39a34783a31b..31c468823740 100644 --- a/stock_no_negative/__init__.py +++ b/stock_no_negative/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py index c66dc114d50c..eccd2d429b94 100644 --- a/stock_no_negative/__manifest__.py +++ b/stock_no_negative/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -6,7 +5,7 @@ { 'name': 'Stock Disallow Negative', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Inventory, Logistic, Storage', 'license': 'AGPL-3', 'summary': 'Disallow negative stock levels by default', diff --git a/stock_no_negative/models/__init__.py b/stock_no_negative/models/__init__.py index bca2f92912bb..6b3a97ecd313 100644 --- a/stock_no_negative/models/__init__.py +++ b/stock_no_negative/models/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/stock_no_negative/models/product.py b/stock_no_negative/models/product.py index 13a6a141ef98..41ba5bfdb839 100644 --- a/stock_no_negative/models/product.py +++ b/stock_no_negative/models/product.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index a0510f1b292d..f1aa4050a7b6 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2017 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -18,8 +17,8 @@ def check_negative_qty(self): 'Product Unit of Measure') check_negative_qty = ( config['test_enable'] and self.env.context.get( - 'test_stock_no_negative')) or ( - 'test_enable' not in config.options) + 'test_stock_no_negative')) or not config.options.get( + 'test_enable') if not check_negative_qty: return for quant in self: diff --git a/stock_no_negative/tests/__init__.py b/stock_no_negative/tests/__init__.py index 80a18a0dc5d9..629aec36e556 100644 --- a/stock_no_negative/tests/__init__.py +++ b/stock_no_negative/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # ?? 2016 Eficent Business and IT Consulting Services S.L. diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index 812ee0c7d763..d3fced21bd4e 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # ?? 2015-2016 Akretion (http://www.akretion.com) # @author Alexis de Lattre # ?? 2016 Eficent Business and IT Consulting Services S.L. From 4553e9377dc7c1b35e4a6ca28af1dc42851ed953 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 30 Dec 2017 15:24:19 +0100 Subject: [PATCH 06/66] OCA Transbot updated translations from Transifex --- stock_no_negative/i18n/fr.po | 76 ++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/stock_no_negative/i18n/fr.po b/stock_no_negative/i18n/fr.po index bc81a14fe407..6955eadcae6c 100644 --- a/stock_no_negative/i18n/fr.po +++ b/stock_no_negative/i18n/fr.po @@ -1,35 +1,61 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * stock_no_negative -# +# * stock_no_negative +# +# Translators: +# OCA Transbot , 2017 +# guillaume bauer , 2017 msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-10-07 09:43+0000\n" -"PO-Revision-Date: 2015-10-07 09:43+0000\n" -"Last-Translator: Alexis de Lattre \n" -"Language-Team: \n" +"POT-Creation-Date: 2017-12-23 03:52+0000\n" +"PO-Revision-Date: 2017-12-23 03:52+0000\n" +"Last-Translator: guillaume bauer , 2017\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Plural-Forms: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: stock_no_negative -#: field:product.category,allow_negative_stock:0 -#: field:product.template,allow_negative_stock:0 +#: code:addons/stock_no_negative/models/stock_quant.py:31 +#, python-format +msgid " lot '%s'" +msgstr "lot%s" + +#. module: stock_no_negative +#: model:ir.model.fields,field_description:stock_no_negative.field_product_category_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_template_allow_negative_stock msgid "Allow Negative Stock" msgstr "Autoriser le stock n??gatif" #. module: stock_no_negative -#: help:product.category,allow_negative_stock:0 -msgid "Allow negative stock levels for the stockable products attached to this category. The options doesn't apply to products attached to sub-categories of this category." -msgstr "Autorise les niveaux de stock n??gatif pour les articles stockables attach??s ?? cette cat??gorie. Cette option ne s'applique pas aux articles attach??s ?? des sous-cat??gories de cette cat??gorie." +#: model:ir.model.fields,help:stock_no_negative.field_product_category_allow_negative_stock +msgid "" +"Allow negative stock levels for the stockable products attached to this " +"category. The options doesn't apply to products attached to sub-categories " +"of this category." +msgstr "" +"Autorise les niveaux de stock n??gatif pour les articles stockables attach??s " +"?? cette cat??gorie. Cette option ne s'applique pas aux articles attach??s ?? " +"des sous-cat??gories de cette cat??gorie." #. module: stock_no_negative -#: help:product.template,allow_negative_stock:0 -msgid "If this option is not active on this product nor on its product category and that this product is a stockable product, then the validation of the related stock moves will be blocked if the stock level becomes negative with the stock move." -msgstr "Si cette option n'est pas activ??e sur cet article ni sur la cat??gorie ?? laquelle il est rattach?? et que cet article est un produit stockable, alors la validation des mouvements de stock sera bloqu??e si le niveau de stock devient n??gatif avec ce mouvement de stock." +#: model:ir.model.fields,help:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,help:stock_no_negative.field_product_template_allow_negative_stock +msgid "" +"If this option is not active on this product nor on its product category and" +" that this product is a stockable product, then the validation of the " +"related stock moves will be blocked if the stock level becomes negative with" +" the stock move." +msgstr "" +"Si cette option n'est pas activ??e sur cet article ni sur la cat??gorie ?? " +"laquelle il est rattach?? et que cet article est un produit stockable, alors " +"la validation des mouvements de stock sera bloqu??e si le niveau de stock " +"devient n??gatif avec ce mouvement de stock." #. module: stock_no_negative #: model:ir.model,name:stock_no_negative.model_product_category @@ -47,13 +73,13 @@ msgid "Quants" msgstr "Quants" #. module: stock_no_negative -#: view:product.template:stock_no_negative.product_template_form_view -msgid "Stock and Expected Variations" -msgstr "Stock et variations pr??vues" - -#. module: stock_no_negative -#: code:addons/stock_no_negative/stock_no_negative.py:60 +#: code:addons/stock_no_negative/models/stock_quant.py:32 #, python-format -msgid "You cannot valide this stock operation because the stock level of the product '%s' would become negative on the stock location '%s' and negative stock is not allowed for this product." -msgstr "Vous ne pouvez pas valider cette op??ration de stock car le niveau de stock de l'article '%s' deviendrait n??gatif sur l'emplacement de stock '%s' et le stock n??gatif n'est pas autoris?? pour cet article." - +msgid "" +"You cannot validate this stock operation because the stock level of the " +"product '%s'%s would become negative (%s) on the stock location '%s' and " +"negative stock is not allowed for this product." +msgstr "" +"Impossible de valider cette op??ration car le niveau de stock de ce produit " +"%s'%s deviendrait n??gative(%s) dans l'emplacement du stock '%s'. Un stock " +"n??gatif n'est pas permis pour ce produit." From 93dba287290aef8fb6138d0566fc0d06266979c3 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 27 Dec 2017 14:24:54 +0100 Subject: [PATCH 07/66] [FIX] Issue #391 --- stock_no_negative/__manifest__.py | 2 +- stock_no_negative/models/stock_quant.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py index eccd2d429b94..770bf6ca204c 100644 --- a/stock_no_negative/__manifest__.py +++ b/stock_no_negative/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Stock Disallow Negative', - 'version': '11.0.1.0.0', + 'version': '11.0.1.0.1', 'category': 'Inventory, Logistic, Storage', 'license': 'AGPL-3', 'summary': 'Disallow negative stock levels by default', diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index f1aa4050a7b6..1cfb59628a6f 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -22,10 +22,13 @@ def check_negative_qty(self): if not check_negative_qty: return for quant in self: - if (float_compare(quant.quantity, 0, precision_digits=p) == -1 and - quant.product_id.type == 'product' and - not quant.product_id.allow_negative_stock and - not quant.product_id.categ_id.allow_negative_stock): + if ( + float_compare(quant.quantity, 0, precision_digits=p) == -1 and + quant.product_id.type == 'product' and + not quant.product_id.allow_negative_stock and + not quant.product_id.categ_id.allow_negative_stock and + quant.location_id.usage in ['internal', 'transit'] + ): msg_add = '' if quant.lot_id: msg_add = _(" lot '%s'") % quant.lot_id.name_get()[0][1] From 109a2aee6d0e504e34c01fb0650bb9db5385a4e1 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 28 Feb 2018 01:46:56 +0100 Subject: [PATCH 08/66] [FIX] stock_no_negative: Incorrect tests --- stock_no_negative/README.rst | 2 + stock_no_negative/models/stock_quant.py | 7 ++-- .../tests/test_stock_no_negative.py | 40 +++++++------------ 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/stock_no_negative/README.rst b/stock_no_negative/README.rst index d11f95e9919a..02135e815bdd 100644 --- a/stock_no_negative/README.rst +++ b/stock_no_negative/README.rst @@ -41,6 +41,8 @@ Contributors * Alexis de Lattre * Eficent Business and IT Consulting Services S.L. * Serpent Consulting Services Pvt. Ltd. +* Tecnativa + * Pedro M. Baeza Maintainer ---------- diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index 1cfb59628a6f..b2340c9c3de9 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -16,9 +16,10 @@ def check_negative_qty(self): p = self.env['decimal.precision'].precision_get( 'Product Unit of Measure') check_negative_qty = ( - config['test_enable'] and self.env.context.get( - 'test_stock_no_negative')) or not config.options.get( - 'test_enable') + (config['test_enable'] and + self.env.context.get('test_stock_no_negative')) or + not config['test_enable'] + ) if not check_negative_qty: return for quant in self: diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index d3fced21bd4e..daaf9c530d37 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -1,8 +1,7 @@ -# ?? 2015-2016 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# ?? 2016 Eficent Business and IT Consulting Services S.L. -# (http://www.eficent.com) -# ?? 2016 Serpent Consulting Services Pvt. Ltd. () +# Copyright 2015-2016 Akretion (http://www.akretion.com) - Alexis de Lattre +# Copyright 2016 Eficent (http://www.eficent.com) +# Copyright 2016 Serpent Consulting Services () +# Copyright 2018 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -28,6 +27,7 @@ def setUp(self): def _create_product_category(self): product_ctg = self.product_ctg_model.create({ 'name': 'test_product_ctg', + 'allow_negative_stock': False, }) return product_ctg @@ -36,11 +36,14 @@ def _create_product(self, name): 'name': name, 'categ_id': self.product_ctg.id, 'type': 'product', + 'allow_negative_stock': False, }) return product def _create_picking(self): - self.stock_picking = self.env['stock.picking'].create({ + self.stock_picking = self.env['stock.picking'].with_context( + test_stock_no_negative=True, + ).create({ 'picking_type_id': self.picking_type_id.id, 'move_type': 'direct', 'location_id': self.location_id.id, @@ -55,7 +58,8 @@ def _create_picking(self): 'picking_id': self.stock_picking.id, 'state': 'draft', 'location_id': self.location_id.id, - 'location_dest_id': self.location_dest_id.id + 'location_dest_id': self.location_dest_id.id, + 'quantity_done': 100.0, }) def test_check_constrains(self): @@ -63,30 +67,16 @@ def test_check_constrains(self): tries to validate the stock operation which would make the stock level of the product negative """ self.stock_picking.action_confirm() - self.stock_picking.action_assign() - self.stock_picking.force_assign() - res = self.stock_picking.button_validate() - self.stock_immediate_transfer = self.env[ - 'stock.immediate.transfer' - ].browse(res['res_id']) with self.assertRaises(ValidationError): - self.stock_immediate_transfer.with_context( - test_stock_no_negative=True).process() + self.stock_picking.button_validate() def test_true_allow_negative_stock(self): """Assert that negative stock levels are allowed when the allow_negative_stock is set active in the product""" - self.product.product_tmpl_id.write({'allow_negative_stock': True}) + self.product.allow_negative_stock = True self.stock_picking.action_confirm() - self.stock_picking.action_assign() - self.stock_picking.force_assign() - res = self.stock_picking.button_validate() - self.stock_immediate_transfer = self.env[ - 'stock.immediate.transfer' - ].browse(res['res_id']) - self.stock_immediate_transfer.with_context( - test_stock_no_negative=True).process() + self.stock_picking.button_validate() quant = self.env['stock.quant'].search([ ('product_id', '=', self.product.id), ('location_id', '=', self.location_id.id)]) - self.assertEqual(quant.quantity, -self.stock_move.product_uom_qty) + self.assertEqual(quant.quantity, -100) From f4e52747c9a6507406871ec8abc7a75bb908e9e2 Mon Sep 17 00:00:00 2001 From: OCA Transbot Date: Sat, 3 Mar 2018 16:34:28 +0100 Subject: [PATCH 09/66] OCA Transbot updated translations from Transifex --- stock_no_negative/i18n/fr.po | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stock_no_negative/i18n/fr.po b/stock_no_negative/i18n/fr.po index 6955eadcae6c..6d081f9da3c2 100644 --- a/stock_no_negative/i18n/fr.po +++ b/stock_no_negative/i18n/fr.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-12-23 03:52+0000\n" -"PO-Revision-Date: 2017-12-23 03:52+0000\n" +"POT-Creation-Date: 2018-02-28 08:51+0000\n" +"PO-Revision-Date: 2018-02-28 08:51+0000\n" "Last-Translator: guillaume bauer , 2017\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" "MIME-Version: 1.0\n" @@ -20,7 +20,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: stock_no_negative -#: code:addons/stock_no_negative/models/stock_quant.py:31 +#: code:addons/stock_no_negative/models/stock_quant.py:35 #, python-format msgid " lot '%s'" msgstr "lot%s" @@ -73,7 +73,7 @@ msgid "Quants" msgstr "Quants" #. module: stock_no_negative -#: code:addons/stock_no_negative/models/stock_quant.py:32 +#: code:addons/stock_no_negative/models/stock_quant.py:36 #, python-format msgid "" "You cannot validate this stock operation because the stock level of the " From 6a02be4a3b1f9c6b5c6bf406e581f17d02d24f8c Mon Sep 17 00:00:00 2001 From: oca-travis Date: Sat, 23 Jun 2018 23:25:20 +0000 Subject: [PATCH 10/66] [UPD] Update stock_no_negative.pot --- stock_no_negative/i18n/fr.po | 12 ++-- stock_no_negative/i18n/stock_no_negative.pot | 60 ++++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 stock_no_negative/i18n/stock_no_negative.pot diff --git a/stock_no_negative/i18n/fr.po b/stock_no_negative/i18n/fr.po index 6d081f9da3c2..212db9160622 100644 --- a/stock_no_negative/i18n/fr.po +++ b/stock_no_negative/i18n/fr.po @@ -1,7 +1,7 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: # * stock_no_negative -# +# # Translators: # OCA Transbot , 2017 # guillaume bauer , 2017 @@ -13,10 +13,10 @@ msgstr "" "PO-Revision-Date: 2018-02-28 08:51+0000\n" "Last-Translator: guillaume bauer , 2017\n" "Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" -"Language: fr\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: stock_no_negative @@ -47,10 +47,10 @@ msgstr "" #: model:ir.model.fields,help:stock_no_negative.field_product_product_allow_negative_stock #: model:ir.model.fields,help:stock_no_negative.field_product_template_allow_negative_stock msgid "" -"If this option is not active on this product nor on its product category and" -" that this product is a stockable product, then the validation of the " -"related stock moves will be blocked if the stock level becomes negative with" -" the stock move." +"If this option is not active on this product nor on its product category and " +"that this product is a stockable product, then the validation of the related " +"stock moves will be blocked if the stock level becomes negative with the " +"stock move." msgstr "" "Si cette option n'est pas activ??e sur cet article ni sur la cat??gorie ?? " "laquelle il est rattach?? et que cet article est un produit stockable, alors " diff --git a/stock_no_negative/i18n/stock_no_negative.pot b/stock_no_negative/i18n/stock_no_negative.pot new file mode 100644 index 000000000000..ce52727d8431 --- /dev/null +++ b/stock_no_negative/i18n/stock_no_negative.pot @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_no_negative +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_no_negative +#: code:addons/stock_no_negative/models/stock_quant.py:35 +#, python-format +msgid " lot '%s'" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,field_description:stock_no_negative.field_product_category_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_template_allow_negative_stock +msgid "Allow Negative Stock" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,help:stock_no_negative.field_product_category_allow_negative_stock +msgid "Allow negative stock levels for the stockable products attached to this category. The options doesn't apply to products attached to sub-categories of this category." +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,help:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,help:stock_no_negative.field_product_template_allow_negative_stock +msgid "If this option is not active on this product nor on its product category and that this product is a stockable product, then the validation of the related stock moves will be blocked if the stock level becomes negative with the stock move." +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_category +msgid "Product Category" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_template +msgid "Product Template" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_no_negative +#: code:addons/stock_no_negative/models/stock_quant.py:36 +#, python-format +msgid "You cannot validate this stock operation because the stock level of the product '%s'%s would become negative (%s) on the stock location '%s' and negative stock is not allowed for this product." +msgstr "" + From d0a8bd8e5f726e8fb3652afbe4d1a901f08fe414 Mon Sep 17 00:00:00 2001 From: Osoul Date: Fri, 29 Jun 2018 04:22:29 +0000 Subject: [PATCH 11/66] Added translation using Weblate (Arabic) --- stock_no_negative/i18n/ar.po | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 stock_no_negative/i18n/ar.po diff --git a/stock_no_negative/i18n/ar.po b/stock_no_negative/i18n/ar.po new file mode 100644 index 000000000000..237ed946de6c --- /dev/null +++ b/stock_no_negative/i18n/ar.po @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_no_negative +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" + +#. module: stock_no_negative +#: code:addons/stock_no_negative/models/stock_quant.py:35 +#, python-format +msgid " lot '%s'" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,field_description:stock_no_negative.field_product_category_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,field_description:stock_no_negative.field_product_template_allow_negative_stock +msgid "Allow Negative Stock" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,help:stock_no_negative.field_product_category_allow_negative_stock +msgid "Allow negative stock levels for the stockable products attached to this category. The options doesn't apply to products attached to sub-categories of this category." +msgstr "" + +#. module: stock_no_negative +#: model:ir.model.fields,help:stock_no_negative.field_product_product_allow_negative_stock +#: model:ir.model.fields,help:stock_no_negative.field_product_template_allow_negative_stock +msgid "If this option is not active on this product nor on its product category and that this product is a stockable product, then the validation of the related stock moves will be blocked if the stock level becomes negative with the stock move." +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_category +msgid "Product Category" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_product_template +msgid "Product Template" +msgstr "" + +#. module: stock_no_negative +#: model:ir.model,name:stock_no_negative.model_stock_quant +msgid "Quants" +msgstr "" + +#. module: stock_no_negative +#: code:addons/stock_no_negative/models/stock_quant.py:36 +#, python-format +msgid "You cannot validate this stock operation because the stock level of the product '%s'%s would become negative (%s) on the stock location '%s' and negative stock is not allowed for this product." +msgstr "" From a775f5bb99dcebba0ef545c965a73840b13cca5a Mon Sep 17 00:00:00 2001 From: Osoul Date: Fri, 29 Jun 2018 04:22:55 +0000 Subject: [PATCH 12/66] Translated using Weblate (Arabic) Currently translated at 50.0% (4 of 8 strings) Translation: stock-logistics-workflow-11.0/stock-logistics-workflow-11.0-stock_no_negative Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-workflow-11-0/stock-logistics-workflow-11-0-stock_no_negative/ar/ --- stock_no_negative/i18n/ar.po | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/stock_no_negative/i18n/ar.po b/stock_no_negative/i18n/ar.po index 237ed946de6c..1c28018dfe98 100644 --- a/stock_no_negative/i18n/ar.po +++ b/stock_no_negative/i18n/ar.po @@ -6,7 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2018-06-30 05:01+0000\n" +"Last-Translator: Osoul \n" "Language-Team: none\n" "Language: ar\n" "MIME-Version: 1.0\n" @@ -14,6 +15,7 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " "&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n" +"X-Generator: Weblate 3.0.1\n" #. module: stock_no_negative #: code:addons/stock_no_negative/models/stock_quant.py:35 @@ -26,7 +28,7 @@ msgstr "" #: model:ir.model.fields,field_description:stock_no_negative.field_product_product_allow_negative_stock #: model:ir.model.fields,field_description:stock_no_negative.field_product_template_allow_negative_stock msgid "Allow Negative Stock" -msgstr "" +msgstr "???????????? ???????????? ??????????" #. module: stock_no_negative #: model:ir.model.fields,help:stock_no_negative.field_product_category_allow_negative_stock @@ -42,12 +44,12 @@ msgstr "" #. module: stock_no_negative #: model:ir.model,name:stock_no_negative.model_product_category msgid "Product Category" -msgstr "" +msgstr "?????? ????????????" #. module: stock_no_negative #: model:ir.model,name:stock_no_negative.model_product_template msgid "Product Template" -msgstr "" +msgstr "???????? ????????????" #. module: stock_no_negative #: model:ir.model,name:stock_no_negative.model_stock_quant @@ -59,3 +61,5 @@ msgstr "" #, python-format msgid "You cannot validate this stock operation because the stock level of the product '%s'%s would become negative (%s) on the stock location '%s' and negative stock is not allowed for this product." msgstr "" +"???? ?????????? ?????????? ???????? ?????????????? ?????? ???????? ???????????? '%s'%s ?????????? ?????????? (%s) ???? " +"???????????? '%s' ???????? ???????????? ???? ???????? ???? ???????? ????????????." From 760a7235502ba4fc34abf41831af93661c6eecb3 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 10 Oct 2018 18:05:56 +0200 Subject: [PATCH 13/66] [IMP] stock_no_negative: Avoid problems on integration tests For example, when you install *delivery* along with this one --- stock_no_negative/tests/test_stock_no_negative.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index daaf9c530d37..1e06a1da7656 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -10,6 +10,8 @@ class TestStockNoNegative(TransactionCase): + at_install = False + post_install = True def setUp(self): super(TestStockNoNegative, self).setUp() From 2f2cae3c1c7c45c6f6aa38b6e30f7e91ad10da37 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Thu, 13 Dec 2018 18:08:43 +0100 Subject: [PATCH 14/66] [stock_no_negative][IMP] Add the ability to allow negative stock for individual stock locations. --- stock_no_negative/README.rst | 118 ++++- stock_no_negative/__manifest__.py | 7 +- stock_no_negative/models/__init__.py | 1 + stock_no_negative/models/stock_location.py | 14 + stock_no_negative/models/stock_quant.py | 12 +- stock_no_negative/readme/CONFIGURE.rst | 22 + stock_no_negative/readme/CONTRIBUTORS.rst | 6 + stock_no_negative/readme/DESCRIPTION.rst | 15 + stock_no_negative/readme/HISTORY.rst | 4 + stock_no_negative/readme/USAGE.rst | 4 + .../static/description/index.html | 460 ++++++++++++++++++ .../tests/test_stock_no_negative.py | 14 +- ...{product.xml => product_product_views.xml} | 0 .../views/stock_location_views.xml | 22 + 14 files changed, 670 insertions(+), 29 deletions(-) create mode 100644 stock_no_negative/models/stock_location.py create mode 100644 stock_no_negative/readme/CONFIGURE.rst create mode 100644 stock_no_negative/readme/CONTRIBUTORS.rst create mode 100644 stock_no_negative/readme/DESCRIPTION.rst create mode 100644 stock_no_negative/readme/HISTORY.rst create mode 100644 stock_no_negative/readme/USAGE.rst create mode 100644 stock_no_negative/static/description/index.html rename stock_no_negative/views/{product.xml => product_product_views.xml} (100%) create mode 100644 stock_no_negative/views/stock_location_views.xml diff --git a/stock_no_negative/README.rst b/stock_no_negative/README.rst index 02135e815bdd..b5d191aeab48 100644 --- a/stock_no_negative/README.rst +++ b/stock_no_negative/README.rst @@ -1,60 +1,134 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - ======================= Stock Disallow Negative ======================= -By default, Odoo allows negative stock. The advantage of negative stock is that, if some stock levels are wrong in the ERP, you will not be blocked when validating the picking for a customer... so you will still be able to ship the products on time (it's an example !). The problem is that, after you forced the stock level to negative, you are supposed to fix the stock level later via an inventory ; but this action is often forgotten by users, so you end up with negative stock levels in your ERP and it can stay like this forever (or at least until the next full inventory). - -If you disallow negative stock in Odoo with this module, you will be blocked when trying to validate a stock operation that will set the stock level of a product as negative. So you will have to fix the wrong stock level of that product without delay, in order to validate the stock operation in Odoo... you can't forget it anymore ! +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/11.0/stock_no_negative + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-11-0/stock-logistics-workflow-11-0-stock_no_negative + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/154/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +By default, Odoo allows negative stock. The advantage of negative stock +is that, if some stock levels are wrong in the ERP, you will not be blocked +when validating the picking for a customer... so you will still be able to +ship the products on time (it's an example !). The problem is that, after you +forced the stock level to negative, you are supposed to fix the stock level +later via an inventory ; but this action is often forgotten by users, +so you end up with negative stock levels in your ERP and it can stay like +this forever (or at least until the next full inventory). + +If you disallow negative stock in Odoo with this module, you will be blocked +when trying to validate a stock operation that will set the stock level of +a product and/or location as negative. So you will have to fix the +wrong stock level of that product without delay, in order to validate the +stock operation in Odoo...you can't forget it anymore ! + + +**Table of contents** + +.. contents:: + :local: Configuration ============= -By default, the stockable products will not be allowed to have a negative stock. If you want to make some exceptions for some products or some product categories, you can activate the option *Allow Negative Stock* on some products or some products categories. +By default, the stockable products will not be allowed to have a negative +stock. If you want to make some exceptions for some products, product +categories or locations, you can activate the option *Allow Negative Stock*: + +For products: + +#. Go to *Inventory / Master Data / Products* and in the + tab *General Information* activate this option. + +For product categories: + +#. Go to *Inventory / Configuration / Products / Product Categories* + and activate this option. + +For individual locations: + +#. Go to *Inventory / Configuration / Settings* and activate + the option *Storage Locations*. +#. Go to *Inventory / Configuration / Warehouse Management / Locations* and + activate the option the option *Allow Negative Stock* for the locations you + choose. + Usage ===== -When you validate a stock operation (a stock move, a picking, a manufacturing order, etc.) that will set the stock level of a stockable product as negative, you will be blocked by an error message. The consumable products can still have a negative stock level. +When you validate a stock operation (a stock move, a picking, +a manufacturing order, etc.) that will set the stock level of a +stockable product as negative, you will be blocked by an error message. +The consumable products can still have a negative stock level. + +Changelog +========= -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/154/11.0 +11.0.1.1.0 (2018-12-13) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Add the ability to allow negative stock for individual stock locations. Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smashing it by providing a detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Akretion + Contributors ------------- +~~~~~~~~~~~~ * Alexis de Lattre * Eficent Business and IT Consulting Services S.L. + * Jordi Ballester * Serpent Consulting Services Pvt. Ltd. * Tecnativa * Pedro M. Baeza -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_no_negative/__manifest__.py b/stock_no_negative/__manifest__.py index 770bf6ca204c..d5cfa6825fda 100644 --- a/stock_no_negative/__manifest__.py +++ b/stock_no_negative/__manifest__.py @@ -5,13 +5,16 @@ { 'name': 'Stock Disallow Negative', - 'version': '11.0.1.0.1', + 'version': '11.0.1.1.0', 'category': 'Inventory, Logistic, Storage', 'license': 'AGPL-3', 'summary': 'Disallow negative stock levels by default', 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'depends': ['stock'], - 'data': ['views/product.xml'], + 'data': [ + 'views/product_product_views.xml', + 'views/stock_location_views.xml', + ], 'installable': True, } diff --git a/stock_no_negative/models/__init__.py b/stock_no_negative/models/__init__.py index 6b3a97ecd313..8d84cb148784 100644 --- a/stock_no_negative/models/__init__.py +++ b/stock_no_negative/models/__init__.py @@ -4,3 +4,4 @@ from . import product from . import stock_quant +from . import stock_location diff --git a/stock_no_negative/models/stock_location.py b/stock_no_negative/models/stock_location.py new file mode 100644 index 000000000000..c304d066e9cb --- /dev/null +++ b/stock_no_negative/models/stock_location.py @@ -0,0 +1,14 @@ +# ?? 2018 Eficent (https://www.eficent.com) +# @author Jordi Ballester +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, fields + + +class StockLocation(models.Model): + _inherit = 'stock.location' + + allow_negative_stock = fields.Boolean( + string='Allow Negative Stock', + help="Allow negative stock levels for the stockable products " + "attached to this location.") diff --git a/stock_no_negative/models/stock_quant.py b/stock_no_negative/models/stock_quant.py index b2340c9c3de9..6ef4a201fe0f 100644 --- a/stock_no_negative/models/stock_quant.py +++ b/stock_no_negative/models/stock_quant.py @@ -22,13 +22,17 @@ def check_negative_qty(self): ) if not check_negative_qty: return + for quant in self: + disallowed_by_product = \ + not quant.product_id.allow_negative_stock \ + and not quant.product_id.categ_id.allow_negative_stock + disallowed_by_location = not quant.location_id.allow_negative_stock if ( float_compare(quant.quantity, 0, precision_digits=p) == -1 and quant.product_id.type == 'product' and - not quant.product_id.allow_negative_stock and - not quant.product_id.categ_id.allow_negative_stock and - quant.location_id.usage in ['internal', 'transit'] + quant.location_id.usage in ['internal', 'transit'] and + disallowed_by_product and disallowed_by_location ): msg_add = '' if quant.lot_id: @@ -37,6 +41,6 @@ def check_negative_qty(self): "You cannot validate this stock operation because the " "stock level of the product '%s'%s would become negative " "(%s) on the stock location '%s' and negative stock is " - "not allowed for this product.") % ( + "not allowed for this product and/or location.") % ( quant.product_id.name, msg_add, quant.quantity, quant.location_id.complete_name)) diff --git a/stock_no_negative/readme/CONFIGURE.rst b/stock_no_negative/readme/CONFIGURE.rst new file mode 100644 index 000000000000..af12e7673fd1 --- /dev/null +++ b/stock_no_negative/readme/CONFIGURE.rst @@ -0,0 +1,22 @@ +By default, the stockable products will not be allowed to have a negative +stock. If you want to make some exceptions for some products, product +categories or locations, you can activate the option *Allow Negative Stock*: + +For products: + +#. Go to *Inventory / Master Data / Products* and in the + tab *General Information* activate this option. + +For product categories: + +#. Go to *Inventory / Configuration / Products / Product Categories* + and activate this option. + +For individual locations: + +#. Go to *Inventory / Configuration / Settings* and activate + the option *Storage Locations*. +#. Go to *Inventory / Configuration / Warehouse Management / Locations* and + activate the option the option *Allow Negative Stock* for the locations you + choose. + diff --git a/stock_no_negative/readme/CONTRIBUTORS.rst b/stock_no_negative/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..553d62f979ac --- /dev/null +++ b/stock_no_negative/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Alexis de Lattre +* Eficent Business and IT Consulting Services S.L. + * Jordi Ballester +* Serpent Consulting Services Pvt. Ltd. +* Tecnativa + * Pedro M. Baeza diff --git a/stock_no_negative/readme/DESCRIPTION.rst b/stock_no_negative/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..a2772af003d4 --- /dev/null +++ b/stock_no_negative/readme/DESCRIPTION.rst @@ -0,0 +1,15 @@ +By default, Odoo allows negative stock. The advantage of negative stock +is that, if some stock levels are wrong in the ERP, you will not be blocked +when validating the picking for a customer... so you will still be able to +ship the products on time (it's an example !). The problem is that, after you +forced the stock level to negative, you are supposed to fix the stock level +later via an inventory ; but this action is often forgotten by users, +so you end up with negative stock levels in your ERP and it can stay like +this forever (or at least until the next full inventory). + +If you disallow negative stock in Odoo with this module, you will be blocked +when trying to validate a stock operation that will set the stock level of +a product and/or location as negative. So you will have to fix the +wrong stock level of that product without delay, in order to validate the +stock operation in Odoo...you can't forget it anymore ! + diff --git a/stock_no_negative/readme/HISTORY.rst b/stock_no_negative/readme/HISTORY.rst new file mode 100644 index 000000000000..c9e7e47f9c41 --- /dev/null +++ b/stock_no_negative/readme/HISTORY.rst @@ -0,0 +1,4 @@ +11.0.1.1.0 (2018-12-13) +~~~~~~~~~~~~~~~~~~~~~~~ + +* Add the ability to allow negative stock for individual stock locations. diff --git a/stock_no_negative/readme/USAGE.rst b/stock_no_negative/readme/USAGE.rst new file mode 100644 index 000000000000..004f5169f9c8 --- /dev/null +++ b/stock_no_negative/readme/USAGE.rst @@ -0,0 +1,4 @@ +When you validate a stock operation (a stock move, a picking, +a manufacturing order, etc.) that will set the stock level of a +stockable product as negative, you will be blocked by an error message. +The consumable products can still have a negative stock level. diff --git a/stock_no_negative/static/description/index.html b/stock_no_negative/static/description/index.html new file mode 100644 index 000000000000..4f1965e9c24d --- /dev/null +++ b/stock_no_negative/static/description/index.html @@ -0,0 +1,460 @@ + + + + + + +Stock Disallow Negative + + + +
+

Stock Disallow Negative

+ + +

Beta License: AGPL-3 OCA/stock-logistics-workflow Translate me on Weblate Try me on Runbot

+

By default, Odoo allows negative stock. The advantage of negative stock +is that, if some stock levels are wrong in the ERP, you will not be blocked +when validating the picking for a customer??? so you will still be able to +ship the products on time (it???s an example !). The problem is that, after you +forced the stock level to negative, you are supposed to fix the stock level +later via an inventory ; but this action is often forgotten by users, +so you end up with negative stock levels in your ERP and it can stay like +this forever (or at least until the next full inventory).

+

If you disallow negative stock in Odoo with this module, you will be blocked +when trying to validate a stock operation that will set the stock level of +a product and/or location as negative. So you will have to fix the +wrong stock level of that product without delay, in order to validate the +stock operation in Odoo???you can???t forget it anymore !

+

Table of contents

+ +
+

Configuration

+

By default, the stockable products will not be allowed to have a negative +stock. If you want to make some exceptions for some products, product +categories or locations, you can activate the option Allow Negative Stock:

+

For products:

+
    +
  1. Go to Inventory / Master Data / Products and in the +tab General Information activate this option.
  2. +
+

For product categories:

+
    +
  1. Go to Inventory / Configuration / Products / Product Categories +and activate this option.
  2. +
+

For individual locations:

+
    +
  1. Go to Inventory / Configuration / Settings and activate +the option Storage Locations.
  2. +
  3. Go to Inventory / Configuration / Warehouse Management / Locations and +activate the option the option Allow Negative Stock for the locations you +choose.
  4. +
+
+
+

Usage

+

When you validate a stock operation (a stock move, a picking, +a manufacturing order, etc.) that will set the stock level of a +stockable product as negative, you will be blocked by an error message. +The consumable products can still have a negative stock level.

+
+
+

Changelog

+
+

11.0.1.1.0 (2018-12-13)

+
    +
  • Add the ability to allow negative stock for individual stock locations.
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_no_negative/tests/test_stock_no_negative.py b/stock_no_negative/tests/test_stock_no_negative.py index 1e06a1da7656..c617cdb54dae 100644 --- a/stock_no_negative/tests/test_stock_no_negative.py +++ b/stock_no_negative/tests/test_stock_no_negative.py @@ -72,7 +72,7 @@ def test_check_constrains(self): with self.assertRaises(ValidationError): self.stock_picking.button_validate() - def test_true_allow_negative_stock(self): + def test_true_allow_negative_stock_product(self): """Assert that negative stock levels are allowed when the allow_negative_stock is set active in the product""" self.product.allow_negative_stock = True @@ -82,3 +82,15 @@ def test_true_allow_negative_stock(self): ('product_id', '=', self.product.id), ('location_id', '=', self.location_id.id)]) self.assertEqual(quant.quantity, -100) + + def test_true_allow_negative_stock_location(self): + """Assert that negative stock levels are allowed when + the allow_negative_stock is set active in the product""" + self.product.allow_negative_stock = False + self.location_id.allow_negative_stock = True + self.stock_picking.action_confirm() + self.stock_picking.button_validate() + quant = self.env['stock.quant'].search([ + ('product_id', '=', self.product.id), + ('location_id', '=', self.location_id.id)]) + self.assertEqual(quant.quantity, -100) diff --git a/stock_no_negative/views/product.xml b/stock_no_negative/views/product_product_views.xml similarity index 100% rename from stock_no_negative/views/product.xml rename to stock_no_negative/views/product_product_views.xml diff --git a/stock_no_negative/views/stock_location_views.xml b/stock_no_negative/views/stock_location_views.xml new file mode 100644 index 000000000000..69540c3bded3 --- /dev/null +++ b/stock_no_negative/views/stock_location_views.xml @@ -0,0 +1,22 @@ + + + + + + + stock.location.form.allow_negative_stock + stock.location + + + + + + + + + From 4d9764bb3454214ec57bc0d201ae3c3d34a0acaa Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Thu, 24 Jan 2019 18:26:45 +0000 Subject: [PATCH 15/66] [UPD] README.rst --- .../static/description/index.html | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/stock_no_negative/static/description/index.html b/stock_no_negative/static/description/index.html index 4f1965e9c24d..62a81677ada4 100644 --- a/stock_no_negative/static/description/index.html +++ b/stock_no_negative/static/description/index.html @@ -3,13 +3,13 @@ - + Stock Disallow Negative