[IMP] stock_cycle_count:

* Update README.
 * Fixes: DEFAULT_SERVER_DATETIME_FORMAT, PERCENT variables and sale price calculation.
This commit is contained in:
lreficent
2017-03-09 15:54:32 +01:00
committed by Lois Rilo
parent a6d6000501
commit f04dd9d965
6 changed files with 37 additions and 15 deletions

View File

@@ -6,9 +6,22 @@
Stock Cycle Count
=================
This module adds the capability to execute a cycle count strategy in a
warehouse through different rules defined by the user.
This module provides the capability to execute a cycle count strategy in a
warehouse through different rules defined by the user. Cycle count is an
alternative to full wall-to-wall physical inventories in which little
portions (stock locations) of the stock are selected to count on a regular
basis.
The system propose locations in which to perform a inventory adjustment every
day based on a set of rules defined for the warehouse. In addition the system
can propose Zero-Confirmations which are simply and opportunistic counts to
check whether a locations has actually became empty or not.
With this strategy it is possible to:
* Remove the need to perform full physical inventories and to stop the
production in the warehouse.
* Measure the accuracy of the inventory records and improve it.
* Correct inventory errors earlier and prevent them to become bigger.
Installation
============
@@ -60,9 +73,9 @@ Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of
trouble, please check there if your issue has already been reported. If you
spotted it first, help us smash it by providing detailed and welcomed feedback.
Images

View File

@@ -5,6 +5,7 @@
from openerp import api, fields, models, _
from openerp.exceptions import UserError
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from datetime import timedelta, datetime
@@ -111,7 +112,7 @@ class StockCycleCountRule(models.Model):
@api.model
def _propose_cycle_count(self, date, location):
cycle_count = {
'date': date.strftime('%Y-%m-%d %H:%M:%S'),
'date': date.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'location': location,
'rule_type': self
}
@@ -130,7 +131,8 @@ class StockCycleCountRule(models.Model):
period = self.periodic_count_period / \
self.periodic_qty_per_period
next_date = datetime.strptime(
latest_inventory, '%Y-%m-%d %H:%M:%S') + timedelta(
latest_inventory,
DEFAULT_SERVER_DATETIME_FORMAT) + timedelta(
days=period)
except Exception as e:
raise UserError(
@@ -153,7 +155,8 @@ class StockCycleCountRule(models.Model):
@api.model
def _compute_turnover(self, move):
turnover = move.product_uom_qty * move.product_id.standard_price
price = move.get_price_unit(move)
turnover = move.product_uom_qty * price
return turnover
@api.model

View File

@@ -5,6 +5,8 @@
from openerp import api, fields, models
PERCENT = 100.0
class StockInventory(models.Model):
_inherit = 'stock.inventory'
@@ -15,8 +17,8 @@ class StockInventory(models.Model):
abs_discrepancy = sum(self.line_ids.mapped(
lambda x: abs(x.discrepancy_qty)))
if total_qty:
self.inventory_accuracy = 100 * (total_qty - abs_discrepancy) / \
total_qty
self.inventory_accuracy = PERCENT * (
total_qty - abs_discrepancy) / total_qty
if not self.line_ids and self.state == 'done':
self.inventory_accuracy = 100.0

View File

@@ -6,6 +6,7 @@
import logging
from openerp import api, fields, models, tools
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from datetime import datetime
_logger = logging.getLogger(__name__)
@@ -71,10 +72,11 @@ class StockLocation(models.Model):
self.create_zero_confirmation_cycle_count()
def create_zero_confirmation_cycle_count(self):
date = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
date = datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
wh_id = self.get_warehouse(self)
date_horizon = self.env['stock.warehouse'].browse(
wh_id).get_horizon_date()[0].strftime('%Y-%m-%d %H:%M:%S')
wh_id).get_horizon_date()[0].strftime(
DEFAULT_SERVER_DATETIME_FORMAT)
counts_planned = self.env['stock.cycle.count'].search([
('date_deadline', '<', date_horizon), ('state', '=', 'draft'),
('location_id', '=', self.id)])

View File

@@ -4,6 +4,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openerp import api, fields, models
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from datetime import datetime, timedelta
@@ -92,7 +93,7 @@ class StockWarehouse(models.Model):
existing_cycle_counts.state = 'cancelled'
delta = datetime.strptime(
cycle_count_proposed['date'],
'%Y-%m-%d %H:%M:%S') - datetime.today()
DEFAULT_SERVER_DATETIME_FORMAT) - datetime.today()
if not existing_cycle_counts and \
delta.days < self.cycle_count_planning_horizon:
self.env['stock.cycle.count'].create({

View File

@@ -67,7 +67,7 @@ class TestStockCycleCount(common.TransactionCase):
self.stock_cycle_count1.action_view_inventory()
self.inventory1 = self.stock_inventory_model.search([
('cycle_count_id', '=', self.stock_cycle_count1.id)])
('cycle_count_id', '=', self.stock_cycle_count1.id)])
self.inventory1.prepare_inventory()
self.inventory1.action_done()
@@ -167,4 +167,5 @@ class TestStockCycleCount(common.TransactionCase):
# constrain: can only have one warehouse assigned
self.stock_cycle_count_rule4.warehouse_ids = [(4, self.big_wh.id)]
with self.assertRaises(ValidationError):
self.stock_cycle_count_rule4.warehouse_ids = [(4, self.small_wh.id)]
self.stock_cycle_count_rule4.warehouse_ids = [
(4, self.small_wh.id)]