Skip to content

Commit

Permalink
[18.0][MIG] stock_picking_show_linked: Migration to 18.0
Browse files Browse the repository at this point in the history
[18.0][MIG] stock_picking_show_linked: Migration to 18.0
[18.0][MIG] stock_picking_show_linked: Migration to 18.0

[18.0][MIG] stock_picking_show_linked: Migration to 18.0

[18.0][MIG] stock_picking_show_linked: Migration to 18.0, suggested improvements
  • Loading branch information
fd-oerp committed Dec 12, 2024
1 parent cf59722 commit 48edd9a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions stock_picking_show_linked/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Contributors
------------

- Juany Davila <juany.davila@forgeflow.com>
- Foram Darji <fd@oerp.ca>

Maintainers
-----------
Expand Down
3 changes: 2 additions & 1 deletion stock_picking_show_linked/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{
"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": "16.0.1.0.0",
"version": "18.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management",
Expand Down
13 changes: 6 additions & 7 deletions stock_picking_show_linked/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-19 15:37+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"POT-Creation-Date: 2024-12-11 19:18+0000\n"
"PO-Revision-Date: 2024-12-11 19:18+0000\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: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
"Plural-Forms: \n"

#. module: stock_picking_show_linked
#: model:ir.model.fields,field_description:stock_picking_show_linked.field_stock_picking__dest_picking_count
Expand Down
4 changes: 3 additions & 1 deletion stock_picking_show_linked/i18n/stock_picking_show_linked.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Project-Id-Version: Odoo Server 18.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-11 19:15+0000\n"
"PO-Revision-Date: 2024-12-11 19:15+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down
23 changes: 14 additions & 9 deletions stock_picking_show_linked/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models

Expand All @@ -9,22 +10,26 @@ class StockPicking(models.Model):
dest_picking_count = fields.Integer(compute="_compute_picking_count")
origin_picking_count = fields.Integer(compute="_compute_picking_count")

@api.depends("move_ids")
@api.depends("move_ids.move_orig_ids", "move_ids.move_dest_ids")
def _compute_picking_count(self):
for record in self:
origin_pickings = record.mapped("move_ids.move_orig_ids.picking_id")
dest_pickings = record.mapped("move_ids.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):
record.update(

Check warning on line 18 in stock_picking_show_linked/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_show_linked/models/stock_picking.py#L16-L18

Added lines #L16 - L18 were not covered by tests
{
"origin_picking_count": len(origin_pickings),
"dest_picking_count": len(dest_pickings),
}
)

def _get_action_link(self, picking_ids):
result = self.env["ir.actions.actions"]._for_xml_id(

Check warning on line 26 in stock_picking_show_linked/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_show_linked/models/stock_picking.py#L26

Added line #L26 was not covered by tests
"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:
if not picking_ids or len(picking_ids) > 1:
result["domain"] = f"[('id','in',{picking_ids})]"

Check warning on line 31 in stock_picking_show_linked/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_show_linked/models/stock_picking.py#L31

Added line #L31 was not covered by tests
elif len(picking_ids) == 1:
res = self.env.ref("stock.view_picking_form", False)
form_view = [(res and res.id or False, "form")]

Check warning on line 34 in stock_picking_show_linked/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_show_linked/models/stock_picking.py#L33-L34

Added lines #L33 - L34 were not covered by tests
if "views" in result:
Expand All @@ -33,7 +38,7 @@ def _get_action_link(self, pickings):
]
else:
result["views"] = form_view
result["res_id"] = pickings[0]
result["res_id"] = picking_ids[0]
return result

Check warning on line 42 in stock_picking_show_linked/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_show_linked/models/stock_picking.py#L40-L42

Added lines #L40 - L42 were not covered by tests

def action_stock_picking_origin(self):
Expand Down
1 change: 1 addition & 0 deletions stock_picking_show_linked/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Juany Davila \<<juany.davila@forgeflow.com>\>
- Foram Darji \<<fd@oerp.ca>\>
1 change: 1 addition & 0 deletions stock_picking_show_linked/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Juany Davila &lt;<a class="reference external" href="mailto:juany.davila&#64;forgeflow.com">juany.davila&#64;forgeflow.com</a>&gt;</li>
<li>Foram Darji &lt;<a class="reference external" href="mailto:fd&#64;oerp.ca">fd&#64;oerp.ca</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
6 changes: 4 additions & 2 deletions stock_picking_show_linked/views/stock_picking.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)-->
<odoo>
<record id="stock_picking_show_linked_form_inherit" model="ir.ui.view">
<field name="name">stock_picking_show_linked.form</field>
Expand All @@ -13,7 +15,7 @@
type="object"
name="action_stock_picking_destination"
icon="fa-truck"
attrs="{'invisible': [('dest_picking_count', '==', 0)]}"
invisible="dest_picking_count == 0"
>
<field
string="Dest. Transfers"
Expand All @@ -26,7 +28,7 @@
type="object"
name="action_stock_picking_origin"
icon="fa-truck"
attrs="{'invisible': [('origin_picking_count', '==', 0)]}"
invisible="origin_picking_count == 0"
>
<field
string="Origin Transfers"
Expand Down

0 comments on commit 48edd9a

Please sign in to comment.