This commit is contained in:
2026-02-11 07:26:48 +01:00
parent 1eb86892de
commit e37cd4a1cc
7 changed files with 51 additions and 15 deletions

View File

@@ -36,6 +36,7 @@ class WeightReport(ModelSQL, ModelView):
arrival_date = fields.Date('Arrival Date')
weighing_place = fields.Char('Weighing Place')
weighing_method = fields.Char('Weighing Method')
weight_date = fields.Date('Weight Date')
bales = fields.Integer('Number of Bales')
# Weights Information
@@ -90,13 +91,17 @@ class WeightReport(ModelSQL, ModelView):
report['file_no'] = report_data.get('file_no', '')
# Conversion de la date (format: "28 October 2025")
date_str = report_data.get('date', '')
if date_str:
try:
report['report_date'] = dt.strptime(date_str, '%d %B %Y').date()
except:
report['report_date'] = None
def parse_date(date_str):
for fmt in ('%d %B %Y', '%d %b %Y'):
try:
return dt.strptime(date_str, fmt).date()
except ValueError:
pass
return None
report['report_date'] = parse_date(report_data.get('date', ''))
report['weight_date'] = parse_date(report_data.get('weight_date', ''))
# 3. Contract Information
contract_data = json_data.get('contract', {})
report['contract_no'] = contract_data.get('contract_no', '')