[IMP] stock_location_bin_name: black, isort

This commit is contained in:
Guewen Baconnier
2019-12-19 11:48:41 +01:00
committed by Hai Lang
parent 8af14c98a2
commit 1d2f33d966
2 changed files with 21 additions and 26 deletions

View File

@@ -3,20 +3,15 @@
# Copyright 2019 Camptocamp SA # Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
{ {
'name': 'Stock Location Bin Name', "name": "Stock Location Bin Name",
'version': '12.0.1.0.0', "version": "12.0.1.0.0",
'author': "BCIM, Okia, Camptocamp, Odoo Community Association (OCA)", "author": "BCIM, Okia, Camptocamp, Odoo Community Association (OCA)",
'website': "https://github.com/OCA/stock-logistics-warehouse", "website": "https://github.com/OCA/stock-logistics-warehouse",
'summary': "Compute bin stock location name automatically", "summary": "Compute bin stock location name automatically",
'category': 'Stock Management', "category": "Stock Management",
'depends': [ "depends": ["stock_location_zone", "stock_location_attribute"],
'stock_location_zone', "data": ["views/stock_location.xml"],
'stock_location_attribute', "installable": True,
], "development_status": "Alpha",
'data': [ "license": "AGPL-3",
'views/stock_location.xml',
],
'installable': True,
'development_status': 'Alpha',
'license': 'AGPL-3',
} }

View File

@@ -7,30 +7,30 @@ from odoo import api, fields, models
class StockLocation(models.Model): class StockLocation(models.Model):
_inherit = 'stock.location' _inherit = "stock.location"
location_name_format = fields.Char( location_name_format = fields.Char(
'Location Name Format', "Location Name Format",
help="Format string that will compute the name of the location. " help="Format string that will compute the name of the location. "
"Use location fields. Example: " "Use location fields. Example: "
"'{area}-{corridor:0>2}.{rack:0>3}" "'{area}-{corridor:0>2}.{rack:0>3}"
".{level:0>2}'") ".{level:0>2}'",
)
area = fields.Char( area = fields.Char(
string='Area', string="Area",
# Field used for _onchange_attribute_compute_name, so we # Field used for _onchange_attribute_compute_name, so we
# have the name in the record's cache. Does not need to be # have the name in the record's cache. Does not need to be
# stored as we already have 'area_location_id' # stored as we already have 'area_location_id'
related='area_location_id.name', related="area_location_id.name",
readonly=True, readonly=True,
) )
@api.multi @api.multi
@api.onchange('corridor', 'row', 'rack', 'level', @api.onchange("corridor", "row", "rack", "level", "posx", "posy", "posz")
'posx', 'posy', 'posz')
def _onchange_attribute_compute_name(self): def _onchange_attribute_compute_name(self):
for location in self: for location in self:
if not location.location_kind == 'bin': if not location.location_kind == "bin":
continue continue
area = location area = location
while area and not area.location_name_format: while area and not area.location_name_format: