diff --git a/setup/stock_location_bin_name/odoo/addons/stock_location_bin_name b/setup/stock_location_bin_name/odoo/addons/stock_location_bin_name new file mode 120000 index 000000000..cb6599b26 --- /dev/null +++ b/setup/stock_location_bin_name/odoo/addons/stock_location_bin_name @@ -0,0 +1 @@ +../../../../stock_location_bin_name \ No newline at end of file diff --git a/setup/stock_location_bin_name/setup.py b/setup/stock_location_bin_name/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_location_bin_name/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_location_bin_name/README.rst b/stock_location_bin_name/README.rst new file mode 100644 index 000000000..80c4b2640 --- /dev/null +++ b/stock_location_bin_name/README.rst @@ -0,0 +1,87 @@ +======================= +Stock Location Bin Name +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/14.0/stock_location_bin_name + :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-14-0/stock-logistics-warehouse-14-0-stock_location_bin_name + :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/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows to compute automatically Bin location names based on +locations attributes. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* BCIM +* Okia +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Syvain Van Hoof (Okia sprl) +* Jacques-Etienne Baudoux (BCIM) +* Guewen Baconnier (Camptocamp) +* Akim Juillerat +* Phuc Tran Thanh + +Other credits +~~~~~~~~~~~~~ + +The development of this module has been financially supported by: + +* Camptocamp + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_location_bin_name/__init__.py b/stock_location_bin_name/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_location_bin_name/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_location_bin_name/__manifest__.py b/stock_location_bin_name/__manifest__.py new file mode 100644 index 000000000..57a3dabd8 --- /dev/null +++ b/stock_location_bin_name/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2017 Syvain Van Hoof (Okia sprl) +# Copyright 2016-2019 Jacques-Etienne Baudoux (BCIM) +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +{ + "name": "Stock Location Bin Name", + "version": "14.0.1.0.0", + "author": "BCIM, Okia, Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "summary": "Compute bin stock location name automatically", + "category": "Stock Management", + "depends": ["stock_location_zone", "stock_location_position"], + "data": ["views/stock_location.xml"], + "installable": True, + "development_status": "Beta", + "license": "AGPL-3", +} diff --git a/stock_location_bin_name/i18n/stock_location_bin_name.pot b/stock_location_bin_name/i18n/stock_location_bin_name.pot new file mode 100644 index 000000000..2ced5544b --- /dev/null +++ b/stock_location_bin_name/i18n/stock_location_bin_name.pot @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_location_bin_name +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_location_bin_name +#: model:ir.model.fields,help:stock_location_bin_name.field_stock_location__location_name_format +msgid "" +"Format string that will compute the name of the location. Use location fields. Example: '{area}-{corridor:0>2}.{rack:0>3}.{level:0>2}'\n" +"Missing fields are replaced by '~' and formatting errors by '!'." +msgstr "" + +#. module: stock_location_bin_name +#: model:ir.model,name:stock_location_bin_name.model_stock_location +msgid "Inventory Locations" +msgstr "" + +#. module: stock_location_bin_name +#: model:ir.model.fields,field_description:stock_location_bin_name.field_stock_location__location_name_format +msgid "Location Name Format" +msgstr "" diff --git a/stock_location_bin_name/models/__init__.py b/stock_location_bin_name/models/__init__.py new file mode 100644 index 000000000..88493e35d --- /dev/null +++ b/stock_location_bin_name/models/__init__.py @@ -0,0 +1 @@ +from . import stock_location diff --git a/stock_location_bin_name/models/stock_location.py b/stock_location_bin_name/models/stock_location.py new file mode 100644 index 000000000..5a4c38b10 --- /dev/null +++ b/stock_location_bin_name/models/stock_location.py @@ -0,0 +1,67 @@ +# Copyright 2017 Syvain Van Hoof (Okia sprl) +# Copyright 2016-2019 Jacques-Etienne Baudoux (BCIM) +# Copyright 2019 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) +import string + +from odoo import api, fields, models + + +class PartialFormatter(string.Formatter): + def __init__(self, missing="~", bad_fmt="!"): + self.missing = missing + self.bad_fmt = bad_fmt + + def get_field(self, field_name, args, kwargs): + # Handle a key not found + try: + val = super().get_field(field_name, args, kwargs) + except (KeyError, AttributeError): + val = None, field_name + return val + + def format_field(self, value, spec): + # handle an invalid format + if value is None: + return self.missing + try: + return super().format_field(value, spec) + except ValueError: + if self.bad_fmt is not None: + return self.bad_fmt + else: + raise + + +class StockLocation(models.Model): + _inherit = "stock.location" + + 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}'\n" + "Missing fields are replaced by '~' and formatting errors by '!'.", + ) + + @api.onchange("corridor", "row", "rack", "level", "posx", "posy", "posz") + def _onchange_attribute_compute_name(self): + for location in self: + if not location.location_kind == "bin": + continue + area = location + while area and not area.location_name_format: + area = area.location_id + if not area: + continue + template = area.location_name_format + # We don't want to use the full browse record as it would + # give too much access to internals for the users. + # We cannot use location.read() as we may have a NewId. + # We should have the record's values in the cache at this + # point. We must be cautious not to leak an environment through + # relational fields. + values = dict(location._cache) + values["area"] = area.name + location.name = PartialFormatter().format(template, **values) diff --git a/stock_location_bin_name/readme/CONTRIBUTORS.rst b/stock_location_bin_name/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..f2f6cdfd5 --- /dev/null +++ b/stock_location_bin_name/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Syvain Van Hoof (Okia sprl) +* Jacques-Etienne Baudoux (BCIM) +* Guewen Baconnier (Camptocamp) +* Akim Juillerat +* Phuc Tran Thanh diff --git a/stock_location_bin_name/readme/CREDITS.rst b/stock_location_bin_name/readme/CREDITS.rst new file mode 100644 index 000000000..f5cc070c7 --- /dev/null +++ b/stock_location_bin_name/readme/CREDITS.rst @@ -0,0 +1,3 @@ +The development of this module has been financially supported by: + +* Camptocamp diff --git a/stock_location_bin_name/readme/DESCRIPTION.rst b/stock_location_bin_name/readme/DESCRIPTION.rst new file mode 100644 index 000000000..d868c822f --- /dev/null +++ b/stock_location_bin_name/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to compute automatically Bin location names based on +locations attributes. diff --git a/stock_location_bin_name/static/description/icon.png b/stock_location_bin_name/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_location_bin_name/static/description/icon.png differ diff --git a/stock_location_bin_name/static/description/index.html b/stock_location_bin_name/static/description/index.html new file mode 100644 index 000000000..0a755617e --- /dev/null +++ b/stock_location_bin_name/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Stock Location Bin Name + + + +
+

Stock Location Bin Name

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

This module allows to compute automatically Bin location names based on +locations attributes.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • BCIM
  • +
  • Okia
  • +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The development of this module has been financially supported by:

+
    +
  • Camptocamp
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_location_bin_name/views/stock_location.xml b/stock_location_bin_name/views/stock_location.xml new file mode 100644 index 000000000..9cbcdc769 --- /dev/null +++ b/stock_location_bin_name/views/stock_location.xml @@ -0,0 +1,16 @@ + + + + stock.location.name.format + stock.location + + + + + + + +