stock_usability: Improve display of reservations from quants
Add link to stock.move.lines from lot form view
This commit is contained in:
@@ -35,6 +35,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'views/stock_warehouse_orderpoint.xml',
|
||||
'views/product.xml',
|
||||
'views/procurement_group.xml',
|
||||
'views/stock_production_lot.xml',
|
||||
'views/procurement_scheduler_log.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Copyright 2021 Akretion France (http://www.akretion.com/)
|
||||
# Copyright 2021-2022 Akretion France (http://www.akretion.com/)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo import fields, models, _
|
||||
from odoo.tools import float_compare, float_is_zero
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,21 @@ from odoo import fields, models
|
||||
class StockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
||||
product_barcode = fields.Char(
|
||||
related='product_id.barcode', string="Product Barcode")
|
||||
|
||||
def action_stock_move_lines_reserved(self):
|
||||
self.ensure_one()
|
||||
action = self.action_view_stock_moves()
|
||||
action['context'] = {'search_default_todo': True}
|
||||
action = self.env["ir.actions.actions"]._for_xml_id(
|
||||
"stock.stock_move_line_action")
|
||||
action['domain'] = [
|
||||
('state', 'not in', ('draft', 'done')),
|
||||
('product_id', '=', self.product_id.id),
|
||||
('location_id', '=', self.location_id.id),
|
||||
('lot_id', '=', self.lot_id.id or False),
|
||||
'|',
|
||||
('package_id', '=', self.package_id.id or False),
|
||||
('result_package_id', '=', self.package_id.id or False),
|
||||
]
|
||||
action['context'] = {'create': 0}
|
||||
return action
|
||||
|
||||
@@ -64,6 +64,11 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock.stock_move_action" model="ir.actions.act_window">
|
||||
<!-- Remove from context 'search_default_groupby_location_id': 1 -->
|
||||
<field name="context">{'search_default_done': 1}</field>
|
||||
</record>
|
||||
|
||||
<record id="view_move_line_tree" model="ir.ui.view">
|
||||
<field name="name">stock_usability.stock.move.line.tree</field>
|
||||
<field name="model">stock.move.line</field>
|
||||
@@ -104,4 +109,19 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_move_line_view_search" model="ir.ui.view">
|
||||
<field name="model">stock.move.line</field>
|
||||
<field name="inherit_id" ref="stock.stock_move_line_view_search"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="location_dest_id" position="after">
|
||||
<field name="lot_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="stock.stock_move_line_action" model="ir.actions.act_window">
|
||||
<!-- remove from context 'search_default_groupby_product_id': 1 -->
|
||||
<field name="context">{'search_default_done': 1, 'create': 0}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
|
||||
35
stock_usability/views/stock_production_lot.xml
Normal file
35
stock_usability/views/stock_production_lot.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2022 Akretion France (http://www.akretion.com/)
|
||||
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="stock.action_production_lot_form" model="ir.actions.act_window">
|
||||
<!-- remove from context 'search_default_group_by_product': 1-->
|
||||
<field name="context">{'display_complete': True, 'default_company_id': allowed_company_ids[0]}</field>
|
||||
</record>
|
||||
|
||||
<record id="stock_move_line_from_lot_action" model="ir.actions.act_window">
|
||||
<field name="name">Product Moves</field>
|
||||
<field name="res_model">stock.move.line</field>
|
||||
<field name="view_mode">tree,kanban,pivot,form</field>
|
||||
<field name="domain">[('lot_id', '=', active_id)]</field>
|
||||
<field name="context">{'search_default_done': 1, 'create': 0}</field>
|
||||
</record>
|
||||
|
||||
<record id="view_production_lot_form" model="ir.ui.view">
|
||||
<field name="model">stock.production.lot</field>
|
||||
<field name="inherit_id" ref="stock.view_production_lot_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<button name="action_lot_open_quants" position="after">
|
||||
<button name="%(stock_move_line_from_lot_action)d" string="Product Moves" type="action" icon="fa-exchange"/>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
@@ -16,6 +16,29 @@
|
||||
<field name="product_id" position="after">
|
||||
<field name="product_barcode" optional="hide"/>
|
||||
</field>
|
||||
<!-- Move available_quantity AFTER quantity -->
|
||||
<field name="quantity" position="after">
|
||||
<field name="reserved_quantity" sum="1" optional="show"/>
|
||||
<field name="available_quantity" position="move"/>
|
||||
</field>
|
||||
<field name="quantity" position="attributes">
|
||||
<attribute name="sum">1</attribute>
|
||||
</field>
|
||||
<field name="available_quantity" position="attributes">
|
||||
<attribute name="sum">1</attribute>
|
||||
<attribute name="optional">show</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_quant_tree_editable" model="ir.ui.view">
|
||||
<field name="model">stock.quant</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_quant_tree_editable"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="available_quantity" position="before">
|
||||
<field name="reserved_quantity" sum="1" optional="show"/>
|
||||
<button type="object" name="action_stock_move_lines_reserved" string="Reservations" attrs="{'invisible': [('reserved_quantity', '=', 0)]}"/>
|
||||
</field>
|
||||
<field name="quantity" position="attributes">
|
||||
<attribute name="sum">1</attribute>
|
||||
</field>
|
||||
@@ -25,7 +48,7 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
|
||||
<record id="view_stock_quant_form" model="ir.ui.view">
|
||||
<field name="name">stock.usability.quant.form</field>
|
||||
<field name="model">stock.quant</field>
|
||||
@@ -34,9 +57,15 @@
|
||||
<div name="button_box" position="inside">
|
||||
<button class="oe_stat_button" icon="fa-arrows-v" type="object" name="action_stock_move_lines_reserved" string="Reservations"/>
|
||||
</div>
|
||||
<xpath expr="//field[@name='reserved_quantity']/.." position="after">
|
||||
<label for="available_quantity" />
|
||||
<div class="o_row">
|
||||
<field name="available_quantity"/>
|
||||
<field name="product_uom_id" groups="uom.group_uom"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- more detailed stock.move tree view when using the button from product form -->
|
||||
<!-- TODO TEST
|
||||
@@ -58,10 +87,4 @@ So I create another "regular" Quants" menu entry -->
|
||||
parent="stock.menu_warehouse_report"
|
||||
sequence="160"/>
|
||||
|
||||
<!--
|
||||
<record id="stock.action_production_lot_form" model="ir.actions.act_window">
|
||||
<field name="context">{}</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user