[IMP] mrp: display Ready to Produce qty in MO Overview Report

Before this commit
==================
Currently, There is no way to know how many qty users can produce with the current stock.

After this commit
=================
With this commit, In the MO Overview report, the following stages are added:
'Ready', 'Not Ready', and '{X} Ready'. the Ready to Produce qty is based on
the component reserved quantity + component free quantity. Furthermore, the
table header in the MO status overview report has been slightly highlighted for
improved visibility.

task-3356499

closes odoo/odoo#124474

Signed-off-by: Tiffany Chang (tic) <tic@odoo.com>
This commit is contained in:
priyanshi patel(prpa)
2023-09-14 18:09:49 +00:00
committed by Tiffany Chang (tic)
parent 824fc94bbc
commit f712299fe4
3 changed files with 32 additions and 4 deletions
+27 -2
View File
@@ -4,7 +4,7 @@ import copy
import json
from collections import defaultdict
from odoo import _, api, fields, models
from odoo.tools import float_compare, format_date, float_is_zero, get_lang
from odoo.tools import float_compare, float_repr, float_round, float_is_zero, format_date, get_lang
from datetime import datetime, timedelta
from math import log10
@@ -100,7 +100,32 @@ class ReportMoOverview(models.AbstractModel):
}
def _format_state(self, record):
return dict(record._fields['state']._description_selection(self.env)).get(record.state)
if record._name != 'mrp.production' or record.state not in ('draft', 'confirmed') or not record.move_raw_ids:
return dict(record._fields['state']._description_selection(self.env)).get(record.state)
components_qty_to_produce = defaultdict(float)
components_qty_reserved = defaultdict(float)
for move in record.move_raw_ids:
if move.product_id.detailed_type != 'product':
continue
components_qty_to_produce[move.product_id] += move.product_uom._compute_quantity(move.product_uom_qty, move.product_id.uom_id)
components_qty_reserved[move.product_id] += move.product_uom._compute_quantity(move.reserved_availability, move.product_id.uom_id)
producible_qty = record.product_qty
for product_id, comp_qty_to_produce in components_qty_to_produce.items():
if float_is_zero(comp_qty_to_produce, precision_rounding=product_id.uom_id.rounding):
continue
comp_producible_qty = float_round(
record.product_qty * (components_qty_reserved[product_id] + product_id.free_qty) / comp_qty_to_produce,
precision_rounding=record.product_uom_id.rounding, rounding_method='DOWN'
)
if float_is_zero(comp_producible_qty, precision_rounding=record.product_uom_id.rounding):
return _("Not Ready")
producible_qty = min(comp_producible_qty, producible_qty)
if float_is_zero(producible_qty, precision_rounding=record.product_uom_id.rounding):
return _("Not Ready")
elif float_compare(producible_qty, record.product_qty, precision_rounding=record.product_uom_id.rounding) == -1:
producible_qty = float_repr(producible_qty, self.env['decimal.precision'].precision_get('Product Unit of Measure'))
return _("%(producible_qty)s Ready", producible_qty=producible_qty)
return _("Ready")
def _get_uom_precision(self, uom_rounding):
return max(0, int(-(log10(uom_rounding))))
@@ -14,10 +14,10 @@
</div>
</t>
<div class="py-3 py-lg-5 overflow-auto border-bottom bg-view">
<div class="overflow-auto border-bottom bg-view">
<div class="container-fluid">
<table class="table">
<thead>
<thead class="o_mrp_mo_overview_thead">
<tr>
<th class="text-start"/>
<th class="text-center" t-if="showReplenishments">Status</th>
@@ -0,0 +1,3 @@
.o_mrp_mo_overview_thead {
background-color: #{$o-webclient-background-color};
}