not able to make an allocation request

Bug #680468 reported by Aline (OpenERP)
26
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP R&D Addons Team 3
Odoo Web Client
Fix Released
Medium
OpenERP R&D Web Team
5.0
Invalid
Undecided
Unassigned
Trunk
Fix Released
Medium
OpenERP R&D Web Team

Bug Description

trunk

in hr holiday, allocation request (from Human Resoucres/Holydays / Allocation Requests).

1) create a new allocation request
2) save or confirm : bug

Traceback (most recent call last):
  File "/home/aline/openerp/trunk/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/aline/openerp/trunk/server/bin/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
  File "/home/aline/openerp/trunk/server/bin/osv/osv.py", line 57, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/aline/openerp/trunk/server/bin/osv/osv.py", line 140, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/aline/openerp/trunk/server/bin/osv/osv.py", line 130, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/aline/openerp/trunk/addons/hr_holidays/hr_holidays.py", line 205, in create
    return super(hr_holidays, self).create(cr, uid, vals, context=context)
  File "/home/aline/openerp/trunk/server/bin/osv/orm.py", line 3748, in create
    self._validate(cr, user, [id_new], context)
  File "/home/aline/openerp/trunk/server/bin/osv/orm.py", line 1051, in _validate
    if not fun(self, cr, uid, ids):
  File "/home/aline/openerp/trunk/addons/hr_holidays/hr_holidays.py", line 254, in _check_date
    date_from = time.strptime(rec['date_from'], '%Y-%m-%d %H:%M:%S')
  File "/usr/lib/python2.6/_strptime.py", line 454, in _strptime_time
    return _strptime(data_string, format)[0]
  File "/usr/lib/python2.6/_strptime.py", line 322, in _strptime
    found = format_regex.match(data_string)
TypeError: expected string or buffer

Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Ajay Patel (OpenERP) (ajay-openerp) wrote :

@Aline

Bug has been Committed revision 4401 in lp:~openerp-report/openobject-addons/report-dev-apa.
will be soon merge in the trunk.

Thanks
apa

Changed in openobject-addons:
status: Confirmed → Fix Released
Revision history for this message
qdp (OpenERP) (qdp) wrote :

fix rejected, i reopen the bug

Changed in openobject-addons:
status: Fix Released → In Progress
Changed in openobject-addons:
importance: High → Critical
affects: openobject-addons → openobject-client-web
Revision history for this message
Aline (OpenERP) (apr-tinyerp) wrote :

i think it doesn't take account the domain defined on the act_window [('type':'add')]

Changed in openobject-client-web:
assignee: OpenERP R&D Addons Team 3 (openerp-dev-addons3) → OpenERP SA's Web Client R&D (openerp-dev-web)
Revision history for this message
Ajay Patel (OpenERP) (ajay-openerp) wrote :

@Aline

context is not updated when you test in new fresh database.
when you got the problem, then restart the client and after context is updated.
May be it is also problem in GTK client.

Thanks,
apa

Revision history for this message
Vaibhav Darji (vaibhav-openerp) wrote :

Hello Aline,

It's working fine in Web client but not in GTK client.

web-client rev:4067
trunk-server rev:3082
gtk-client rev:1711
trunk-addon: 3987

Thanks.

Changed in openobject-client-web:
status: In Progress → Invalid
Revision history for this message
Aline (OpenERP) (apr-tinyerp) wrote :

I tested again, and bug is still there. If i restart the client, i have no bug anymore.

VDA you can reproduce with a new db, try to create an allocation request -> bug. Restart your client, no more bug.
Can you try to fix it ?

thanks

Changed in openobject-client-web:
importance: Critical → Medium
status: Invalid → Confirmed
Changed in openobject-client-web:
status: Confirmed → In Progress
Changed in openobject-client:
assignee: nobody → OpenERP sa GTK client R&D (openerp-dev-gtk)
status: New → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

From we tested, something very fishy is going on in the clients. This error only occurs if you start a fresh new client, install a new database with it, install hr_holidays, then go to open the HR/Holidays/Allocation Requests screen.

In that case only, the context of the action is not applied, so when creating new requests in the next screen the create() method is called with only a partial context, where 'type:"add"' is missing, even though it is in the action definition.

For some undetermined reason, having the client call "res.users.context_get()" seems to cure the problem, which means that if you trigger it by logging out and back in the client, or by simply changing your user preferences, the problem goes away if you open the action again (and the correct context is passed).

To correctly solve this problem we need the GTK and Web team to explain precisely why this happens initially, and why this is linked to the reloading of context_get at some point?

Even weirder: after solving it by forcing a context_get call, you will not be able to reproduce it, even after creating a new db, unless you restart the client first (at least in GTK)

Changed in openobject-client:
status: Confirmed → In Progress
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Olivier,

This is what happens in the gtk client:Gtk client just update the session's context only when the user creates a new session or he/she changes his preferences.

looking at the example above:

when the client tries to eval the context of the action from the session.context
action context is :{"search_default_my_leaves": 1,'type':'add',"search_default_department_id": department_id}
so now here a traceback appears because the client session context is does not know that the context has a new field department_id to be added and results in this :

ERROR:tools.expr_eval:{"search_default_my_leaves": 1,'type':'add',"search_default_department_id": department_id}
Traceback (most recent call last):
  File "/home/nch/OpenERP0910/Devs/Trunk/client/bin/tools/__init__.py", line 51, in expr_eval
    temp = eval(string, context)
  File "<string>", line 1, in <module>
NameError: name 'department_id' is not defined

which fails the update of the client's local context

Thanks,

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Ok correction, after discussing more with GTK team, the real issue is simply that the clients fail to evaluate the context in some c
cases because it contains this:
  {"search_default_my_leaves": 1,'type':'add',"search_default_department_id": department_id}

Notice the "department_id" variable at the end? This special trick is allowed to access "context_"-prefixed fields from the global session context. But it fails if the HR module was only recently installed, and the session context has not been reloaded since then, and thus does not have any "context_department_id" value.

Hence the strange behavior we were seeing.

Now as to fix this, unfortunately the server does not have any way of notifying the client about new session context items.. the 2 cases where the session context is reloaded are hardcoded: upon login and when clicking on the OK button in the user preferences popup.

Changed in openobject-client:
status: In Progress → Triaged
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

can't we use "context.get('department_id', False)" instead of department_id ?

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

+ 1

yes, the context should be fetched like that only.
or
restart the client which does not seems feasible

Transferring the post to addons-3 team to make the corrections.

Thanks !

affects: openobject-client → openerp-addons
Changed in openerp-addons:
assignee: OpenERP sa GTK client R&D (openerp-dev-gtk) → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
affects: openerp-addons → openobject-addons
Changed in openobject-addons:
status: Triaged → In Progress
Changed in openobject-addons:
importance: Undecided → Medium
Revision history for this message
Purnendu Singh (OpenERP) (purnendu-singh) wrote :

Hello Aline,

Tested with latest addons and seems it is fixed. So, i am closing this bug. If you still facing same problem feel free to reopen this bug.

Thanks

Changed in openobject-addons:
status: In Progress → Fix Released
Changed in openobject-addons:
milestone: none → 6.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.