From 12ffafaae0cc71f6076193284baddcc6d64866b9 Mon Sep 17 00:00:00 2001 From: Preksha Chouhan Date: Mon, 5 Jun 2023 13:15:45 +0000 Subject: [PATCH] [FIX] mrp: prevent traceback when date format of delivery_date doesn't match While creating a Manufacturing Orders, when user give date format as '%d/%m/%Y' and when it tries to match the date format with '%m/%d/%Y' in '_add_transit_line' method, the error will be generated. Steps to Produce:- 1. Install 'mrp' and 'purchase' module 2. Change the format of date in 'Languages' as '%d/%m/%Y' 3. Activate 'Multi-Step Routes' in inventory configuration 4. Go to 'Warehouse' and select 3 steps route in 'Incoming Shipments' and 'Manufacture' and save 5. Go to 'mrp' and create a new BOM 6. Go to 'purchase' and create a PO with the same product in BOM and confirm it 7. Click on smart button 'Receipt' -> 'set quantities' -> 'validate' 8. Go to 'mrp' and create a MO with same BOM change the 'Scheduled Date' and confirm it 9. Click on smart button 'Overview' Trace-back will be generated. Applying these changes will resolve this issue. sentry-4088257491 closes odoo/odoo#128453 X-original-commit: d1d7141fd52bd7167910074adcde2cd95e8b9440 Signed-off-by: Ivan Elizaryev (iel) --- addons/mrp/report/mrp_report_mo_overview.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/mrp/report/mrp_report_mo_overview.py b/addons/mrp/report/mrp_report_mo_overview.py index ba0685ff6c2..d89f8ea5485 100644 --- a/addons/mrp/report/mrp_report_mo_overview.py +++ b/addons/mrp/report/mrp_report_mo_overview.py @@ -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 +from odoo.tools import float_compare, format_date, float_is_zero, get_lang from datetime import datetime, timedelta from math import log10 @@ -342,7 +342,8 @@ class ReportMoOverview(models.AbstractModel): product = move_raw.product_id currency = (production.company_id or self.env.company).currency_id - receipt_date = datetime.strptime(in_transit['delivery_date'], '%m/%d/%Y') + lg = self.env['res.lang']._lang_get(self.env.user.lang) or get_lang(self.env) + receipt_date = datetime.strptime(in_transit['delivery_date'], lg.date_format) return {'summary': { 'level': level + 1, 'index': f"{current_index}IT",