Skip to content

Commit

Permalink
Merge pull request OCA#2 from darshan-serpent/10-stock_no_negative
Browse files Browse the repository at this point in the history
[10.0] [FIX] [stock_no_negative] proper indentation, docstring, flake8
  • Loading branch information
Alexis de Lattre authored Jan 6, 2017
2 parents 3a2a6be + ca8beed commit 9c5defd
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions stock_no_negative/tests/test_stock_no_negative.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# © 2016 Serpent Consulting Services Pvt. Ltd. (<http://www.serpentcs.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError

Expand All @@ -19,13 +20,10 @@ def setUp(self):
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 with real cost
# Create a Product
self.product = self._create_product('test_product1')

self._create_picking()

def _create_product_category(self):
Expand All @@ -35,7 +33,6 @@ def _create_product_category(self):
return product_ctg

def _create_product(self, name):
"""Create a Product with inventory valuation set to auto."""
product = self.product_model.create({
'name': name,
'categ_id': self.product_ctg.id,
Expand All @@ -49,20 +46,23 @@ def _create_picking(self):
'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
})
'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()
Expand All @@ -73,6 +73,8 @@ def test_check_constrains(self):
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()
Expand Down

0 comments on commit 9c5defd

Please sign in to comment.