changeset a9a5aecb3653 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset;node=a9a5aecb3653
description:
Allow lost and found on inventory moves
issue9156
review323431002
diffstat:
CHANGELOG | 2 ++
__init__.py | 1 +
doc/index.rst | 16 +++++++++-------
location.py | 32 ++++++++++++++++++++++++++++++++
move.py | 2 +-
shipment.py | 20 ++++++++++++++------
view/location_form.xml | 2 +-
7 files changed, 60 insertions(+), 15 deletions(-)
diffs (156 lines):
diff -r 617b75bbdae5 -r a9a5aecb3653 CHANGELOG
--- a/CHANGELOG Sun Oct 11 16:05:16 2020 +0200
+++ b/CHANGELOG Sun Oct 11 23:46:10 2020 +0200
@@ -1,3 +1,5 @@
+* Allow lost and found on inventory moves of shipments
+* Add waste locations on warehouses
* Add warning to prevent move in the future
* Add relate to open inventory lines
* Use simplified view for moves list on shipments
diff -r 617b75bbdae5 -r a9a5aecb3653 __init__.py
--- a/__init__.py Sun Oct 11 16:05:16 2020 +0200
+++ b/__init__.py Sun Oct 11 23:46:10 2020 +0200
@@ -21,6 +21,7 @@
def register():
Pool.register(
location.Location,
+ location.WarehouseWasteLocation,
location.Party,
location.PartyLocation,
location.ProductsByLocationsContext,
diff -r 617b75bbdae5 -r a9a5aecb3653 doc/index.rst
--- a/doc/index.rst Sun Oct 11 16:05:16 2020 +0200
+++ b/doc/index.rst Sun Oct 11 23:46:10 2020 +0200
@@ -19,13 +19,15 @@
* Warehouse
Warehouses are meta-locations which define input, storage, picking, output
- and lost and found locations. These locations are all of type Storage. Input
- and Output are locations where incoming an outgoing product are temporally
- stored awaiting transportation. The storage location is often the biggest
- location where products are stored for middle or long periods of time. The
- picking location is optionally where the products are picked by the customer
- shipment otherwise the storage location is used. The lost and found location
- is the location used by inventories when correcting stock levels.
+ ,lost and found and waste locations. These locations are all of type
+ Storage. Input and Output are locations where incoming an outgoing product
+ are temporally stored awaiting transportation. The storage location is often
+ the biggest location where products are stored for middle or long periods of
+ time. The picking location is optionally where the products are picked by
+ the customer shipment otherwise the storage location is used. The lost and
+ found location is the location used by inventories when correcting stock
+ levels. Waste locations are used to throw away wrong products entering the
+ warehouse.
* Customer
diff -r 617b75bbdae5 -r a9a5aecb3653 location.py
--- a/location.py Sun Oct 11 16:05:16 2020 +0200
+++ b/location.py Sun Oct 11 23:46:10 2020 +0200
@@ -19,6 +19,18 @@
from .exceptions import LocationValidationError
+class WarehouseWasteLocation(ModelSQL):
+ "Warehouse Waste Location"
+ __name__ = 'stock.location.waste'
+
+ warehouse = fields.Many2One(
+ 'stock.location', "Warehouse", required=True, ondelete='CASCADE',
+ domain=[('type', '=', 'warehouse')])
+ location = fields.Many2One(
+ 'stock.location', "Waste Location", required=True, ondelete='CASCADE',
+ domain=[('type', '=', 'lost_found')])
+
+
class Location(DeactivableMixin, tree(), ModelSQL, ModelView):
"Stock Location"
__name__ = 'stock.location'
@@ -124,6 +136,26 @@
depends=['type', 'active'],
help="Used, by inventories, when correcting stock levels "
"in the warehouse.")
+ waste_locations = fields.Many2Many(
+ 'stock.location.waste', 'warehouse', 'location', "Waste Locations",
+ states={
+ 'invisible': Eval('type') != 'warehouse',
+ },
+ domain=[
+ ('type', '=', 'lost_found'),
+ ],
+ depends=['type'],
+ help="The locations used for waste products from the warehouse.")
+ waste_warehouses = fields.Many2Many(
+ 'stock.location.waste', 'location', 'warehouse', "Waste Warehouses",
+ states={
+ 'invisible': Eval('type') != 'lost_found',
+ },
+ domain=[
+ ('type', '=', 'warehouse'),
+ ],
+ depends=['type'],
+ help="The warehouses that use the location for waste products.")
quantity = fields.Function(
fields.Float('Quantity',
help="The amount of stock in the location."),
diff -r 617b75bbdae5 -r a9a5aecb3653 move.py
--- a/move.py Sun Oct 11 16:05:16 2020 +0200
+++ b/move.py Sun Oct 11 23:46:10 2020 +0200
@@ -454,7 +454,7 @@
if from_type == 'supplier' and to_type in {'storage', 'drop'}:
return True
- if from_type == 'production':
+ if from_type == 'production' and to_type != 'lost_found':
return True
if from_type in {'storage', 'drop'} and to_type == 'customer':
return True
diff -r 617b75bbdae5 -r a9a5aecb3653 shipment.py
--- a/shipment.py Sun Oct 11 16:05:16 2020 +0200
+++ b/shipment.py Sun Oct 11 23:46:10 2020 +0200
@@ -157,9 +157,13 @@
domain=[
('from_location', '=', Eval('warehouse_input')),
If(~Eval('state').in_(['done', 'cancelled']),
- ('to_location', 'child_of',
- [Eval('warehouse_storage', -1)], 'parent'),
- (),),
+ ['OR',
+ ('to_location', 'child_of',
+ [Eval('warehouse_storage', -1)], 'parent'),
+ ('to_location.waste_warehouses', '=',
+ Eval('warehouse')),
+ ],
+ [],),
('company', '=', Eval('company')),
],
states={
@@ -1484,9 +1488,13 @@
domain=[
('from_location', '=', Eval('warehouse_input')),
If(Eval('state').in_(['received']),
- ('to_location', 'child_of',
- [Eval('warehouse_storage', -1)], 'parent'),
- ()),
+ ['OR',
+ ('to_location', 'child_of',
+ [Eval('warehouse_storage', -1)], 'parent'),
+ ('to_location.waste_warehouses', '=',
+ Eval('warehouse')),
+ ],
+ []),
('company', '=', Eval('company')),
],
states={
diff -r 617b75bbdae5 -r a9a5aecb3653 view/location_form.xml
--- a/view/location_form.xml Sun Oct 11 16:05:16 2020 +0200
+++ b/view/location_form.xml Sun Oct 11 23:46:10 2020 +0200
@@ -31,7 +31,7 @@
<label name="lost_found_location"/>
<field name="lost_found_location"/>
- <newline/>
+ <field name="waste_locations" colspan="4"/>
<field name="childs" colspan="4"/>
</form>