[IMP] stock location cleanup
Here we are cleaning some stuff in locations closes odoo/odoo#28449
This commit is contained in:
@@ -32,12 +32,6 @@
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
|
||||
<record id="location_procurement" model="stock.location">
|
||||
<field name="name">Procurements</field>
|
||||
<field name="location_id" ref="stock_location_locations_virtual"/>
|
||||
<field name="usage">procurement</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
<record id="stock_location_suppliers" model="stock.location">
|
||||
<field name="name">Vendors</field>
|
||||
<field name="location_id" ref="stock_location_locations_partner"/>
|
||||
|
||||
@@ -7,41 +7,6 @@
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Resource: stock.location -->
|
||||
|
||||
<record id="stock_location_3" model="stock.location">
|
||||
<field name="name">IT Vendors</field>
|
||||
<field name="location_id" ref="stock_location_suppliers"/>
|
||||
<field name="usage">supplier</field>
|
||||
<field name="barcode">2601985</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
<record id="stock_location_4" model="stock.location">
|
||||
<field name="name">Big Vendors</field>
|
||||
<field name="location_id" ref="stock_location_3"/>
|
||||
<field name="usage">supplier</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
<record id="stock_location_5" model="stock.location">
|
||||
<field name="name">Generic IT Vendors</field>
|
||||
<field name="location_id" ref="stock_location_3"/>
|
||||
<field name="usage">supplier</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
<record id="stock_location_7" model="stock.location">
|
||||
<field name="name">European Customers</field>
|
||||
<field name="location_id" ref="stock_location_customers"/>
|
||||
<field name="usage">customer</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
<record id="stock_location_8" model="stock.location">
|
||||
<field name="name">Non European Customers</field>
|
||||
<field name="location_id" ref="stock_location_customers"/>
|
||||
<field name="usage">customer</field>
|
||||
<field name="company_id"></field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Resource: stock.inventory -->
|
||||
|
||||
<record id="stock_inventory_0" model="stock.inventory">
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
<record id="stock_location_14" model="stock.location">
|
||||
<field name="name">Shelf 2</field>
|
||||
<field name="posx">0</field>
|
||||
<field name="barcode">2601985</field>
|
||||
<field name="location_id" model="stock.location"
|
||||
eval="obj().env.ref('stock.warehouse0').lot_stock_id.id"/>
|
||||
</record>
|
||||
<record id="stock_location_components" model="stock.location">
|
||||
<field name="name">Shelf 1</field>
|
||||
<field name="posx">0</field>
|
||||
<field name="barcode">2601892</field>
|
||||
<field name="location_id" model="stock.location"
|
||||
eval="obj().env.ref('stock.warehouse0').lot_stock_id.id"/>
|
||||
</record>
|
||||
|
||||
@@ -338,11 +338,6 @@ class Product(models.Model):
|
||||
res['fields']['virtual_available']['string'] = _('Future P&L')
|
||||
if fields.get('qty_available'):
|
||||
res['fields']['qty_available']['string'] = _('P&L Qty')
|
||||
elif location.usage == 'procurement':
|
||||
if fields.get('virtual_available'):
|
||||
res['fields']['virtual_available']['string'] = _('Future Qty')
|
||||
if fields.get('qty_available'):
|
||||
res['fields']['qty_available']['string'] = _('Unplanned Qty')
|
||||
elif location.usage == 'production':
|
||||
if fields.get('virtual_available'):
|
||||
res['fields']['virtual_available']['string'] = _('Future Productions')
|
||||
|
||||
@@ -33,7 +33,6 @@ class Location(models.Model):
|
||||
('internal', 'Internal Location'),
|
||||
('customer', 'Customer Location'),
|
||||
('inventory', 'Inventory Loss'),
|
||||
('procurement', 'Procurement'),
|
||||
('production', 'Production'),
|
||||
('transit', 'Transit Location')], string='Location Type',
|
||||
default='internal', index=True, required=True,
|
||||
@@ -42,14 +41,12 @@ class Location(models.Model):
|
||||
"\n* Internal Location: Physical locations inside your own warehouses,"
|
||||
"\n* Customer Location: Virtual location representing the destination location for products sent to your customers"
|
||||
"\n* Inventory Loss: Virtual location serving as counterpart for inventory operations used to correct stock levels (Physical inventories)"
|
||||
"\n* Procurement: Virtual location serving as temporary counterpart for procurement operations when the source (vendor or production) is not known yet. This location should be empty when the procurement scheduler has finished running."
|
||||
"\n* Production: Virtual counterpart location for production operations: this location consumes the raw material and produces finished products"
|
||||
"\n* Transit Location: Counterpart location that should be used in inter-company or inter-warehouses operations")
|
||||
location_id = fields.Many2one(
|
||||
'stock.location', 'Parent Location', index=True, ondelete='cascade',
|
||||
help="The parent location that includes this location. Example : The 'Dispatch Zone' is the 'Gate 1' parent location.")
|
||||
child_ids = fields.One2many('stock.location', 'location_id', 'Contains')
|
||||
partner_id = fields.Many2one('res.partner', 'Owner', help="Owner of the location if not internal")
|
||||
comment = fields.Text('Additional Information')
|
||||
posx = fields.Integer('Corridor (X)', default=0, help="Optional localization details, for information purpose only")
|
||||
posy = fields.Integer('Shelves (Y)', default=0, help="Optional localization details, for information purpose only")
|
||||
@@ -77,6 +74,11 @@ class Location(models.Model):
|
||||
else:
|
||||
self.complete_name = self.name
|
||||
|
||||
@api.onchange('usage')
|
||||
def _onchange_usage(self):
|
||||
if self.usage not in ('internal', 'inventory'):
|
||||
self.scrap_location = False
|
||||
|
||||
def write(self, values):
|
||||
if 'usage' in values and values['usage'] == 'view':
|
||||
if self.mapped('quant_ids'):
|
||||
@@ -97,6 +99,13 @@ class Location(models.Model):
|
||||
" Please unreserve the products first."
|
||||
))
|
||||
if 'active' in values:
|
||||
if values['active'] == False:
|
||||
for location in self:
|
||||
warehouses = self.env['stock.warehouse'].search([('active', '=', True), '|', ('lot_stock_id', '=', location.id), ('view_location_id', '=', location.id)])
|
||||
if warehouses:
|
||||
raise UserError(_("You cannot archive the location %s as it is"
|
||||
" used by your warehouse %s") % (location.display_name, warehouses[0].display_name))
|
||||
|
||||
if not self.env.context.get('do_not_check_quant'):
|
||||
children_location = self.env['stock.location'].with_context(active_test=False).search([('id', 'child_of', self.ids)])
|
||||
internal_children_locations = children_location.filtered(lambda l: l.usage == 'internal')
|
||||
|
||||
@@ -7,7 +7,7 @@ class TestStockLocationSearch(common.TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestStockLocationSearch, self).setUp()
|
||||
self.location = self.env['stock.location']
|
||||
self.location_barcode = self.env.ref('stock.stock_location_3')
|
||||
self.location_barcode = self.env.ref('stock.stock_location_14')
|
||||
self.location_barcode_id = self.location_barcode.id
|
||||
self.barcode = self.location_barcode.barcode
|
||||
self.name = self.location_barcode.name
|
||||
|
||||
@@ -34,9 +34,8 @@
|
||||
<group>
|
||||
<group string="Additional Information">
|
||||
<field name="usage"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
<field name="scrap_location"/>
|
||||
<field name="scrap_location" attrs="{'invisible': [('usage', 'not in', ('inventory', 'internal'))]}"/>
|
||||
<field name="return_location"/>
|
||||
</group>
|
||||
<group string="Localization" name="localization">
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
<page string="Technical Information" groups='base.group_no_one'>
|
||||
<group>
|
||||
<group string="Locations">
|
||||
<field name="view_location_id" string="Warehouse view location" readonly="1" required="0"/>
|
||||
<field name="lot_stock_id" readonly="1" required="0"/>
|
||||
<field name="wh_input_stock_loc_id" readonly="1"/>
|
||||
<field name="wh_qc_stock_loc_id" readonly="1"/>
|
||||
<field name="wh_pack_stock_loc_id" readonly="1"/>
|
||||
@@ -217,7 +219,7 @@
|
||||
<group>
|
||||
<field name="warehouse_id" widget="selection" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="product_uom" options="{'no_open': True, 'no_create': True}" groups="uom.group_uom"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations"/>
|
||||
<field name="location_id" groups="stock.group_stock_multi_locations" domain="[('usage', 'in', ('internal', 'view'))]"/>
|
||||
<field name="group_id" groups="stock.group_adv_location"/>
|
||||
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user