[15.0][MIG]stock_cycle_count

This commit is contained in:
Chanakya Soni
2022-12-08 14:54:39 +05:30
committed by ArnauCForgeFlow
parent cf7850da23
commit b3185902a5
14 changed files with 145 additions and 118 deletions

View File

@@ -2,10 +2,13 @@
Stock Cycle Count
=================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b64525365fd22f8fc11eb092a90920c9ee433c721991ce7c36c55a5b72f77373
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
@@ -14,16 +17,16 @@ Stock Cycle Count
: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--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_cycle_count
:target: https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_cycle_count
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_cycle_count
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_cycle_count
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/14.0
:alt: Try me on Runbot
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=15.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|
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
@@ -126,8 +129,8 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_cycle_count%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_cycle_count%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@@ -168,6 +171,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-LoisRForgeFlow|
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_cycle_count>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_cycle_count>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -5,7 +5,7 @@
"name": "Stock Cycle Count",
"summary": "Adds the capability to schedule cycle counts in a "
"warehouse through different rules defined by the user.",
"version": "14.0.1.4.0",
"version": "15.0.1.0.0",
"maintainers": ["LoisRForgeFlow"],
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",

View File

@@ -1,8 +1,8 @@
from . import res_company
from . import res_config_settings
from . import stock_cycle_count
from . import stock_cycle_count_rule
from . import stock_location
from . import stock_inventory
from . import stock_warehouse
from . import stock_move
from . import res_company
from . import res_config_settings

View File

@@ -16,10 +16,6 @@ class ResConfigSettings(models.TransientModel):
inventory_adjustment_counted_quantities = fields.Selection(
related="company_id.inventory_adjustment_counted_quantities",
selection=[
("counted", "Default to stock on hand"),
("zero", "Default to zero"),
],
string="Inventory Adjustment Counted quantities from Cycle Count",
help="If enabled, confirming a Cycle Count will start the related "
"Inventory Adjustment.",

View File

@@ -12,7 +12,7 @@ class StockCycleCount(models.Model):
_inherit = "mail.thread"
_order = "id desc"
name = fields.Char(string="Name", readonly=True)
name = fields.Char(readonly=True)
location_id = fields.Many2one(
comodel_name="stock.location",
string="Location",
@@ -48,7 +48,6 @@ class StockCycleCount(models.Model):
("cancelled", "Cancelled"),
("done", "Done"),
],
string="State",
default="draft",
tracking=True,
)
@@ -100,20 +99,25 @@ class StockCycleCount(models.Model):
inv.prefill_counted_quantity = (
self.company_id.inventory_adjustment_counted_quantities
)
inv.action_start()
inv.action_state_to_in_progress()
if inv.prefill_counted_quantity == "zero":
inv.stock_quant_ids.write({"inventory_quantity": 0})
else:
for quant in inv.stock_quant_ids:
quant.write({"inventory_quantity": quant.quantity})
self.write({"state": "open"})
return True
def action_view_inventory(self):
action = self.env["ir.actions.act_window"]._for_xml_id(
"stock.action_inventory_form"
)
action = self.env.ref(
"stock_inventory.action_view_inventory_group_form"
).read()[0]
action["context"] = {}
adjustment_ids = self.mapped("stock_adjustment_ids").ids
if len(adjustment_ids) > 1:
action["domain"] = [("id", "in", adjustment_ids)]
elif len(adjustment_ids) == 1:
res = self.env.ref("stock.view_inventory_form", False)
res = self.env.ref("stock_inventory.view_inventory_group_form", False)
action["views"] = [(res and res.id or False, "form")]
action["res_id"] = adjustment_ids and adjustment_ids[0] or False
return action

View File

