[IMP] mrp: add kits decription in picking
When recieving a kits product, it will be decomponent in the picking. In this commit, we add a column in the picking to show the info of the kits in picking. Task-2444000 COM PR odoo/odoo#75555 ENT PR odoo/enterprise#20440 UPG PR odoo/upgrade#2783
This commit is contained in:
@@ -10,6 +10,7 @@ class StockMoveLine(models.Model):
|
||||
|
||||
workorder_id = fields.Many2one('mrp.workorder', 'Work Order', check_company=True)
|
||||
production_id = fields.Many2one('mrp.production', 'Production Order', check_company=True)
|
||||
description_bom_line = fields.Char(related='move_id.description_bom_line')
|
||||
|
||||
@api.depends('production_id')
|
||||
def _compute_picking_type_id(self):
|
||||
@@ -123,6 +124,22 @@ class StockMove(models.Model):
|
||||
help="The percentage of the final production cost for this by-product. The total of all by-products' cost share must be smaller or equal to 100.")
|
||||
product_qty_available = fields.Float('Product On Hand Quantity', related='product_id.qty_available')
|
||||
product_virtual_available = fields.Float('Product Forecasted Quantity', related='product_id.virtual_available')
|
||||
description_bom_line = fields.Char('Kit', compute='_compute_description_bom_line')
|
||||
|
||||
@api.depends('bom_line_id')
|
||||
def _compute_description_bom_line(self):
|
||||
bom_line_description = {}
|
||||
for bom in self.bom_line_id.bom_id:
|
||||
if bom.type != 'phantom':
|
||||
continue
|
||||
line_ids = bom.bom_line_ids.ids
|
||||
total = len(line_ids)
|
||||
name = bom.display_name
|
||||
for i, line_id in enumerate(line_ids):
|
||||
bom_line_description[line_id] = '%s - %d/%d' % (name, i+1, total)
|
||||
|
||||
for move in self:
|
||||
move.description_bom_line = bom_line_description.get(move.bom_line_id.id)
|
||||
|
||||
@api.depends('raw_material_production_id.priority')
|
||||
def _compute_priority(self):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class StockPickingType(models.Model):
|
||||
@@ -53,6 +53,13 @@ class StockPickingType(models.Model):
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
has_kits = fields.Boolean(compute='_compute_has_kits')
|
||||
|
||||
@api.depends('move_lines')
|
||||
def _compute_has_kits(self):
|
||||
for picking in self:
|
||||
picking.has_kits = any(picking.move_lines.mapped('bom_line_id'))
|
||||
|
||||
def _less_quantities_than_expected_add_documents(self, moves, documents):
|
||||
documents = super(StockPicking, self)._less_quantities_than_expected_add_documents(moves, documents)
|
||||
|
||||
|
||||
@@ -98,6 +98,32 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_form_inherit_mrp" model="ir.ui.view">
|
||||
<field name="name">view.picking.form.inherit.mrp</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='use_create_lots']" position="after">
|
||||
<field name="has_kits" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='description_picking']" position="after">
|
||||
<field name="description_bom_line" optional="show" attrs="{'column_invisible': [('parent.has_kits', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_stock_move_line_detailed_operation_tree_mrp" model="ir.ui.view">
|
||||
<field name="name">stock.move.line.operations.tree.mrp</field>
|
||||
<field name="model">stock.move.line</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='product_id']" position="after">
|
||||
<field name="description_bom_line" optional="show" attrs="{'column_invisible': [('parent.has_kits', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_type_form_inherit_mrp" model="ir.ui.view">
|
||||
<field name="name">Operation Types</field>
|
||||
<field name="model">stock.picking.type</field>
|
||||
|
||||
Reference in New Issue
Block a user