This question has been flagged
2 Replies
259 Views

This is my error: 


RPC_ERROR

Odoo Server Error

Traceback (most recent call last):

  File "/home/odoo/src/odoo/saas-16.4/odoo/tools/safe_eval.py", line 365, in safe_eval

    return unsafe_eval(c, globals_dict, locals_dict)

  File "", line 6, in

TypeError: 'wrap_module' object is not callable


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1715, in _serve_db

    return service_model.retrying(self._serve_ir_http, self.env)

  File "/home/odoo/src/odoo/saas-16.4/odoo/service/model.py", line 133, in retrying

    result = func()

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1742, in _serve_ir_http

    response = self.dispatcher.dispatch(rule.endpoint, args)

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 1943, in dispatch

    result = self.request.registry['ir.http']._dispatch(endpoint)

  File "/home/odoo/src/odoo/saas-16.4/odoo/addons/base/models/ir_http.py", line 191, in _dispatch

    result = endpoint(**request.params)

  File "/home/odoo/src/odoo/saas-16.4/odoo/http.py", line 717, in route_wrapper

    result = endpoint(self, *args, **params_ok)

  File "/home/odoo/src/odoo/saas-16.4/addons/web/controllers/dataset.py", line 30, in call_kw

    return self._call_kw(model, method, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/addons/web/controllers/dataset.py", line 26, in _call_kw

    return call_kw(request.env[model], method, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/api.py", line 466, in call_kw

    result = _call_kw_multi(method, model, args, kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/api.py", line 453, in _call_kw_multi

    result = method(recs, *args, **kwargs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6781, in onchange

    todo = [

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6784, in

    if name not in done and snapshot0.has_changed(name)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6584, in has_changed

    return self[name] != record[name]

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 6211, in __getitem__

    return self._fields[key].__get__(self, type(self))

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1157, in __get__

    self.recompute(record)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1367, in recompute

    apply_except_missing(self.compute_value, recs)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1340, in apply_except_missing

    func(records)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 1389, in compute_value

    records._compute_field_value(self)

  File "/home/odoo/src/odoo/saas-16.4/addons/base_automation/models/base_automation.py", line 434, in _compute_field_value

    _compute_field_value.origin(self, field)

  File "/home/odoo/src/odoo/saas-16.4/addons/mail/models/mail_thread.py", line 395, in _compute_field_value

    return super()._compute_field_value(field)

  File "/home/odoo/src/odoo/saas-16.4/odoo/models.py", line 4553, in _compute_field_value

    fields.determine(field.compute, self)

  File "/home/odoo/src/odoo/saas-16.4/odoo/fields.py", line 104, in determine

    return needle(records, *args)

  File "/home/odoo/src/odoo/saas-16.4/odoo/addons/base/models/ir_model.py", line 38, in

    func = lambda self: safe_eval(text, SAFE_EVAL_BASE, {'self': self}, mode="exec")

  File "/home/odoo/src/odoo/saas-16.4/odoo/tools/safe_eval.py", line 379, in safe_eval

    raise ValueError('%s: "%s" while evaluating\n%r' % (ustr(type(e)), ustr(e), expr))

ValueError: : "'wrap_module' object is not callable" while evaluating

'for record in self:\n    if record.x_studio_contract_duration_months ==0:\n       record["x_studio_contract_target_end_date"] = record.x_studio_contract_target_start_date \n       \n    if (record.x_studio_contract_target_start_date and record.x_studio_contract_duration_months):\n        future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta(months=+record.x_studio_contract_duration_months)\n        print(future_date)\n        record["x_studio_contract_target_end_date"] = future_date - datetime.timedelta(days=1)\n'


The above server error caused the following client error:

null


And this is the code I am using for: 
for record in self:

    if record.x_studio_contract_duration_months ==0:

       record["x_studio_contract_target_end_date"] = record.x_studio_contract_target_start_date 

       

    if (record.x_studio_contract_target_start_date and record.x_studio_contract_duration_months):

        future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta(months=+record.x_studio_contract_duration_months)

        print(future_date)

        record["x_studio_contract_target_end_date"] = future_date - datetime.timedelta(days=1)


Thanks in advance! 

Avatar
Discard
Best Answer

Hi,In the given question, an attempt is made to add months which could potentially lead to an error. This is due to the usage of 'dateutil.relativedelta' with an argument of months equals to plus record.x_studio_contract_duration_months. The corrected solution uses 'dateutil.relativedelta.relativedelta' with an argument of months equals to record.x_studio_contract_duration_months to accurately apply the relative difference for adding months in date calculations. The key difference is in the correct usage of the relativedelta method for proper date manipulation. This change ensures that the months are added correctly.

By following these steps, you should be able to diagnose and potentially resolve the issue with the missing Studio tabs in your Odoo database.


Hope it helps

Avatar
Discard
Best Answer

try to update the code with this:

future_date = record.x_studio_contract_target_start_date + dateutil.relativedelta.relativedelta(months=+record.x_studio_contract_duration_months)



Avatar
Discard