11.02.26
This commit is contained in:
@@ -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', '')
|
||||
|
||||
Reference in New Issue
Block a user