Skip to Content
Menu
This question has been flagged

I'd like to show a last updated time among the time sheets in task.

So I made a class below to get time sheet and calculate which one is last one.

class Project_time_sheet_last_update(models.Model):
_name = "project.task"
_inherit = ['project.task']
_logger.debug("=========================================== project task start ====================================")
timesheet_ids = fields.One2many("account.analytic.line", "task_id", string="Time Sheet ID")

@api.one
@api.depends("timesheet_ids", "timesheet_ids.__last_update")
def _calclastupdate(self):

last_update = datetime.datetime(2009, 10, 5, 18, 00)
for timesheet in self.timesheet_ids:
_logger.error("============================================= last update : %s =========================================" % timesheet.__last_update)
# currentcalories = currentcalories + (mealitem.calories * mealitem.servings)
if last_update < timesheet.__last_update:
last_update = timesheet.__last_update

self.timesheet_update = last_update

timesheet_update = fields.Datetime(string="Last Updated Time Sheet", store=True, compute="_calclastupdate")

 But the problem is I get an error

2017-05-08 07:49:14,288 4761 ERROR odootest9 openerp.modules.registry: Failed to load registry Traceback (most recent call last):

  File "/odoo/odoocom/openerp/modules/registry.py", line 386, in new

    openerp.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/odoo/odoocom/openerp/modules/loading.py", line 336, in load_modules

    force, status, report, loaded_modules, update_module)

  File "/odoo/odoocom/openerp/modules/loading.py", line 239, in load_marked_modules

    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

  File "/odoo/odoocom/openerp/modules/loading.py", line 136, in load_module_graph

    registry.setup_models(cr, partial=True)

  File "/odoo/odoocom/openerp/modules/registry.py", line 200, in setup_models

    model._setup_fields(cr, SUPERUSER_ID, partial)

  File "/odoo/odoocom/openerp/api.py", line 250, in wrapper

    return old_api(self, *args, **kwargs)

  File "/odoo/odoocom/openerp/api.py", line 354, in old_api

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

  File "/odoo/odoocom/openerp/models.py", line 3056, in _setup_fields

    field.setup_full(self)

  File "/odoo/odoocom/openerp/fields.py", line 496, in setup_full

    self._setup_regular_full(model)

  File "/odoo/odoocom/openerp/fields.py", line 1903, in _setup_regular_full

    invf = comodel._fields[self.inverse_name]

KeyError: 'task_id'

2017-05-08 07:49:14,290 4761 INFO odootest9 werkzeug: 127.0.0.1 - - [08/May/2017 07:49:14] "POST /longpolling/poll HTTP/1.0" 500 - 2017-05-08 07:49:14,297 4761 ERROR odootest9 werkzeug: Error on request:

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 193, in run_wsgi

    execute(self.server.app)

  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 181, in execute

    application_iter = app(environ, start_response)

  File "/odoo/odoocom/openerp/service/server.py", line 246, in app

    return self.app(e, s)

  File "/odoo/odoocom/openerp/service/wsgi_server.py", line 184, in application

    return application_unproxied(environ, start_response)

  File "/odoo/odoocom/openerp/service/wsgi_server.py", line 170, in application_unproxied

    result = handler(environ, start_response)

  File "/odoo/odoocom/openerp/http.py", line 1495, in __call__

    return self.dispatch(environ, start_response)

  File "/odoo/odoocom/openerp/http.py", line 1469, in __call__

    return self.app(environ, start_wrapped)

  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 599, in __call__

    return self.app(environ, start_response)

  File "/odoo/odoocom/openerp/http.py", line 1644, in dispatch

    ir_http = request.registry['ir.http']

  File "/odoo/odoocom/openerp/http.py", line 365, in registry

    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None

  File "/odoo/odoocom/openerp/modules/registry.py", line 355, in get

    update_module)

  File "/odoo/odoocom/openerp/modules/registry.py", line 386, in new

    openerp.modules.load_modules(registry._db, force_demo, status, update_module)

  File "/odoo/odoocom/openerp/modules/loading.py", line 336, in load_modules

    force, status, report, loaded_modules, update_module)

  File "/odoo/odoocom/openerp/modules/loading.py", line 239, in load_marked_modules

    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)

  File "/odoo/odoocom/openerp/modules/loading.py", line 136, in load_module_graph

    registry.setup_models(cr, partial=True)

  File "/odoo/odoocom/openerp/modules/registry.py", line 200, in setup_models

    model._setup_fields(cr, SUPERUSER_ID, partial)

  File "/odoo/odoocom/openerp/api.py", line 250, in wrapper

    return old_api(self, *args, **kwargs)

  File "/odoo/odoocom/openerp/api.py", line 354, in old_api

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

  File "/odoo/odoocom/openerp/models.py", line 3056, in _setup_fields

    field.setup_full(self)

  File "/odoo/odoocom/openerp/fields.py", line 496, in setup_full

    self._setup_regular_full(model)

  File "/odoo/odoocom/openerp/fields.py", line 1903, in _setup_regular_full

    invf = comodel._fields[self.inverse_name]

KeyError: 'task_id'


Please help

Avatar
Discard
Author

The Error message has been changed to

ProgrammingError: column project_task.timesheet_update does not exist LINE 1: ..._line_id","project_task"."sequence" as "sequence","project_t...

Related Posts Replies Views Activity
2
Mar 15
5497
0
Mar 15
2490
0
Aug 19
1862
2
Jul 19
3272
1
Aug 24
2710