diff --git a/addons/mrp/report/mrp_report_mo_overview.py b/addons/mrp/report/mrp_report_mo_overview.py index d8ef6ac8730..bf76065c940 100644 --- a/addons/mrp/report/mrp_report_mo_overview.py +++ b/addons/mrp/report/mrp_report_mo_overview.py @@ -57,8 +57,8 @@ class ReportMoOverview(models.AbstractModel): doc['show_uom'] = self.env.user.user_has_groups('uom.group_uom') if doc['show_uom']: footer_colspan += 1 - doc['data_mo_unit_cost'] = doc['summary'].get('mo_cost', 0) / doc['summary'].get('quantity', 1) - doc['data_real_unit_cost'] = doc['summary'].get('real_cost', 0) / doc['summary'].get('quantity', 1) + doc['data_mo_unit_cost'] = doc['summary'].get('mo_cost', 0) / (doc['summary'].get('quantity') or 1) + doc['data_real_unit_cost'] = doc['summary'].get('real_cost', 0) / (doc['summary'].get('quantity') or 1) doc['unfolded_ids'] = set(json.loads(data.get('unfoldedIds', '[]'))) doc['footer_colspan'] = footer_colspan doc['get_color'] = get_color @@ -93,8 +93,8 @@ class ReportMoOverview(models.AbstractModel): def _get_report_extra_lines(self, summary, components, operations, production_done=False): currency = summary.get('currency', self.env.company.currency_id) - unit_mo_cost = currency.round(summary.get('mo_cost', 0) / summary.get('quantity', 1)) - unit_real_cost = currency.round(summary.get('real_cost', 0) / summary.get('quantity', 1)) + unit_mo_cost = currency.round(summary.get('mo_cost', 0) / (summary.get('quantity') or 1)) + unit_real_cost = currency.round(summary.get('real_cost', 0) / (summary.get('quantity') or 1)) extras = { 'unit_mo_cost': unit_mo_cost, 'unit_mo_cost_decorator': self._get_comparison_decorator(unit_real_cost, unit_mo_cost, currency.rounding), @@ -175,7 +175,7 @@ class ReportMoOverview(models.AbstractModel): 'formatted_state': self._format_state(production, components), 'quantity': production.product_qty if production.state != 'done' else production.qty_produced, 'uom_name': production.product_uom_id.display_name, - 'uom_precision': self._get_uom_precision(production.product_uom_id.rounding), + 'uom_precision': self._get_uom_precision(production.product_uom_id.rounding or 0.01), 'quantity_free': product.uom_id._compute_quantity(max(product.free_qty, 0), production.product_uom_id) if product.type == 'product' else False, 'quantity_on_hand': product.uom_id._compute_quantity(product.qty_available, production.product_uom_id) if product.type == 'product' else False, 'quantity_reserved': 0.0, @@ -189,6 +189,8 @@ class ReportMoOverview(models.AbstractModel): } def _get_unit_cost(self, move): + if not move: + return 0.0 return move.product_id.uom_id._compute_price(move.product_id.standard_price, move.product_uom) def _format_state(self, record, components=False):