mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_location_zone: black, isort
This commit is contained in:
@@ -3,19 +3,15 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Stock Location Zone',
|
||||
'version': '12.0.1.0.0',
|
||||
'author': "BCIM, Okia, Camptocamp, Odoo Community Association (OCA)",
|
||||
'website': "https://github.com/OCA/stock-logistics-warehouse",
|
||||
'summary': "Classify locations with zones.",
|
||||
'category': 'Stock Management',
|
||||
'depends': [
|
||||
'stock',
|
||||
],
|
||||
'data': [
|
||||
'views/stock_location.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'development_status': 'Alpha',
|
||||
'license': 'AGPL-3',
|
||||
"name": "Stock Location Zone",
|
||||
"version": "12.0.1.0.0",
|
||||
"author": "BCIM, Okia, Camptocamp, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"summary": "Classify locations with zones.",
|
||||
"category": "Stock Management",
|
||||
"depends": ["stock"],
|
||||
"data": ["views/stock_location.xml"],
|
||||
"installable": True,
|
||||
"development_status": "Alpha",
|
||||
"license": "AGPL-3",
|
||||
}
|
||||
|
||||
@@ -3,52 +3,52 @@
|
||||
# Copyright 2019 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
_inherit = "stock.location"
|
||||
|
||||
is_zone = fields.Boolean(
|
||||
string='Is a Zone Location?',
|
||||
help='Mark to define this location as a zone',
|
||||
string="Is a Zone Location?", help="Mark to define this location as a zone"
|
||||
)
|
||||
|
||||
zone_location_id = fields.Many2one(
|
||||
'stock.location',
|
||||
string='Location Zone',
|
||||
compute='_compute_zone_location_id',
|
||||
"stock.location",
|
||||
string="Location Zone",
|
||||
compute="_compute_zone_location_id",
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
area_location_id = fields.Many2one(
|
||||
'stock.location',
|
||||
string='Location Area',
|
||||
compute='_compute_zone_location_id',
|
||||
"stock.location",
|
||||
string="Location Area",
|
||||
compute="_compute_zone_location_id",
|
||||
store=True,
|
||||
)
|
||||
|
||||
location_kind = fields.Selection(
|
||||
[
|
||||
('zone', 'Zone'),
|
||||
('area', 'Area'),
|
||||
('bin', 'Bin'),
|
||||
('stock', 'Main Stock'),
|
||||
('other', 'Other'),
|
||||
("zone", "Zone"),
|
||||
("area", "Area"),
|
||||
("bin", "Bin"),
|
||||
("stock", "Main Stock"),
|
||||
("other", "Other"),
|
||||
],
|
||||
string='Location Kind',
|
||||
compute='_compute_location_kind',
|
||||
string="Location Kind",
|
||||
compute="_compute_location_kind",
|
||||
store=True,
|
||||
help='Group location according to their kinds: '
|
||||
'* Zone: locations that are flagged as being zones '
|
||||
'* Area: locations with children that are part of a zone '
|
||||
'* Bin: locations without children that are part of a zone '
|
||||
'* Stock: internal locations whose parent is a view '
|
||||
'* Other: any other location',
|
||||
help="Group location according to their kinds: "
|
||||
"* Zone: locations that are flagged as being zones "
|
||||
"* Area: locations with children that are part of a zone "
|
||||
"* Bin: locations without children that are part of a zone "
|
||||
"* Stock: internal locations whose parent is a view "
|
||||
"* Other: any other location",
|
||||
)
|
||||
|
||||
@api.depends('is_zone', 'location_id.zone_location_id',
|
||||
'location_id.area_location_id')
|
||||
@api.depends(
|
||||
"is_zone", "location_id.zone_location_id", "location_id.area_location_id"
|
||||
)
|
||||
def _compute_zone_location_id(self):
|
||||
for location in self:
|
||||
location.zone_location_id = self.browse()
|
||||
@@ -66,48 +66,48 @@ class StockLocation(models.Model):
|
||||
else:
|
||||
location.area_location_id = location
|
||||
|
||||
@api.depends('usage', 'location_id.usage',
|
||||
'child_ids',
|
||||
'area_location_id',
|
||||
'zone_location_id')
|
||||
@api.depends(
|
||||
"usage",
|
||||
"location_id.usage",
|
||||
"child_ids",
|
||||
"area_location_id",
|
||||
"zone_location_id",
|
||||
)
|
||||
def _compute_location_kind(self):
|
||||
for location in self:
|
||||
if location.zone_location_id and not location.area_location_id:
|
||||
location.location_kind = 'zone'
|
||||
location.location_kind = "zone"
|
||||
continue
|
||||
|
||||
parent = location.location_id
|
||||
if (
|
||||
location.usage == 'internal'
|
||||
and parent.usage == 'view'
|
||||
):
|
||||
if location.usage == "internal" and parent.usage == "view":
|
||||
# Internal locations whose parent is view are main stocks
|
||||
location.location_kind = 'stock'
|
||||
location.location_kind = "stock"
|
||||
elif (
|
||||
# Internal locations having a zone and no children are bins
|
||||
location.usage == 'internal'
|
||||
location.usage == "internal"
|
||||
and location.zone_location_id
|
||||
and location.area_location_id
|
||||
and not location.child_ids
|
||||
):
|
||||
location.location_kind = 'bin'
|
||||
location.location_kind = "bin"
|
||||
elif (
|
||||
location.usage == 'internal'
|
||||
location.usage == "internal"
|
||||
and location.zone_location_id
|
||||
and location.area_location_id
|
||||
and location.child_ids
|
||||
):
|
||||
# Internal locations having a zone and children are areas
|
||||
location.location_kind = 'area'
|
||||
location.location_kind = "area"
|
||||
else:
|
||||
# All the rest are other locations
|
||||
location.location_kind = 'other'
|
||||
location.location_kind = "other"
|
||||
|
||||
@api.multi
|
||||
@api.returns('self', lambda value: value.id)
|
||||
@api.returns("self", lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
self.ensure_one()
|
||||
default = dict(default or {})
|
||||
if 'name' not in default:
|
||||
default['name'] = _("%s (copy)") % self.name
|
||||
if "name" not in default:
|
||||
default["name"] = _("%s (copy)") % self.name
|
||||
return super().copy(default=default)
|
||||
|
||||
Reference in New Issue
Block a user