I have this model:
class UserTimesheetRecord(ModelSQL, ModelView):
"Timesheet Record"
__name__ = 'afx.user.timesheet.record'
unique_id = fields.Char("Uuid")
timesheet = fields.Many2One('afx.user.timesheet', "Timesheet")
date = fields.Date("Date", required=True)
day = fields.Char("Day")
task = fields.Selection([], "Status", sort=False)
project = fields.Many2One('afx.project', "Project", domain=[
('so_no', '!=', None)
])
detail = fields.Text("Detail")
so_no = fields.Char(
"S/O Number",
help="Automatically filled based on the selected project.",
on_change_with=['project'] # Trigger computation when project changes
)
time_in = fields.Time(
"Time In",
help="Format: HH:MM"
)
time_out = fields.Time(
'Time Out',
help='Format: HH:MM'
)
total = fields.Float(
'Total Hours',
digits=(16, 2), # Two decimal places
help="Calculated total hours spent from Time In to Time Out."
)
I can create this model with no failure, but when I want to Update it I got error:
Traceback (most recent call last):
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/protocols/dispatcher.py", line 216, in _dispatch
result = rpc.result(meth(*c_args, **c_kwargs))
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 275, in wrapper
return func(cls, *args, **kwargs)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1472, in write
cls._validate(sub_records, field_names=all_field_names)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/transaction.py", line 50, in wrapper
return func(*args, **kwargs)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 1408, in _validate
validate_domain(field)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 1311, in validate_domain
validate_relation_domain(
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelstorage.py", line 1333, in validate_relation_domain
finds = Relation.search(['AND',
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1850, in search
tables, expression, union_orderings = cls.__search_query(
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1798, in __search_query
tables, expression = cls.search_domain(domain)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1962, in search_domain
expression = convert(domain)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1958, in convert
return And((convert(d) for d in (
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1958, in <genexpr>
return And((convert(d) for d in (
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/modelsql.py", line 1949, in convert
expression = field.convert_domain(domain, tables, cls)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/fields/field.py", line 217, in wrapper
return func(self, domain, tables, Model)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/fields/field.py", line 456, in convert_domain
expression = Operator(column, self._domain_value(operator, value))
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/fields/field.py", line 436, in _domain_value
return self.sql_format(value)
File "/home/tryton/afx_project/.env/lib/python3.10/site-packages/trytond/model/fields/date.py", line 36, in sql_format
value = datetime.date.fromisoformat(value)
ValueError: Invalid isoformat string: '4'
Sample data in my db on a record (related to date or time) of this model are below
I tried many ways to find which part of my code is wrong, I also use AI to get answer… I couldn’t find it.. please need help
Regards
Bromo