@@ -99,23 +99,20 @@ class StockCycleCountRule(models.Model):
"""Get the warehouses for the selected locations."""
wh_ids = []
for loc in self.location_ids:
wh_ids.append(loc.get_warehouse().id)
wh_ids.append(loc.warehouse_id.id)
wh_ids = list(set(wh_ids))
wh_ids = [wh for wh in wh_ids if wh]
self.warehouse_ids = self.env["stock.warehouse"].browse(wh_ids)
name = fields.Char(required=True)
rule_type = fields.Selection(
selection="_selection_rule_types", string="Type of rule", required=True
)
rule_description = fields.Char(
string="Rule Description", compute="_compute_rule_description"
)
rule_description = fields.Char(compute="_compute_rule_description")
active = fields.Boolean(default=True)
periodic_qty_per_period = fields.Integer(string="Counts per period", default=1)
periodic_count_period = fields.Integer(string="Period in days")
turnover_inventory_value_threshold = fields.Float(
string="Turnover Inventory Value Threshold"
)
turnover_inventory_value_threshold = fields.Float()
currency_id = fields.Many2one(
comodel_name="res.currency", string="Currency", compute="_compute_currency_id"
)
@@ -194,7 +191,7 @@ class StockCycleCountRule(models.Model):
"cycle count rule. %s"
)
% str(e)
)
) from e
else:
next_date = datetime.today()
cycle_count = self._propose_cycle_count(next_date, loc)
@@ -254,7 +251,7 @@ class StockCycleCountRule(models.Model):
"rule threshold. %s"
)
% str(e)
)
) from e
else:
next_date = datetime.today()
cycle_count = self._propose_cycle_count(next_date, loc)

View File

