Traceback (most recent call last): File "C:\data\odoo\odoo\fields.py", line 940, in __get__ value = record.env.cache.get(record, self) File "C:\data\odoo\odoo\api.py", line 967, in get value = self._data[key][field][record._ids[0]] KeyError: <odoo.models.NewId object at 0x000002005B6709A8> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\data\odoo\odoo\http.py", line 651, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "C:\data\odoo\odoo\http.py", line 310, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "C:\data\odoo\odoo\tools\pycompat.py", line 87, in reraise raise value File "C:\data\odoo\odoo\http.py", line 693, in dispatch result = self._call_function(**self.params) File "C:\data\odoo\odoo\http.py", line 342, in _call_function return checked_call(self.db, *args, **kwargs) File "C:\data\odoo\odoo\service\model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "C:\data\odoo\odoo\http.py", line 335, in checked_call result = self.endpoint(*a, **kw) File "C:\data\odoo\odoo\http.py", line 937, in __call__ return self.method(*args, **kw) File "C:\data\odoo\odoo\http.py", line 515, in response_wrap response = f(*args, **kw) File "c:\data\odoo\addons\web\controllers\main.py", line 934, in call_kw return self._call_kw(model, method, args, kwargs) File "c:\data\odoo\addons\web\controllers\main.py", line 926, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "C:\data\odoo\odoo\api.py", line 689, in call_kw return call_kw_multi(method, model, args, kwargs) File "C:\data\odoo\odoo\api.py", line 680, in call_kw_multi result = method(recs, *args, **kwargs) File "C:\data\odoo\odoo\models.py", line 5198, in onchange snapshot1 = Snapshot(record, nametree) File "C:\data\odoo\odoo\models.py", line 5105, in __init__ if subnames else record[name] File "C:\data\odoo\odoo\models.py", line 4785, in __getitem__ return self._fields[key].__get__(self, type(self)) File "C:\data\odoo\odoo\fields.py", line 946, in __get__ self.determine_draft_value(record) File "C:\data\odoo\odoo\fields.py", line 1066, in determine_draft_value self._compute_value(record) File "C:\data\odoo\odoo\fields.py", line 1002, in _compute_value getattr(records, self.compute)() File "c:\data\addon\custom-addons\fleet_tire_management\models\tire_management.py", line 153, in _compute_cek_days date_2 = datetime.datetime.strptime(r.issue_date, '%Y-%m-%d') TypeError: strptime() argument 1 must be str, not bool
my method.py
cek_days = fields.Integer(string='Hari cek - Hari pasang' , compute='_compute_cek_days')
issue_date = fields.Date(string="Tanggal Pemasangan")
cek_date = fields.Date(string='Tanggal Pengecekan / Penggantian')
@api.depends('cek_date','issue_date')
def _compute_cek_days(self):
for r in self:
# r.cek_days = r.cek_date - r.issue_date
date_1 = datetime.datetime.strptime(r.cek_date, '%Y-%m-%d')
date_2 = datetime.datetime.strptime(r.issue_date, '%Y-%m-%d')
cek_hasil = date_1 - date_2
cek_day = re.sub('[^0-9]', '', str(cek_hasil))
r.cek_days = (int(cek_day))# / 100000
xml
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
The issue might be the r.cek_date or r.issue_date might be returning the value as False, so you are getting this error. By adding a IF statement you can solve this.
def _compute_cek_days(self):
for r in self:
# r.cek_days = r.cek_date - r.issue_date
if r.cek_days and r.issue_date:
date_1 = datetime.datetime.strptime(r.cek_date, '%Y-%m-%d')
date_2 = datetime.datetime.strptime(r.issue_date, '%Y-%m-%d')
cek_hasil = date_1 - date_2
cek_day = re.sub('[^0-9]', '', str(cek_hasil))
r.cek_days = (int(cek_day))# / 100000
In the above code you can see a if condition is added to check whether both variables hold values, you can alter code as per your use case.
Thanks
@niyas raphy : Thanx a lot. its solve ^.^
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
2
jul. 24
|
2608 | ||
|
1
jun. 24
|
5082 | ||
|
1
okt. 23
|
10774 | ||
|
1
okt. 23
|
98 | ||
413 Request Entity Too Large
Opgelost
|
|
1
aug. 23
|
2193 |