mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[ADD][12.0] stock_generate_putaway_from_inventory: Add to 12.0
fixup! Simplified exceptions in case inventory is not validated or inventory's location doesn't have a putaway strategy
This commit is contained in:
committed by
Pierrick Brun
parent
fd8977714c
commit
ef0ef6d115
@@ -13,13 +13,13 @@ Stock Generate Putaway from Inventory
|
|||||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-akretion%2Fak--odoo--incubator-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-oca%2Fstock--logistics--warehouse-lightgray.png?logo=github
|
||||||
:target: https://github.com/akretion/ak-odoo-incubator/tree/10.0/stock_generate_putaway_from_inventory
|
:target: https://github.com/oca/stock-logistics-warehouse/tree/12.0/stock_generate_putaway_from_inventory
|
||||||
:alt: akretion/ak-odoo-incubator
|
:alt: oca/stock-logistics-warehouse
|
||||||
|
|
||||||
|badge1| |badge2| |badge3|
|
|badge1| |badge2| |badge3|
|
||||||
|
|
||||||
Generates Product Putaway Location from an inventory.
|
Synchronize a Product Putaway Location from an inventory. Note that this module assumes that there is a one-to-one correspondence between the location and putaway strategy, and if the location currently has no putaway strategy, an error will be raised.
|
||||||
|
|
||||||
**Table of contents**
|
**Table of contents**
|
||||||
|
|
||||||
@@ -29,28 +29,17 @@ Generates Product Putaway Location from an inventory.
|
|||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Before using this module you should specify a putaway strategy on the stock location
|
|
||||||
you want to generate putaway for. You can find similar instructions on the
|
|
||||||
stock_putaway_product module which is a dependency.
|
|
||||||
|
|
||||||
From a validated stock adjustment, use action -> Generate putaway per product.
|
From a validated stock adjustment, use action -> Generate putaway per product.
|
||||||
|
|
||||||
Once this is done, the products of the stock adjustment without putaway locations
|
The end result is that the location's putaway strategy will be updated, so that all products (and their locations) from the inventory will show up on the putaway strategy.
|
||||||
will have one of the strategy defined on the inventory's location.
|
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
At the moment, the module only creates putaway locations and does not update
|
|
||||||
the existing ones. It could be interesing to do so but can be destructive as well
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Bugs are tracked on `GitHub Issues <https://github.com/akretion/ak-odoo-incubator/issues>`_.
|
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.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/akretion/ak-odoo-incubator/issues/new?body=module:%20stock_generate_putaway_from_inventory%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/oca/stock-logistics-warehouse/issues/new?body=module:%20stock_generate_putaway_from_inventory%0Aversion:%2012.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.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@@ -65,11 +54,31 @@ Authors
|
|||||||
Contributors
|
Contributors
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
Pierrick Brun <pierrick.brun@akretion.com> (akretion.com)
|
* Pierrick Brun <pierrick.brun@akretion.com>
|
||||||
|
* David Beal <david.beal@akretion.com>
|
||||||
|
* Sébastien Beau <sebastien.beau@akretion.com>
|
||||||
|
* Kevin Khao <kevin.khao@akretion.com>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
This module is part of the `akretion/ak-odoo-incubator <https://github.com/akretion/ak-odoo-incubator/tree/10.0/stock_generate_putaway_from_inventory>`_ project on GitHub.
|
.. |maintainer-pierrickbrun| image:: https://github.com/pierrickbrun.png?size=40px
|
||||||
|
:target: https://github.com/pierrickbrun
|
||||||
|
:alt: pierrickbrun
|
||||||
|
.. |maintainer-bealdav| image:: https://github.com/bealdav.png?size=40px
|
||||||
|
:target: https://github.com/bealdav
|
||||||
|
:alt: bealdav
|
||||||
|
.. |maintainer-sebastienbeau| image:: https://github.com/sebastienbeau.png?size=40px
|
||||||
|
:target: https://github.com/sebastienbeau
|
||||||
|
:alt: sebastienbeau
|
||||||
|
.. |maintainer-kevinkhao| image:: https://github.com/kevinkhao.png?size=40px
|
||||||
|
:target: https://github.com/kevinkhao
|
||||||
|
:alt: kevinkhao
|
||||||
|
|
||||||
|
Current maintainers:
|
||||||
|
|
||||||
|
|maintainer-pierrickbrun| |maintainer-bealdav| |maintainer-sebastienbeau| |maintainer-kevinkhao|
|
||||||
|
|
||||||
|
This module is part of the `oca/stock-logistics-warehouse <https://github.com/oca/stock-logistics-warehouse/tree/12.0/stock_generate_putaway_from_inventory>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute.
|
You are welcome to contribute.
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from . import models
|
from . import models
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016-18 Akretion
|
# Copyright 2016-18 Akretion
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "Stock Generate Putaway from Inventory",
|
"name": "Stock Generate Putaway from Inventory",
|
||||||
"summary": "generate Putaway locations per Product deduced from inventory",
|
"summary": "Generate Putaway locations per Product deduced from Inventory",
|
||||||
"version": "10.0.1.0.1",
|
"version": "12.0.1.0.0",
|
||||||
"author": "Akretion",
|
"author": "Akretion, Odoo Community Association (OCA)",
|
||||||
"category": "Warehouse",
|
"category": "Warehouse",
|
||||||
"depends": ["stock_putaway_product"],
|
"depends": ["stock"],
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"data": ["views/stock_inventory.xml",],
|
"data": ["views/stock_inventory.xml"],
|
||||||
"installable": True,
|
"installable": True,
|
||||||
|
"maintainers": ["pierrickbrun", "bealdav", "sebastienbeau", "kevinkhao"],
|
||||||
}
|
}
|
||||||
|
|||||||
40
stock_generate_putaway_from_inventory/i18n/fr.po
Normal file
40
stock_generate_putaway_from_inventory/i18n/fr.po
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * stock_generate_putaway_from_inventory
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2020-02-26 13:48+0000\n"
|
||||||
|
"PO-Revision-Date: 2020-02-26 14:53+0100\n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
"Language: fr\n"
|
||||||
|
"X-Generator: Poedit 2.0.6\n"
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: model:ir.actions.server,name:stock_generate_putaway_from_inventory.action_generate_putaway_strategy
|
||||||
|
msgid "Generate putaway strategies"
|
||||||
|
msgstr "Générer les rangements"
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: model:ir.model,name:stock_generate_putaway_from_inventory.model_stock_inventory
|
||||||
|
msgid "Inventory"
|
||||||
|
msgstr "Inventaire"
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: code:addons/stock_generate_putaway_from_inventory/models/stock_inventory.py:29
|
||||||
|
#, python-format
|
||||||
|
msgid "Some inventories are not validated. Please validate the following inventories: "
|
||||||
|
msgstr "Certains inventaires ne sont pas validés. Veuillez valider les inventaires suivants: "
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: code:addons/stock_generate_putaway_from_inventory/models/stock_inventory.py:22
|
||||||
|
#, python-format
|
||||||
|
msgid "Some locations don't have a putaway strategy. Please set a putaway strategy for the locations: "
|
||||||
|
msgstr "Certains emplacements n'ont pas de stratégie de rangement. Veuillez choisir une stratégie de rangement pour les emplacements suivants: "
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * stock_generate_putaway_from_inventory
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 12.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"POT-Creation-Date: 2020-02-26 13:47+0000\n"
|
||||||
|
"PO-Revision-Date: 2020-02-26 13:47+0000\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_generate_putaway_from_inventory
|
||||||
|
#: model:ir.actions.server,name:stock_generate_putaway_from_inventory.action_generate_putaway_strategy
|
||||||
|
msgid "Generate putaway strategies"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: model:ir.model,name:stock_generate_putaway_from_inventory.model_stock_inventory
|
||||||
|
msgid "Inventory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: code:addons/stock_generate_putaway_from_inventory/models/stock_inventory.py:29
|
||||||
|
#, python-format
|
||||||
|
msgid "Some inventories are not validated. Please validate the following inventories: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: stock_generate_putaway_from_inventory
|
||||||
|
#: code:addons/stock_generate_putaway_from_inventory/models/stock_inventory.py:22
|
||||||
|
#, python-format
|
||||||
|
msgid "Some locations don't have a putaway strategy. Please set a putaway strategy for the locations: "
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
@@ -1,5 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016-18 Akretion
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from . import stock_inventory
|
from . import stock_inventory
|
||||||
|
|||||||
@@ -1,74 +1,61 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2018 Akretion
|
# © 2018 Akretion
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import models, api, _
|
from odoo import models, _
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class StockLocation(models.Model):
|
|
||||||
_inherit = "stock.location"
|
|
||||||
|
|
||||||
def _get_putaway_strategy(self):
|
|
||||||
if self.putaway_strategy_id:
|
|
||||||
return self.putaway_strategy_id
|
|
||||||
elif self.location_id:
|
|
||||||
return self.location_id._get_putaway_strategy()
|
|
||||||
|
|
||||||
|
|
||||||
class StockInventory(models.Model):
|
class StockInventory(models.Model):
|
||||||
_inherit = "stock.inventory"
|
_inherit = "stock.inventory"
|
||||||
|
|
||||||
@api.multi
|
def action_generate_putaway_strategy(self):
|
||||||
def generate_putaway_strategy(self):
|
|
||||||
putaway_locations = {}
|
|
||||||
for inventory in self:
|
for inventory in self:
|
||||||
if self.state != "done":
|
inventory._generate_putaway_strategy()
|
||||||
raise UserError(
|
|
||||||
_("Please, validate the stock adjustment before")
|
|
||||||
)
|
|
||||||
strategy = self.location_id._get_putaway_strategy()
|
|
||||||
if not strategy:
|
|
||||||
raise UserError(
|
|
||||||
_(
|
|
||||||
"Please, specify a Putaway Strategy "
|
|
||||||
"on the inventory's location (or a parent one)"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
putaway_locations.update(self._prepare_putaway_locations(strategy))
|
|
||||||
for putaway_location in putaway_locations.values():
|
|
||||||
putaway_location.pop("qty")
|
|
||||||
self.env["stock.product.putaway.strategy"].create(putaway_location)
|
|
||||||
|
|
||||||
def _prepare_putaway_locations(self, strategy):
|
def _get_putaway_strategy(self, loc):
|
||||||
self.ensure_one()
|
if loc.putaway_strategy_id:
|
||||||
putaway_locations = {}
|
return loc.putaway_strategy_id
|
||||||
|
elif loc.location_id:
|
||||||
|
return self._get_putaway_strategy(loc.location_id)
|
||||||
|
|
||||||
|
def _update_product_putaway_strategy(self, inventory_line, strategy):
|
||||||
|
putaway_line_obj = self.env["stock.fixed.putaway.strat"]
|
||||||
|
putaway_line = putaway_line_obj.search(
|
||||||
|
[
|
||||||
|
("product_id", "=", inventory_line.product_id.id),
|
||||||
|
("putaway_id", "=", strategy.id),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if putaway_line:
|
||||||
|
putaway_line.write(
|
||||||
|
{"fixed_location_id": inventory_line.location_id.id}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
putaway_line_obj.create(
|
||||||
|
{
|
||||||
|
"product_id": inventory_line.product_id.id,
|
||||||
|
"fixed_location_id": inventory_line.location_id.id,
|
||||||
|
"putaway_id": strategy.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def _generate_putaway_strategy(self):
|
||||||
|
if self.state != "done":
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"Please validate the inventory before generating "
|
||||||
|
"the putaway strategy."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
putaway = self._get_putaway_strategy(self.location_id)
|
||||||
|
if not putaway:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"Inventory location doesn't have a putaway strategy. "
|
||||||
|
"Please set a putaway strategy on the inventory's "
|
||||||
|
"location."
|
||||||
|
)
|
||||||
|
)
|
||||||
for line in self.line_ids:
|
for line in self.line_ids:
|
||||||
if line.product_id.product_putaway_ids:
|
if line.product_qty > 0:
|
||||||
continue
|
self._update_product_putaway_strategy(line, putaway)
|
||||||
if (
|
|
||||||
line.product_id.id not in putaway_locations
|
|
||||||
or line.product_qty
|
|
||||||
> putaway_locations[line.product_id.id]["qty"]
|
|
||||||
):
|
|
||||||
# If there is several lines for a product, we will use the
|
|
||||||
# one having more products
|
|
||||||
putaway_locations[
|
|
||||||
line.product_id.id
|
|
||||||
] = line._prepare_putaway_location(strategy)
|
|
||||||
return putaway_locations
|
|
||||||
|
|
||||||
|
|
||||||
class StockInventoryLine(models.Model):
|
|
||||||
_inherit = "stock.inventory.line"
|
|
||||||
|
|
||||||
def _prepare_putaway_location(self, strategy):
|
|
||||||
self.ensure_one()
|
|
||||||
res = {
|
|
||||||
"qty": self.product_qty,
|
|
||||||
"product_product_id": self.product_id.id,
|
|
||||||
"product_tmpl_id": self.product_id.product_tmpl_id.id,
|
|
||||||
"fixed_location_id": self.location_id.id,
|
|
||||||
"putaway_id": strategy.id,
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
Pierrick Brun <pierrick.brun@akretion.com> (akretion.com)
|
* Pierrick Brun <pierrick.brun@akretion.com>
|
||||||
|
* David Beal <david.beal@akretion.com>
|
||||||
|
* Sébastien Beau <sebastien.beau@akretion.com>
|
||||||
|
* Kevin Khao <kevin.khao@akretion.com>
|
||||||
@@ -1 +1 @@
|
|||||||
Generates Product Putaway Location from an inventory.
|
Synchronize a Product Putaway Location from an inventory. Note that this module assumes that there is a one-to-one correspondence between the location and putaway strategy, and if the location currently has no putaway strategy, an error will be raised.
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
At the moment, the module only creates putaway locations and does not update
|
|
||||||
the existing ones. It could be interesing to do so but can be destructive as well
|
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
Before using this module you should specify a putaway strategy on the stock location
|
|
||||||
you want to generate putaway for. You can find similar instructions on the
|
|
||||||
stock_putaway_product module which is a dependency.
|
|
||||||
|
|
||||||
From a validated stock adjustment, use action -> Generate putaway per product.
|
From a validated stock adjustment, use action -> Generate putaway per product.
|
||||||
|
|
||||||
Once this is done, the products of the stock adjustment without putaway locations
|
The end result is that the location's putaway strategy will be updated, so that all products (and their locations) from the inventory will show up on the putaway strategy.
|
||||||
will have one of the strategy defined on the inventory's location.
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||||
<title>Stock Generate Putaway from Inventory</title>
|
<title>Stock Generate Putaway from Inventory</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
@@ -367,59 +367,56 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<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/akretion/ak-odoo-incubator/tree/10.0/stock_generate_putaway_from_inventory"><img alt="akretion/ak-odoo-incubator" src="https://img.shields.io/badge/github-akretion%2Fak--odoo--incubator-lightgray.png?logo=github" /></a></p>
|
<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/12.0/stock_generate_putaway_from_inventory"><img alt="oca/stock-logistics-warehouse" src="https://img.shields.io/badge/github-oca%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a></p>
|
||||||
<p>Generates Product Putaway Location from an inventory.</p>
|
<p>Synchronize a Product Putaway Location from an inventory. Note that this module assumes that there is a one-to-one correspondence between the location and putaway strategy, and if the location currently has no putaway strategy, an error will be raised.</p>
|
||||||
<p><strong>Table of contents</strong></p>
|
<p><strong>Table of contents</strong></p>
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
|
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
|
||||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
|
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
|
||||||
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
|
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
|
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
||||||
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
|
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
|
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
|
||||||
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="usage">
|
<div class="section" id="usage">
|
||||||
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
|
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
|
||||||
<p>Before using this module you should specify a putaway strategy on the stock location
|
|
||||||
you want to generate putaway for. You can find similar instructions on the
|
|
||||||
stock_putaway_product module which is a dependency.</p>
|
|
||||||
<p>From a validated stock adjustment, use action -> Generate putaway per product.</p>
|
<p>From a validated stock adjustment, use action -> Generate putaway per product.</p>
|
||||||
<p>Once this is done, the products of the stock adjustment without putaway locations
|
<p>The end result is that the location’s putaway strategy will be updated, so that all products (and their locations) from the inventory will show up on the putaway strategy.</p>
|
||||||
will have one of the strategy defined on the inventory’s location.</p>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="known-issues-roadmap">
|
|
||||||
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
|
|
||||||
<p>At the moment, the module only creates putaway locations and does not update
|
|
||||||
the existing ones. It could be interesing to do so but can be destructive as well</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/akretion/ak-odoo-incubator/issues">GitHub Issues</a>.
|
<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.
|
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
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/akretion/ak-odoo-incubator/issues/new?body=module:%20stock_generate_putaway_from_inventory%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/oca/stock-logistics-warehouse/issues/new?body=module:%20stock_generate_putaway_from_inventory%0Aversion:%2012.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>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
|
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
|
||||||
<div class="section" id="authors">
|
<div class="section" id="authors">
|
||||||
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>Akretion</li>
|
<li>Akretion</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||||
<p>Pierrick Brun <<a class="reference external" href="mailto:pierrick.brun@akretion.com">pierrick.brun@akretion.com</a>> (akretion.com)</p>
|
<ul class="simple">
|
||||||
|
<li>Pierrick Brun <<a class="reference external" href="mailto:pierrick.brun@akretion.com">pierrick.brun@akretion.com</a>></li>
|
||||||
|
<li>David Beal <<a class="reference external" href="mailto:david.beal@akretion.com">david.beal@akretion.com</a>></li>
|
||||||
|
<li>Sébastien Beau <<a class="reference external" href="mailto:sebastien.beau@akretion.com">sebastien.beau@akretion.com</a>></li>
|
||||||
|
<li>Kevin Khao <<a class="reference external" href="mailto:kevin.khao@akretion.com">kevin.khao@akretion.com</a>></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/akretion/ak-odoo-incubator/tree/10.0/stock_generate_putaway_from_inventory">akretion/ak-odoo-incubator</a> project on GitHub.</p>
|
<p>Current maintainers:</p>
|
||||||
|
<p><a class="reference external" href="https://github.com/pierrickbrun"><img alt="pierrickbrun" src="https://github.com/pierrickbrun.png?size=40px" /></a> <a class="reference external" href="https://github.com/bealdav"><img alt="bealdav" src="https://github.com/bealdav.png?size=40px" /></a> <a class="reference external" href="https://github.com/sebastienbeau"><img alt="sebastienbeau" src="https://github.com/sebastienbeau.png?size=40px" /></a> <a class="reference external" href="https://github.com/kevinkhao"><img alt="kevinkhao" src="https://github.com/kevinkhao.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/12.0/stock_generate_putaway_from_inventory">oca/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute.</p>
|
<p>You are welcome to contribute.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2016-18 Akretion
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from . import test_generate_putaway
|
from . import test_generate_putaway
|
||||||
|
|||||||
@@ -1,42 +1,80 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright Akretion
|
||||||
# Copyright 2016-18 Akretion
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class TestGeneratePutaway(TransactionCase):
|
class TestGeneratePutaway(TransactionCase):
|
||||||
"""Test that the putaway locations are updated when the method is used"""
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
def test_generate(self):
|
ref = self.env.ref
|
||||||
"""Test default methods"""
|
# demo data
|
||||||
self.product_10 = self.env.ref("product.product_product_10")
|
self.inventory_location = ref("stock.stock_location_stock")
|
||||||
self.product_25 = self.env.ref("product.product_product_25")
|
self.inventory = self.env["stock.inventory"].create(
|
||||||
inventory = self.env.ref("stock.stock_inventory_0")
|
|
||||||
self.env["stock.inventory.line"].create(
|
|
||||||
{
|
{
|
||||||
"product_id": self.product_25.id,
|
"name": "example inventory",
|
||||||
"product_uom_id": self.ref("product.product_uom_unit"),
|
"location_id": self.inventory_location.id,
|
||||||
"inventory_id": inventory.id,
|
|
||||||
"product_qty": 1.0,
|
|
||||||
"location_id": self.ref("stock.stock_location_components"),
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
inventory.generate_putaway_strategy()
|
self.inventory_line_1_product = ref("product.product_product_24")
|
||||||
self.assertEquals(
|
self.inventory_line_1_location = ref("stock.stock_location_14")
|
||||||
len(self.product_25.product_putaway_ids),
|
self.inventory_line_1 = self.env["stock.inventory.line"].create(
|
||||||
1,
|
{
|
||||||
"pas le bon nombre de putaway strategy créées",
|
"product_id": self.inventory_line_1_product.id,
|
||||||
|
"location_id": self.inventory_line_1_location.id,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
self.assertEquals(
|
self.irrelevant_location = ref("stock.stock_location_customers")
|
||||||
self.product_10.product_putaway_ids.fixed_location_id.id,
|
|
||||||
self.ref("stock.stock_location_components"),
|
def test_error_not_validated(self):
|
||||||
|
putaway = self.env["product.putaway"].create(
|
||||||
|
{"name": "Putaway example"}
|
||||||
)
|
)
|
||||||
self.assertEquals(
|
self.inventory.putaway_strategy_id = putaway
|
||||||
self.product_10.product_putaway_ids.putaway_id.id,
|
self.inventory.action_cancel_draft()
|
||||||
self.ref("stock_putaway_product.product_putaway_per_product_wh"),
|
with self.assertRaises(ValidationError):
|
||||||
|
self.inventory.action_generate_putaway_strategy()
|
||||||
|
|
||||||
|
def test_error_location_has_no_putaway_strategy(self):
|
||||||
|
self.inventory_location.putaway_strategy_id = self.env[
|
||||||
|
"product.putaway"
|
||||||
|
]
|
||||||
|
self.inventory.action_start()
|
||||||
|
self.inventory.action_validate()
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
self.inventory.action_generate_putaway_strategy()
|
||||||
|
|
||||||
|
def test_putaway_line_location_update(self):
|
||||||
|
putaway = self.env["product.putaway"].create(
|
||||||
|
{"name": "Putaway example"}
|
||||||
)
|
)
|
||||||
self.assertEquals(
|
putaway_line_1 = self.env["stock.fixed.putaway.strat"].create(
|
||||||
self.product_25.product_putaway_ids.fixed_location_id.id,
|
{
|
||||||
self.ref("stock.stock_location_14"),
|
"putaway_id": putaway.id,
|
||||||
|
"fixed_location_id": self.irrelevant_location.id,
|
||||||
|
"product_id": self.inventory_line_1_product.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.inventory_location.putaway_strategy_id = putaway
|
||||||
|
self.inventory.action_start()
|
||||||
|
self.inventory.action_validate()
|
||||||
|
self.inventory.action_generate_putaway_strategy()
|
||||||
|
self.assertEqual(
|
||||||
|
putaway_line_1.fixed_location_id, self.inventory_line_1_location
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_putaway_line_location_create(self):
|
||||||
|
putaway = self.env["product.putaway"].create(
|
||||||
|
{"name": "Putaway example"}
|
||||||
|
)
|
||||||
|
self.inventory_location.putaway_strategy_id = putaway
|
||||||
|
self.inventory.action_start()
|
||||||
|
self.inventory.action_validate()
|
||||||
|
self.inventory.action_generate_putaway_strategy()
|
||||||
|
putaway_line = putaway.product_location_ids.filtered(
|
||||||
|
lambda r: r.product_id == self.inventory_line_1_product
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
putaway_line.fixed_location_id, self.inventory_line_1_location
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,24 +1,14 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<odoo>
|
<openerp>
|
||||||
|
<data>
|
||||||
<record model="ir.actions.server" id="generate_putaway_from_inventory_act">
|
<record id="action_generate_putaway_strategy" model="ir.actions.server">
|
||||||
<field name="name">Generate putaway per product</field>
|
<field name="name">Generate putaway strategies</field>
|
||||||
<field name="model_id" ref="model_stock_inventory"/>
|
<field name="model_id" ref="model_stock_inventory"/>
|
||||||
<field name="type">ir.actions.server</field>
|
<field name="binding_model_id" ref="stock.model_stock_inventory"/>
|
||||||
<field name="condition">True</field>
|
<field name="state">code</field>
|
||||||
<field name="code">
|
<field name="code">
|
||||||
action = model.browse(env.context['active_ids']).generate_putaway_strategy()
|
records.action_generate_putaway_strategy()
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
</data>
|
||||||
<record model="ir.values" id="generate_putaway_from_inventory_act_values">
|
</openerp>
|
||||||
<field name="name">Generate putaway per product</field>
|
|
||||||
<field name="action_id" ref="generate_putaway_from_inventory_act" />
|
|
||||||
<field name="value" eval="'ir.actions.server,' + str(ref('generate_putaway_from_inventory_act'))" />
|
|
||||||
<field name="key">action</field>
|
|
||||||
<field name="model_id" ref="model_stock_inventory"/>
|
|
||||||
<field name="model">stock.inventory</field>
|
|
||||||
<field name="key2">client_action</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
</odoo>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user