Skip to content

Commit

Permalink
[ADD] stock_location_zone
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaudoux authored and rousseldenis committed Dec 7, 2022
1 parent 96a8011 commit 74b2135
Show file tree
Hide file tree
Showing 13 changed files with 747 additions and 0 deletions.
85 changes: 85 additions & 0 deletions stock_location_zone/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
===================
Stock Location Zone
===================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_zone
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_location_zone
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

Add coordinate attributes on stock location.
Define picking zone with links to picking type.

**Table of contents**

.. contents::
:local:

Configuration
=============

In Inventory Settings, you must have:

* Storage Locations

Set coordinate attibute on the locations.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_zone%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* BCIM
* Okia

Contributors
~~~~~~~~~~~~

* Syvain Van Hoof (Okia sprl) <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_location_zone>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_location_zone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
23 changes: 23 additions & 0 deletions stock_location_zone/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2017 Syvain Van Hoof (Okia sprl) <[email protected]>
# Copyright 2016-2019 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# 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, Odoo Community Association (OCA)",
'website': "https://github.com/OCA/stock-logistics-warehouse",
'summary': "Add coordinate attributes on stock location. "
"Define picking zone with links to picking type.",
'category': 'Stock Management',
'depends': [
'stock',
],
'data': [
'views/stock_picking_zone.xml',
'views/stock_location.xml',
'security/ir.model.access.csv',
],
'installable': True,
'license': 'AGPL-3',
}
2 changes: 2 additions & 0 deletions stock_location_zone/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import stock_picking_zone
from . import stock_location
78 changes: 78 additions & 0 deletions stock_location_zone/models/stock_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2017 Sylvain Van Hoof <[email protected]>
# Copyright 2018-2019 Jacques-Etienne Baudoux (BCIM sprl) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models


class StockLocation(models.Model):
_inherit = 'stock.location'

# FIXME: add in selection: shuttle, tray (module vertical lift)
kind = fields.Selection([
('zone', 'Picking Zone'),
('area', 'Area'),
('bin', 'Bin'),
],
string='Kind')

picking_zone_id = fields.Many2one(
'stock.picking.zone',
string='Picking zone')

picking_type_id = fields.Many2one(
related='picking_zone_id.pick_type_id',
help="Picking type for operations from this location",
oldname='barcode_picking_type_id')

area = fields.Char(
'Area',
compute='_compute_area', store=True,
oldname='zone')

@api.depends('name', 'kind', 'location_id.area')
def _compute_area(self):
for location in self:
if location.kind == 'area':
location.area = location.name
else:
location.area = location.location_id.area

corridor = fields.Char('Corridor', help="Street")
row = fields.Char('Row', help="Side in the street")
rack = fields.Char('Rack', oldname='shelf', help="House number")
level = fields.Char('Level', help="Height on the shelf")
posx = fields.Integer('Box (X)')
posy = fields.Integer('Box (Y)')
posz = fields.Integer('Box (Z)')

location_name_format = fields.Char(
'Location Name Format',
help="Format string that will compute the name of the location. "
"Use location fields. Example: "
"'{area}-{corridor:0>2}.{rack:0>3}"
".{level:0>2}'")

@api.multi
@api.onchange('corridor', 'row', 'rack', 'level',
'posx', 'posy', 'posz')
def _compute_name(self):
for location in self:
if not location.kind == 'bin':
continue
area = location
while not area.location_name_format:
if not area.location_id:
return
area = area.location_id
location.name = area.location_name_format\
.format(**location.read())

_sql_constraints = [
(
'unique_location_name',
'UNIQUE(name, location_id)',
_('The location name must be unique'),
)
]

25 changes: 25 additions & 0 deletions stock_location_zone/models/stock_picking_zone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2017 Syvain Van Hoof (Okia sprl) <[email protected]>
# Copyright 2017-2019 Jacques-Etienne Baudoux (BCIM sprl) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


class PickingZone(models.Model):
_name = 'stock.picking.zone'

name = fields.Char('Name', required=True, translate=True)
code = fields.Char('Code', required=True)
pick_type_id = fields.Many2one(
'stock.picking.type',
string='Pick Type',
help="Picking type for operations from this location",
)

_sql_constraints = [
(
'unique_picking_zone',
'unique (code)',
'The picking zone code must be unique',
)
]
5 changes: 5 additions & 0 deletions stock_location_zone/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In Inventory Settings, you must have:

* Storage Locations

Set coordinate attibute on the locations.
2 changes: 2 additions & 0 deletions stock_location_zone/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Syvain Van Hoof (Okia sprl) <[email protected]>
* Jacques-Etienne Baudoux (BCIM) <[email protected]>
2 changes: 2 additions & 0 deletions stock_location_zone/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add coordinate attributes on stock location.
Define picking zone with links to picking type.
3 changes: 3 additions & 0 deletions stock_location_zone/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_picking_zone,access_picking_zone,model_stock_picking_zone,base.group_user,1,0,0,0
access_picking_zone_manager,access_picking_zone_manager,model_stock_picking_zone,base.group_system,1,1,1,1
Loading

0 comments on commit 74b2135

Please sign in to comment.