[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) <iel@odoo.com>
This commit is contained in:
Preksha Chouhan
2023-07-15 10:54:23 +02:00
parent b7a72872bf
commit 12ffafaae0
+3 -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
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",