Define lost and found location for inventory on parent location
We remove the lost and found location on the inventory to only used one define on the warehouse or parent of the inventoried location. issue9071 review276901002
This commit is contained in:
1 parent
b434ce8e8d
commit
fe4650d885
10 files changed
+59
-32
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Define one lost and found location per warehouse
|
||||
* Show warehouse in user status if not unique
|
||||
* Add cost price revision
|
||||
* Add wizard to modify product cost price
|
||||
|
||||
+10
-10
@@ -18,13 +18,14 @@ virtually stored. The following location types are defined:
|
||||
|
||||
* Warehouse
|
||||
|
||||
Warehouses are meta-locations which define input, storage, picking and output
|
||||
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.
|
||||
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.
|
||||
|
||||
* Customer
|
||||
|
||||
@@ -261,9 +262,8 @@ of moves. It can be in one of these states:
|
||||
Inventory
|
||||
*********
|
||||
|
||||
Inventories allow to control and update stock levels. They are mainly
|
||||
composed of two locations (a Storage location and a Lost And Found
|
||||
location), and a list of inventory lines.
|
||||
Inventories allow to control and update stock levels. They are mainly composed
|
||||
of the inventoried storage location and a list of inventory lines.
|
||||
Inventory lines consist of a product and it's default unit of measure, an
|
||||
expected quantity and the real quantity (the real products on the shelves).
|
||||
|
||||
|
||||
+9
-13
@@ -37,11 +37,6 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
},
|
||||
depends=['state'],
|
||||
help="The date of the stock count.")
|
||||
lost_found = fields.Many2One(
|
||||
'stock.location', 'Lost and Found', required=True,
|
||||
domain=[('type', '=', 'lost_found')], states=_states, depends=_depends,
|
||||
help="Used for the balancing entries needed when the stock is "
|
||||
"corrected.")
|
||||
lines = fields.One2Many(
|
||||
'stock.inventory.line', 'inventory', 'Lines',
|
||||
states={
|
||||
@@ -106,6 +101,9 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
# Add index on create_date
|
||||
table.index_action('create_date', action='add')
|
||||
|
||||
# Migration from 5.4: remove lost_found
|
||||
table.not_null_action('lost_found', 'remove')
|
||||
|
||||
@staticmethod
|
||||
def default_state():
|
||||
return 'draft'
|
||||
@@ -119,13 +117,6 @@ class Inventory(Workflow, ModelSQL, ModelView):
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@classmethod
|
||||
def default_lost_found(cls):
|
||||
Location = Pool().get('stock.location')
|
||||
locations = Location.search(cls.lost_found.domain)
|
||||
if len(locations) == 1:
|
||||
return locations[0].id
|
||||
|
||||
@classmethod
|
||||
def view_attributes(cls):
|
||||
return [
|
||||
@@ -446,7 +437,12 @@ class InventoryLine(ModelSQL, ModelView):
|
||||
if delta_qty == 0.0:
|
||||
return
|
||||
from_location = self.inventory.location
|
||||
to_location = self.inventory.lost_found
|
||||
to_location = self.inventory.location.lost_found_used
|
||||
if not to_location:
|
||||
raise InventoryValidationError(
|
||||
gettext('stock.msg_inventory_location_missing_lost_found',
|
||||
inventory=self.inventory.rec_name,
|
||||
location=self.inventory.location.rec_name))
|
||||
if delta_qty < 0:
|
||||
(from_location, to_location, delta_qty) = \
|
||||
(to_location, from_location, -delta_qty)
|
||||
|
||||
+17
@@ -112,6 +112,18 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView):
|
||||
depends=['type', 'storage_location'],
|
||||
help="Where stock is picked from.\n"
|
||||
"Leave empty to use the storage location.")
|
||||
lost_found_location = fields.Many2One(
|
||||
'stock.location', "Lost and Found",
|
||||
states={
|
||||
'invisible': Eval('type') != 'warehouse',
|
||||
'readonly': ~Eval('active'),
|
||||
},
|
||||
domain=[
|
||||
('type', '=', 'lost_found'),
|
||||
],
|
||||
depends=['type', 'active'],
|
||||
help="Used, by inventories, when correcting stock levels "
|
||||
"in the warehouse.")
|
||||
quantity = fields.Function(
|
||||
fields.Float('Quantity',
|
||||
help="The amount of stock in the location."),
|
||||
@@ -304,6 +316,11 @@ class Location(DeactivableMixin, tree(), ModelSQL, ModelView):
|
||||
cls._default_warehouse_cache.set(None, warehouse)
|
||||
return warehouse
|
||||
|
||||
@property
|
||||
def lost_found_used(self):
|
||||
if self.warehouse:
|
||||
return self.warehouse.lost_found_location
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
if clause[1].startswith('!') or clause[1].startswith('not '):
|
||||
|
||||
+5
-4
@@ -194,6 +194,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">STO</field>
|
||||
<field name="type">storage</field>
|
||||
</record>
|
||||
<record model="stock.location" id="location_lost_found">
|
||||
<field name="name">Lost and Found</field>
|
||||
<field name="type">lost_found</field>
|
||||
</record>
|
||||
<record model="stock.location" id="location_warehouse">
|
||||
<field name="name">Warehouse</field>
|
||||
<field name="code">WH</field>
|
||||
@@ -201,6 +205,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="input_location" ref="location_input"/>
|
||||
<field name="output_location" ref="location_output"/>
|
||||
<field name="storage_location" ref="location_storage"/>
|
||||
<field name="lost_found_location" ref="location_lost_found"/>
|
||||
</record>
|
||||
<record model="stock.location" id="location_supplier">
|
||||
<field name="name">Supplier</field>
|
||||
@@ -212,10 +217,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="code">CUS</field>
|
||||
<field name="type">customer</field>
|
||||
</record>
|
||||
<record model="stock.location" id="location_lost_found">
|
||||
<field name="name">Lost and Found</field>
|
||||
<field name="type">lost_found</field>
|
||||
</record>
|
||||
<record model="stock.location" id="location_transit">
|
||||
<field name="name">Transit</field>
|
||||
<field name="type">storage</field>
|
||||
|
||||
@@ -41,6 +41,9 @@ because the type does not support moves and location has existing moves.</field>
|
||||
<record model="ir.message" id="msg_inventory_missing_empty_quantity">
|
||||
<field name="text">To confirm the inventory "%(inventory)s" you must select an option for empty quantity.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_inventory_location_missing_lost_found">
|
||||
<field name="text">To confirm the inventory "%(inventory)s" you must set a lost and found on a parent of location "%(location)s".</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_inventory_line_unique">
|
||||
<field name="text">Inventory line "%(line)s" is not unique on inventory "%(inventory)s".</field>
|
||||
</record>
|
||||
|
||||
@@ -28,6 +28,7 @@ Get stock locations::
|
||||
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
>>> lost_found_loc, = Location.find([('type', '=', 'lost_found')])
|
||||
|
||||
Create products::
|
||||
|
||||
@@ -170,7 +171,7 @@ Confirm the inventory::
|
||||
>>> move, = line_p1.moves
|
||||
>>> move.quantity
|
||||
1.0
|
||||
>>> move.from_location == inventory.lost_found
|
||||
>>> move.from_location == lost_found_loc
|
||||
True
|
||||
>>> move.to_location == inventory.location
|
||||
True
|
||||
@@ -230,7 +231,7 @@ Add quantity of consumable product::
|
||||
>>> move, = line.moves
|
||||
>>> move.quantity
|
||||
5.0
|
||||
>>> move.from_location == inventory.lost_found
|
||||
>>> move.from_location == lost_found_loc
|
||||
True
|
||||
>>> move.to_location == inventory.location
|
||||
True
|
||||
|
||||
@@ -28,6 +28,7 @@ Get stock locations::
|
||||
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
>>> lost_found_loc, = Location.find([('type', '=', 'lost_found')])
|
||||
|
||||
Create product::
|
||||
|
||||
@@ -83,5 +84,5 @@ Creating an inventory with empty quantities creates and empty move::
|
||||
1.0
|
||||
>>> move.from_location == inventory.location
|
||||
True
|
||||
>>> move.to_location == inventory.lost_found
|
||||
>>> move.to_location == lost_found_loc
|
||||
True
|
||||
@@ -6,15 +6,17 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="location"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<label name="lost_found"/>
|
||||
<field name="lost_found"/>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
|
||||
<label name="empty_quantity"/>
|
||||
<field name="empty_quantity"/>
|
||||
|
||||
<field name="lines" colspan="4"/>
|
||||
|
||||
<label name="state"/>
|
||||
<field name="state"/>
|
||||
<group colspan="2" col="-1" id="buttons">
|
||||
|
||||
@@ -28,5 +28,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="storage_location"/>
|
||||
<label name="picking_location"/>
|
||||
<field name="picking_location"/>
|
||||
|
||||
<label name="lost_found_location"/>
|
||||
<field name="lost_found_location"/>
|
||||
<newline/>
|
||||
|
||||
<field name="childs" colspan="4"/>
|
||||
</form>
|
||||
Reference in new issue
Block a user