[MIG] bemade_picking_upstream to 18.0
This commit is contained in:
parent
5ec51c3554
commit
ba9f1e0c56
5 changed files with 85 additions and 0 deletions
1
bemade_picking_upstream/__init__.py
Normal file
1
bemade_picking_upstream/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
||||||
32
bemade_picking_upstream/__manifest__.py
Normal file
32
bemade_picking_upstream/__manifest__.py
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#
|
||||||
|
# Bemade Inc.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023-June Bemade Inc. (<https://www.bemade.org>).
|
||||||
|
# Author: Marc Durepos (Contact : marc@bemade.org)
|
||||||
|
#
|
||||||
|
# This program is under the terms of the Odoo Proprietary License v1.0 (OPL-1)
|
||||||
|
# It is forbidden to publish, distribute, sublicense, or sell copies of the Software
|
||||||
|
# or modified copies of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
# DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
{
|
||||||
|
"name": "Show Upstream Pickings",
|
||||||
|
"version": "18.0.1.0.0",
|
||||||
|
"summary": "Show upstream pickings when a picking is waiting on other moves.",
|
||||||
|
"category": "Stock",
|
||||||
|
"author": "Bemade Inc.",
|
||||||
|
"website": "http://www.bemade.org",
|
||||||
|
"license": "LGPL-3",
|
||||||
|
"depends": ["stock"],
|
||||||
|
"data": ["views/stock_picking_views.xml"],
|
||||||
|
"assets": {},
|
||||||
|
"installable": True,
|
||||||
|
"auto_install": False,
|
||||||
|
}
|
||||||
1
bemade_picking_upstream/models/__init__.py
Normal file
1
bemade_picking_upstream/models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import stock_picking
|
||||||
37
bemade_picking_upstream/models/stock_picking.py
Normal file
37
bemade_picking_upstream/models/stock_picking.py
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
|
class StockPicking(models.Model):
|
||||||
|
_inherit = "stock.picking"
|
||||||
|
|
||||||
|
upstream_picking_ids = fields.One2many(
|
||||||
|
compute="_compute_upstream_picking_ids",
|
||||||
|
comodel_name="stock.picking",
|
||||||
|
string="Upstream Transfers",
|
||||||
|
help="Transfers that this transfer depends on for stock availability.",
|
||||||
|
compute_sudo=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
upstream_picking_count = fields.Integer(
|
||||||
|
compute="_compute_upstream_picking_ids",
|
||||||
|
compute_sudo=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends(
|
||||||
|
"move_ids", "move_ids.move_orig_ids", "move_ids.move_orig_ids.picking_id"
|
||||||
|
)
|
||||||
|
def _compute_upstream_picking_ids(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.upstream_picking_ids = (
|
||||||
|
rec.move_ids.mapped("move_orig_ids").mapped("picking_id") - rec
|
||||||
|
)
|
||||||
|
rec.upstream_picking_count = len(rec.upstream_picking_ids)
|
||||||
|
|
||||||
|
def action_view_upstream_transfers(self):
|
||||||
|
return {
|
||||||
|
"name": "Upstream Transfers",
|
||||||
|
"type": "ir.actions.act_window",
|
||||||
|
"res_model": "stock.picking",
|
||||||
|
"domain": [("id", "in", self.upstream_picking_ids.ids)],
|
||||||
|
"view_mode": "list,kanban,form,calendar,map",
|
||||||
|
}
|
||||||
14
bemade_picking_upstream/views/stock_picking_views.xml
Normal file
14
bemade_picking_upstream/views/stock_picking_views.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="stock_picking_view_form" model="ir.ui.view">
|
||||||
|
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||||
|
<field name="model">stock.picking</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<button name="action_see_move_scrap" position="before">
|
||||||
|
<field invisible="1" name="upstream_picking_ids"/>
|
||||||
|
<field invisible="1" name="upstream_picking_count"/>
|
||||||
|
<button class="oe_stat_button" icon="fa-pause" invisible="upstream_picking_count == 0" name="action_view_upstream_transfers" string="Upstream Transfer(s)" type="object">
|
||||||
|
</button>
|
||||||
|
</button></field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in a new issue