[ADD] sale_project_stock: show stock.move when click on SOL in project update
This commit adds an action to allow the user to click on SOL contains other project than product one to see the `stock.move` related of the SOL clicked. task-2710808
This commit is contained in:
committed by
Laurent Stukkens (LTU)
parent
08501fa130
commit
4567edf97e
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
{
|
||||
'name': 'Sale Project - Sale Stock',
|
||||
'version': '1.0',
|
||||
'description': 'Adds a full traceability of inventory operations on the profitability report.',
|
||||
'summary': 'Adds a full traceability of inventory operations on the profitability report.',
|
||||
'license': 'LGPL-3',
|
||||
'category': 'Sales',
|
||||
'depends': ['sale_project', 'sale_stock'],
|
||||
'data': [
|
||||
'views/stock_move_views.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'auto_install': True,
|
||||
'application': False,
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import sale_order_line
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
|
||||
# FIXME: see if we move this computed field into sale_stock module.
|
||||
stock_move_count = fields.Integer(compute='_compute_stock_move_count')
|
||||
|
||||
@api.depends('move_ids')
|
||||
def _compute_stock_move_count(self):
|
||||
stock_move_read_group = self.env['stock.move'].read_group([('sale_line_id', 'in', self.ids)], ['sale_line_id'], ['sale_line_id'])
|
||||
stock_move_count_per_sol = {res['sale_line_id'][0]: res['sale_line_id_count'] for res in stock_move_read_group}
|
||||
for sol in self:
|
||||
sol.stock_move_count = stock_move_count_per_sol.get(sol.id, 0)
|
||||
|
||||
def _get_action_per_item(self):
|
||||
""" Get action per Sales Order Item to display the stock moves linked
|
||||
|
||||
:returns: Dict containing id of SOL as key and the action as value
|
||||
"""
|
||||
action_per_sol = super()._get_action_per_item()
|
||||
stock_move_action = self.env.ref('sale_project_stock.stock_move_per_sale_order_line_action').id
|
||||
for sol in self:
|
||||
if not sol.is_service and sol.stock_move_count > 0:
|
||||
action_per_sol[sol.id] = stock_move_action
|
||||
return action_per_sol
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="stock_move_per_sale_order_line_action" model="ir.actions.act_window">
|
||||
<field name="name">Transfers</field>
|
||||
<field name="res_model">stock.move</field>
|
||||
<field name="view_mode">tree,kanban,pivot,graph,form</field>
|
||||
<field name="domain">[('sale_line_id', '=', active_id)]</field>
|
||||
<field name="context">{}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
No stock move found
|
||||
</p>
|
||||
<p>
|
||||
This menu gives you the full traceability of inventory
|
||||
operations on a specific product. You can filter on the product
|
||||
to see all the past or future movements for the product.
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user