From 632790829ad082e028924ac0f2f60bd2cd8cc0e5 Mon Sep 17 00:00:00 2001 From: Juany Davila Date: Mon, 20 Jun 2022 10:29:56 -0500 Subject: [PATCH] [ADD] stock_picking_show_linked: Add to 14.0 --- stock_picking_show_linked/README.rst | 77 ++++ stock_picking_show_linked/__init__.py | 1 + stock_picking_show_linked/__manifest__.py | 20 + stock_picking_show_linked/models/__init__.py | 1 + .../models/stock_picking.py | 48 ++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 5 + .../static/description/index.html | 423 ++++++++++++++++++ .../views/stock_picking.xml | 42 ++ 9 files changed, 618 insertions(+) create mode 100644 stock_picking_show_linked/README.rst create mode 100644 stock_picking_show_linked/__init__.py create mode 100644 stock_picking_show_linked/__manifest__.py create mode 100644 stock_picking_show_linked/models/__init__.py create mode 100644 stock_picking_show_linked/models/stock_picking.py create mode 100644 stock_picking_show_linked/readme/CONTRIBUTORS.rst create mode 100644 stock_picking_show_linked/readme/DESCRIPTION.rst create mode 100644 stock_picking_show_linked/static/description/index.html create mode 100644 stock_picking_show_linked/views/stock_picking.xml diff --git a/stock_picking_show_linked/README.rst b/stock_picking_show_linked/README.rst new file mode 100644 index 000000000..e83e5fbc3 --- /dev/null +++ b/stock_picking_show_linked/README.rst @@ -0,0 +1,77 @@ +========================= +Stock Picking Show Linked +========================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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_picking_show_linked + :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_picking_show_linked + :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 should allow a user to display, on smart buttons in a picking: + +* Destination pickings: the pickings associated to destination moves indicated in the moves in this picking + +* Origin pickings: the pickings associated to origin moves indicated in the moves in this picking + +**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 +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Juany Davila + +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_show_linked/__init__.py b/stock_picking_show_linked/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/stock_picking_show_linked/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_picking_show_linked/__manifest__.py b/stock_picking_show_linked/__manifest__.py new file mode 100644 index 000000000..90a580533 --- /dev/null +++ b/stock_picking_show_linked/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# Part of ForgeFlow. See LICENSE file for full copyright and licensing details. +{ + "name": "Stock Picking Show Linked", + "summary": """ + This addon allows to easily access related pickings + (in the case of chained routes) through a button + in the parent picking view. + """, + "version": "14.0.1.0.0", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse Management", + "depends": [ + "stock", + ], + "data": ["views/stock_picking.xml"], + "license": "AGPL-3", + "installable": True, +} diff --git a/stock_picking_show_linked/models/__init__.py b/stock_picking_show_linked/models/__init__.py new file mode 100644 index 000000000..ae4c27227 --- /dev/null +++ b/stock_picking_show_linked/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/stock_picking_show_linked/models/stock_picking.py b/stock_picking_show_linked/models/stock_picking.py new file mode 100644 index 000000000..227bffe38 --- /dev/null +++ b/stock_picking_show_linked/models/stock_picking.py @@ -0,0 +1,48 @@ +# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com) +# Part of ForgeFlow. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + dest_picking_count = fields.Integer(compute="_compute_picking_count") + origin_picking_count = fields.Integer(compute="_compute_picking_count") + + @api.depends("move_lines") + def _compute_picking_count(self): + for record in self: + origin_pickings = record.mapped("move_lines.move_orig_ids.picking_id") + dest_pickings = record.mapped("move_lines.move_dest_ids.picking_id") + record.origin_picking_count = len(origin_pickings) + record.dest_picking_count = len(dest_pickings) + + def _get_action_link(self, pickings): + result = self.env["ir.actions.actions"]._for_xml_id( + "stock.action_picking_tree_all" + ) + # choose the view_mode accordingly + if not pickings or len(pickings) > 1: + result["domain"] = "[('id','in',%s)]" % pickings + elif len(pickings) == 1: + res = self.env.ref("stock.view_picking_form", False) + form_view = [(res and res.id or False, "form")] + if "views" in result: + result["views"] = form_view + [ + (state, view) for state, view in result["views"] if view != "form" + ] + else: + result["views"] = form_view + result["res_id"] = pickings[0] + return result + + def action_stock_picking_origin(self): + pick_ids = self.mapped("move_lines.move_orig_ids.picking_id") + result = self._get_action_link(pick_ids.ids) + return result + + def action_stock_picking_destination(self): + pick_ids = self.mapped("move_lines.move_dest_ids.picking_id") + result = self._get_action_link(pick_ids.ids) + return result diff --git a/stock_picking_show_linked/readme/CONTRIBUTORS.rst b/stock_picking_show_linked/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..960dd0adb --- /dev/null +++ b/stock_picking_show_linked/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Juany Davila diff --git a/stock_picking_show_linked/readme/DESCRIPTION.rst b/stock_picking_show_linked/readme/DESCRIPTION.rst new file mode 100644 index 000000000..5b1e6deb5 --- /dev/null +++ b/stock_picking_show_linked/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module should allow a user to display, on smart buttons in a picking: + +* Destination pickings: the pickings associated to destination moves indicated in the moves in this picking + +* Origin pickings: the pickings associated to origin moves indicated in the moves in this picking diff --git a/stock_picking_show_linked/static/description/index.html b/stock_picking_show_linked/static/description/index.html new file mode 100644 index 000000000..51ef00cc6 --- /dev/null +++ b/stock_picking_show_linked/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +Stock Picking Show Linked + + + +
+

Stock Picking Show Linked

+ + +

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

+

This module should allow a user to display, on smart buttons in a picking:

+
    +
  • Destination pickings: the pickings associated to destination moves indicated in the moves in this picking
  • +
  • Origin pickings: the pickings associated to origin moves indicated in the moves in this picking
  • +
+

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

+
    +
  • ForgeFlow
  • +
+
+ +
+

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_show_linked/views/stock_picking.xml b/stock_picking_show_linked/views/stock_picking.xml new file mode 100644 index 000000000..7abd5d9ae --- /dev/null +++ b/stock_picking_show_linked/views/stock_picking.xml @@ -0,0 +1,42 @@ + + + + + stock_picking_show_linked.form + stock.picking + + +
+ + + + +
+
+
+
+