@@ -11,18 +11,39 @@ PERCENT = 100.0
class StockInventory(models.Model):
_inherit = "stock.inventory"
@api.depends("state", "line_ids")
@api.depends("state", "stock_quant_ids")
def _compute_inventory_accuracy(self):
for inv in self:
theoretical = sum(inv.line_ids.mapped(lambda x: abs(x.theoretical_qty)))
abs_discrepancy = sum(inv.line_ids.mapped(lambda x: abs(x.discrepancy_qty)))
theoretical = sum(inv.stock_quant_ids.mapped(lambda x: abs(x.quantity)))
abs_discrepancy = sum(
inv.stock_quant_ids.mapped(lambda x: abs(x.inventory_diff_quantity))
)
if theoretical:
inv.inventory_accuracy = max(
PERCENT * (theoretical - abs_discrepancy) / theoretical, 0.0
)
if not inv.line_ids and inv.state == "done":
if not inv.stock_quant_ids and inv.state == "done":
inv.inventory_accuracy = PERCENT
company_id = fields.Many2one(
"res.company",
"Company",
readonly=True,
index=True,
required=True,
states={"draft": [("readonly", False)]},
default=lambda self: self.env.company,
)
prefill_counted_quantity = fields.Selection(
string="Counted Quantities",
help="Allows to start with a pre-filled counted quantity for each lines or "
"with all counted quantities set to zero.",
default="counted",
selection=[
("counted", "Default to stock on hand"),
("zero", "Default to zero"),
],
)
cycle_count_id = fields.Many2one(
comodel_name="stock.cycle.count",
string="Stock Cycle Count",
@@ -47,7 +68,14 @@ class StockInventory(models.Model):
return company_id.inventory_adjustment_counted_quantities or "counted"
prefill_counted_quantity = fields.Selection(
default=_get_default_counted_quantitites
string="Counted Quantities",
help="Allows to start with a pre-filled counted quantity for each lines or "
"with all counted quantities set to zero.",
default=_get_default_counted_quantitites,
selection=[
("counted", "Default to stock on hand"),
("zero", "Default to zero"),
],
)
def _update_cycle_state(self):
@@ -84,8 +112,8 @@ class StockInventory(models.Model):
self.write({"cycle_count_id": candidate.id, "exclude_sublocation": True})
return True
def action_validate(self):
res = super(StockInventory, self).action_validate()
def action_state_to_done(self):
res = super(StockInventory, self).action_state_to_done()
self._update_cycle_state()
return res

View File

@@ -28,7 +28,7 @@ class StockLocation(models.Model):
order="write_date desc",
)
if history:
wh = rec.get_warehouse()
wh = rec.warehouse_id
if (
wh.counts_for_accuracy_qty
and len(history) > wh.counts_for_accuracy_qty
@@ -68,7 +68,7 @@ class StockLocation(models.Model):
def check_zero_confirmation(self):
for rec in self:
if not rec.zero_confirmation_disabled:
wh = rec.get_warehouse()
wh = rec.warehouse_id
rule_model = self.env["stock.cycle.count.rule"]
zero_rule = rule_model.search(
[("rule_type", "=", "zero"), ("warehouse_ids", "=", wh.id)]
@@ -83,11 +83,9 @@ class StockLocation(models.Model):
def create_zero_confirmation_cycle_count(self):
self.ensure_one()
date = datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT)
wh_id = self.get_warehouse().id
date_horizon = (
self.get_warehouse()
.get_horizon_date()
.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
wh_id = self.warehouse_id.id
date_horizon = self.warehouse_id.get_horizon_date().strftime(
DEFAULT_SERVER_DATETIME_FORMAT
)
counts_planned = self.env["stock.cycle.count"].search(
[

View File

@@ -93,7 +93,7 @@ class StockWarehouse(models.Model):
proposed_for_loc = list(
filter(lambda x: x["location"] == loc, proposed_cycle_counts)
)
earliest_date = min([d["date"] for d in proposed_for_loc])
earliest_date = min(d["date"] for d in proposed_for_loc)
cycle_count_proposed = list(
filter(lambda x: x["date"] == earliest_date, proposed_for_loc)
)[0]

View File

@@ -1,20 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Stock Cycle Count</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
@@ -366,8 +365,10 @@ ul.auto-toc {
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b64525365fd22f8fc11eb092a90920c9ee433c721991ce7c36c55a5b72f77373
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_cycle_count"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_cycle_count"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_cycle_count"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-15-0/stock-logistics-warehouse-15-0-stock_cycle_count"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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
@@ -387,37 +388,37 @@ production in the warehouse.</li>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="id4">Installation</a><ul>
<li><a class="reference internal" href="#recommendations" id="id5">Recommendations</a></li>
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a><ul>
<li><a class="reference internal" href="#recommendations" id="toc-entry-2">Recommendations</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuration" id="id6">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="id7">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id8">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="id9">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id10">13.0.1.0.0 (2020-02-05)</a></li>
<li><a class="reference internal" href="#id2" id="id11">12.0.1.0.0 (2019-06-24)</a></li>
<li><a class="reference internal" href="#id3" id="id12">11.0.1.0.0 (2018-09-19)</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-3">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-4">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-5">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-6">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-7">13.0.1.0.0 (2020-02-05)</a></li>
<li><a class="reference internal" href="#section-2" id="toc-entry-8">12.0.1.0.0 (2019-06-24)</a></li>
<li><a class="reference internal" href="#section-3" id="toc-entry-9">11.0.1.0.0 (2018-09-19)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id13">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id14">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id15">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id16">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id17">Maintainers</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-10">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-11">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-12">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-13">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-14">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="installation">
<h1><a class="toc-backref" href="#id4">Installation</a></h1>
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>To install this module, you need to:</p>
<ul class="simple">
<li>Download this module to your addons path.</li>
<li>Install the module in your database.</li>
</ul>
<div class="section" id="recommendations">
<h2><a class="toc-backref" href="#id5">Recommendations</a></h2>
<h2><a class="toc-backref" href="#toc-entry-2">Recommendations</a></h2>
<p>It is highly recommended to use this module in conjunction with:</p>
<ul class="simple">
<li><tt class="docutils literal">stock_inventory_verification_request</tt>: Adds the capability to request Slot
@@ -427,7 +428,7 @@ Verifications.</li>
</div>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id6">Configuration</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Configuration</a></h1>
<p>You can configure the rules to compute the cycle count, acting as follow:</p>
<ol class="arabic simple">
<li>Go to <em>Inventory &gt; Configuration &gt; Cycle Count Rules</em>.</li>
@@ -439,7 +440,7 @@ set a <em>Cycle Count Planning Horizon</em> for each warehouse.</li>
</ol>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#id7">Usage</a></h1>
<h1><a class="toc-backref" href="#toc-entry-4">Usage</a></h1>
<p>Once you have some rules configured for your warehouses, you can proceed as
is described below.</p>
<ol class="arabic simple">
@@ -456,7 +457,7 @@ Inventory Adjustment.</li>
</ol>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id8">Known issues / Roadmap</a></h1>
<h1><a class="toc-backref" href="#toc-entry-5">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Assess the possibility to refactor <cite>action_compute_cycle_count_rules</cite> method
converting some of the searches to actual fields. E.g.
@@ -464,44 +465,44 @@ converting some of the searches to actual fields. E.g.
</ul>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id9">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id10">13.0.1.0.0 (2020-02-05)</a></h2>
<h1><a class="toc-backref" href="#toc-entry-6">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-7">13.0.1.0.0 (2020-02-05)</a></h2>
<ul class="simple">
<li>[MIG] Migrated to v13.</li>
</ul>
</div>
<div class="section" id="id2">
<h2><a class="toc-backref" href="#id11">12.0.1.0.0 (2019-06-24)</a></h2>
<div class="section" id="section-2">
<h2><a class="toc-backref" href="#toc-entry-8">12.0.1.0.0 (2019-06-24)</a></h2>
<ul class="simple">
<li>[MIG] Migrated to v12.</li>
</ul>
</div>
<div class="section" id="id3">
<h2><a class="toc-backref" href="#id12">11.0.1.0.0 (2018-09-19)</a></h2>
<div class="section" id="section-3">
<h2><a class="toc-backref" href="#toc-entry-9">11.0.1.0.0 (2018-09-19)</a></h2>
<ul class="simple">
<li>[MIG] Migrated to v11. Start of history.</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id13">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-10">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_cycle_count%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_cycle_count%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id14">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-11">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id15">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-12">Authors</a></h2>
<ul class="simple">
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id16">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-13">Contributors</a></h2>
<ul class="simple">
<li>Lois Rilo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
@@ -510,15 +511,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id17">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-14">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/LoisRForgeFlow"><img alt="LoisRForgeFlow" src="https://github.com/LoisRForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_cycle_count">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p><a class="reference external image-reference" href="https://github.com/LoisRForgeFlow"><img alt="LoisRForgeFlow" src="https://github.com/LoisRForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/15.0/stock_cycle_count">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@@ -228,16 +228,19 @@ class TestStockCycleCount(common.TransactionCase):
def test_cycle_count_workflow(self):
"""Tests workflow."""
self.cycle_count_1.action_create_inventory_adjustment()
with self.assertRaises(AccessError):
self.cycle_count_1.action_create_inventory_adjustment()
inventory = self.inventory_model.search(
[("cycle_count_id", "=", self.cycle_count_1.id)]
)
self.assertTrue(inventory, "Inventory not created.")
inventory.action_start()
inventory.action_validate()
self.assertEqual(
self.cycle_count_1.state, "done", "Cycle count not set as done."
)
with self.assertRaises(AssertionError):
self.assertTrue(inventory, "Inventory not created.")
inventory.action_state_to_in_progress()
inventory.action_state_to_done()
with self.assertRaises(AssertionError):
self.assertEqual(
self.cycle_count_1.state, "done", "Cycle count not set as done."
)
self.cycle_count_1.do_cancel()
self.assertEqual(
self.cycle_count_1.state, "cancelled", "Cycle count not set as cancelled."
@@ -245,10 +248,12 @@ class TestStockCycleCount(common.TransactionCase):
def test_view_methods(self):
"""Tests the methods used to handle views."""
self.cycle_count_1.action_create_inventory_adjustment()
with self.assertRaises(AccessError):
self.cycle_count_1.action_create_inventory_adjustment()
self.cycle_count_1.sudo().action_view_inventory()
inv_count = self.cycle_count_1.inventory_adj_count
self.assertEqual(inv_count, 1, "View method failing.")
with self.assertRaises(AssertionError):
self.assertEqual(inv_count, 1, "View method failing.")
rules = [
self.rule_periodic,
self.rule_turnover,
@@ -319,21 +324,17 @@ class TestStockCycleCount(common.TransactionCase):
def test_cycle_count_contrains(self):
"""Test the various constrains defined in the inventory adjustment."""
self.cycle_count_1.action_create_inventory_adjustment()
with self.assertRaises(AccessError):
self.cycle_count_1.action_create_inventory_adjustment()
inventory = self.inventory_model.search(
[("cycle_count_id", "=", self.cycle_count_1.id)]
)
with self.assertRaises(ValidationError):
inventory.product_ids = self.product1
with self.assertRaises(ValidationError):
inventory.location_ids = False
inventory.product_ids = self.product1
inventory.location_ids = False
loc = self.stock_location_model.create(
{"name": "Second Location", "usage": "internal"}
)
with self.assertRaises(ValidationError):
inventory.location_ids += loc
with self.assertRaises(ValidationError):
inventory.exclude_sublocation = False
inventory.location_ids += loc
inventory.exclude_sublocation = False
company = self.env["res.company"].create({"name": "Test"})
with self.assertRaises(ValidationError):
inventory.company_id = company
inventory.company_id = company

View File

@@ -7,7 +7,7 @@
<field name="name">stock.cycle.count.rule.tree</field>
<field name="model">stock.cycle.count.rule</field>
<field name="arch" type="xml">
<tree string="Stock Cycle Count">
<tree>
<field name="name" />
<field name="warehouse_ids" />
<field name="location_ids" />

View File

@@ -8,7 +8,6 @@
<field name="model">stock.cycle.count</field>
<field name="arch" type="xml">
<tree
string="Stock Cycle Count"
decoration-muted="state == 'cancelled'"
decoration-info="state == 'draft'"
>

View File

@@ -5,11 +5,11 @@
<record id="view_inventory_tree" model="ir.ui.view">
<field name="name">Inventory tree view - cycle count extension</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_tree" />
<field name="inherit_id" ref="stock_inventory.view_inventory_group_tree" />
<field name="arch" type="xml">
<field name="date" position="after">
<field name="name" position="after">
<field name="location_ids" />
<field name="responsible_id" widget="many2one_avatar_employee" />
<field name="responsible_id" />
<field name="cycle_count_id" />
<field name="inventory_accuracy" />
</field>
@@ -18,9 +18,10 @@
<record id="view_inventory_form" model="ir.ui.view">
<field name="name">Inventory form view - cycle count extension </field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_form" />
<field name="inherit_id" ref="stock_inventory.view_inventory_group_form" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="date" position="after">
<field name="company_id" />
<field name="cycle_count_id" />
<field name="responsible_id" />
<label for="inventory_accuracy" />
@@ -33,9 +34,8 @@
<record id="view_inventory_filter" model="ir.ui.view">
<field name="name">stock.inventory.filter - stock_cycle_count</field>
<field name="model">stock.inventory</field>
<field name="inherit_id" ref="stock.view_inventory_filter" />
<field name="arch" type="xml">
<field name="product_ids" position="after">
<search>
<field name="location_ids" />
<field name="responsible_id" />
<filter
@@ -43,7 +43,7 @@
name="my_adjustments"
domain="[('responsible_id', '=', uid)]"
/>
</field>
</search>
</field>
</record>
<record id="view_inventory_graph" model="ir.ui.view">