diff --git a/setup/stock_picking_commercial_partner/odoo/addons/stock_picking_commercial_partner b/setup/stock_picking_commercial_partner/odoo/addons/stock_picking_commercial_partner new file mode 120000 index 000000000..ed2caab95 --- /dev/null +++ b/setup/stock_picking_commercial_partner/odoo/addons/stock_picking_commercial_partner @@ -0,0 +1 @@ +../../../../stock_picking_commercial_partner \ No newline at end of file diff --git a/setup/stock_picking_commercial_partner/setup.py b/setup/stock_picking_commercial_partner/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_picking_commercial_partner/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_picking_commercial_partner/README.rst b/stock_picking_commercial_partner/README.rst new file mode 100644 index 000000000..771f3ae78 --- /dev/null +++ b/stock_picking_commercial_partner/README.rst @@ -0,0 +1,81 @@ +=============================== +Stock Picking Commercial Entity +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/16.0/stock_picking_commercial_partner + :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-16-0/stock-logistics-warehouse-16-0-stock_picking_commercial_partner + :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/16.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When you organize the work into your warehouse you could need to search +for pickings related to a specific commercial entity. This use case could +be motivated by the fact that pickings for the same commercial entity +are usually delivered together. + +This addon add on the picking form the "Commercial Entity" field the related +partner is part of. This field is readonly and comes from the partner information. +It also allows you to quickly search for pickings related to a specific +commercial entity and to group by this field in the picking tree view. + +**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 +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Laurent Mignon + +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_picking_commercial_partner/__init__.py b/stock_picking_commercial_partner/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_picking_commercial_partner/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_commercial_partner/__manifest__.py b/stock_picking_commercial_partner/__manifest__.py new file mode 100644 index 000000000..317278162 --- /dev/null +++ b/stock_picking_commercial_partner/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Picking Commercial Entity", + "summary": """ + Add Commercial Partner on the Stock Picking""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "depends": ["stock"], + "data": [ + "views/stock_picking.xml", + ], + "demo": [], +} diff --git a/stock_picking_commercial_partner/hooks.py b/stock_picking_commercial_partner/hooks.py new file mode 100644 index 000000000..911ba2f9c --- /dev/null +++ b/stock_picking_commercial_partner/hooks.py @@ -0,0 +1,30 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from odoo.tools import sql + +_logger = logging.getLogger(__name__) + + +def pre_init_hook(cr): + """Initialise the commercial_partner_id field on stock.picking""" + if not sql.column_exists(cr, "stock_picking", "commercial_partner_id"): + _logger.info("Create column commercial_partner_id on stock_picking") + cr.execute( + """ + ALTER TABLE stock_picking ADD COLUMN commercial_partner_id integer; + """ + ) + _logger.info("Init commercial_partner_id on stock_picking") + cr.execute( + """ + UPDATE stock_picking + SET commercial_partner_id = res_partner.commercial_partner_id + FROM res_partner + WHERE + stock_picking.partner_id = res_partner.id; + """ + ) + _logger.info(f"{cr.rowcount} rows updated in stock_picking") diff --git a/stock_picking_commercial_partner/models/__init__.py b/stock_picking_commercial_partner/models/__init__.py new file mode 100644 index 000000000..ae4c27227 --- /dev/null +++ b/stock_picking_commercial_partner/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/stock_picking_commercial_partner/models/stock_picking.py b/stock_picking_commercial_partner/models/stock_picking.py new file mode 100644 index 000000000..0c1324065 --- /dev/null +++ b/stock_picking_commercial_partner/models/stock_picking.py @@ -0,0 +1,18 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockPicking(models.Model): + + _inherit = "stock.picking" + + commercial_partner_id = fields.Many2one( + comodel_name="res.partner", + string="Commercial Entity", + related="partner_id.commercial_partner_id", + store=True, + readonly=True, + depends=["partner_id"], + ) diff --git a/stock_picking_commercial_partner/readme/CONTRIBUTORS.rst b/stock_picking_commercial_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..172b2d223 --- /dev/null +++ b/stock_picking_commercial_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Laurent Mignon diff --git a/stock_picking_commercial_partner/readme/DESCRIPTION.rst b/stock_picking_commercial_partner/readme/DESCRIPTION.rst new file mode 100644 index 000000000..161a7ea47 --- /dev/null +++ b/stock_picking_commercial_partner/readme/DESCRIPTION.rst @@ -0,0 +1,9 @@ +When you organize the work into your warehouse you could need to search +for pickings related to a specific commercial entity. This use case could +be motivated by the fact that pickings for the same commercial entity +are usually delivered together. + +This addon add on the picking form the "Commercial Entity" field the related +partner is part of. This field is readonly and comes from the partner information. +It also allows you to quickly search for pickings related to a specific +commercial entity and to group by this field in the picking tree view. diff --git a/stock_picking_commercial_partner/static/description/icon.png b/stock_picking_commercial_partner/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_picking_commercial_partner/static/description/icon.png differ diff --git a/stock_picking_commercial_partner/static/description/index.html b/stock_picking_commercial_partner/static/description/index.html new file mode 100644 index 000000000..1b89f17d5 --- /dev/null +++ b/stock_picking_commercial_partner/static/description/index.html @@ -0,0 +1,426 @@ + + + + + + +Stock Picking Commercial Entity + + + +
+

Stock Picking Commercial Entity

+ + +

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

+

When you organize the work into your warehouse you could need to search +for pickings related to a specific commercial entity. This use case could +be motivated by the fact that pickings for the same commercial entity +are usually delivered together.

+

This addon add on the picking form the “Commercial Entity” field the related +partner is part of. This field is readonly and comes from the partner information. +It also allows you to quickly search for pickings related to a specific +commercial entity and to group by this field in the picking tree view.

+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

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_picking_commercial_partner/views/stock_picking.xml b/stock_picking_commercial_partner/views/stock_picking.xml new file mode 100644 index 000000000..90b67b365 --- /dev/null +++ b/stock_picking_commercial_partner/views/stock_picking.xml @@ -0,0 +1,53 @@ + + + + + + stock.picking.form (in stock_picking_commercial_partner) + stock.picking + + + + + + + + + + stock.picking.search (in stock_picking_commercial_partner) + stock.picking + + + + + + + + + + + + + stock.picking.tree (in stock_picking_commercial_partner) + stock.picking + + + + + + + + +