bemade_picking_upstream: new module for smart button to link to upstream pickings (waiting for other operation).
This commit is contained in:
parent
bf8dd0145f
commit
a2602e2ba6
5 changed files with 88 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': '15.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': 'OPL-1',
|
||||
'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
|
||||
33
bemade_picking_upstream/models/stock_picking.py
Normal file
33
bemade_picking_upstream/models/stock_picking.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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_lines', 'move_lines.move_orig_ids', 'move_lines.move_orig_ids.picking_id')
|
||||
def _compute_upstream_picking_ids(self):
|
||||
for rec in self:
|
||||
rec.upstream_picking_ids = rec.move_lines.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': 'tree,kanban,form,calendar,map',
|
||||
}
|
||||
21
bemade_picking_upstream/views/stock_picking_views.xml
Normal file
21
bemade_picking_upstream/views/stock_picking_views.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?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 name="upstream_picking_ids" invisible="1"/>
|
||||
<field name="upstream_picking_count" invisible="1"/>
|
||||
<button
|
||||
name="action_view_upstream_transfers"
|
||||
string="Upstream Transfer(s)"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
icon="fa-pause"
|
||||
attrs="{'invisible': [('upstream_picking_count', '=', 0)]}">
|
||||
</button>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue