Tryton - Issues

 

Issue2991

Title Time field broken in 2.6
Priority bug Status resolved
Superseder Nosy List ced, oscar, shalabhaggarwal
Type crash Components
Assigned To ced Keywords
Reviews

Created on 2013-02-06.13:17:18 by shalabhaggarwal, last changed by ced.

Messages
msg12663 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-03-06.23:41:51
No news since 1 month, issue should be solved. Re-open it if not.
msg12456 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-02-07.00:55:55
On 07/02/13 00:48 +0100, Oscar Andres Alvarez wrote:
> I didn't find rev cb6a50d8832a?

Here http://hg.tryton.org/2.6/tryton/rev/cb6a50d8832a
msg12455 (view) Author: [hidden] (oscar) (Tryton translator) Date: 2013-02-07.00:48:06
I didn't find rev cb6a50d8832a?

But this fix it the problem, now I am testing.... 

file: /tryton/gui/window/view_form/model/field.py
line: 271

-  if value is not None:
       return value.strftime(self.time_format(record))
 
+  if value:
       return value.strftime(self.time_format(record))
msg12454 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-02-06.22:52:12
Have you the rev cb6a50d8832a ?
msg12453 (view) Author: [hidden] (oscar) (Tryton translator) Date: 2013-02-06.22:24:50
#This is my code

from trytond.model import ModelView, ModelSQL, fields

__all__ = ['Timetable']

class Timetable(ModelSQL, ModelView):
    'Timetable'
    __name__ = 'education.timetable'
    day_week = fields.Selection([
            ('monday', 'Monday'),
            ('tuesday', 'Tuesday'),
            ('wednesday', 'Wednesday'),
            ('thursday', 'Thursday'),
            ('friday', 'Friday'),
            ('saturday', 'Saturday'),
            ('sunday', 'Sunday'),
            ], 'Day Of The Week', required=True, readonly=True)
    hour_start = fields.Time('Hour Start')
    hour_end = fields.Time('Hour End')
    classe = fields.Many2One('education.classe', 'Class', required=True)
    classroom = fields.Many2One('education.location', 'Location')

    @classmethod
    def __setup__(cls):
        super(Timetable, cls).__setup__()

#And xml file

        <record model="ir.ui.view" id="timetable_view_form">
            <field name="model">education.timetable</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <![CDATA[
                <form string="Timetable">
                    <label name="day_week"/>
                    <field name="day_week"/>
                    <label name="classe"/>
                    <field name="classe"/>
                    <label name="hour_start"/>
                    <field name="hour_start"/>
                    <label name="hour_end"/>
                    <field name="hour_end"/>
                    <label name="classroom"/>
                    <field name="classroom"/>
                </form>
                ]]>
            </field>
        </record>
msg12452 (view) Author: [hidden] (oscar) (Tryton translator) Date: 2013-02-06.22:21:58
I have the same problem in a new module, I think is a bug, I reviewed (several
times) my code and all seems fine.

"'str' object has no attribute 'strftime'"

This is the traceback:

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/form.py",
line 338, in sig_new
    self.screen.new()

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/screen/screen.py",
line 430, in new
    self.switch_view()

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/screen/screen.py",
line 342, in switch_view
    self.new(default=default, context=context)

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/screen/screen.py",
line 447, in new
    group.add(record, self.new_model_position())

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/model/group.py",
line 284, in add
    self.signal('group-changed', record)

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/signal_event.py",
line 14, in signal
    fnct(self, signal_data, *data)

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/screen/screen.py",
line 245, in _group_changed
    self.display()

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/screen/screen.py",
line 694, in display
    view.display()

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/view/form.py",
line 140, in display
    widget.display(record, field)

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/view/form_gtk/calendar.py",
line 61, in display
    value = field.get_client(record)

  File
"/usr/local/lib/python2.7/dist-packages/tryton-2.6.1-py2.7.egg/tryton/gui/window/view_form/model/field.py",
line 272, in get_client
    return value.strftime(self.time_format(record))

This occurs in form view of the model, becauce in Tree view don't show this
problem. My model don't have default value for Time field, but just when I
remove the fields in the .xml file (view form) the crash go away.
msg12449 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-02-06.18:19:11
I tested on 2.6 and fields.Time works correctly for me.
Could you show the code your are using?
msg12448 (view) Author: [hidden] (shalabhaggarwal) Date: 2013-02-06.14:09:07
I tried with the following:

1. Without a default. [Gives same error as defined first]

2. With a default of datetime.time(). [Gives same error as defined first]

3. With a default of datetime.time(9, 00, 00). [The form loads correctly with the right value but breaks while saving with the 
error below]

Traceback (most recent call last):
  File "/trytond/protocols/jsonrpc.py", line 123, in _marshaled_dispatch
    response['result'] = dispatch_method(method, params)
  File "/trytond/protocols/jsonrpc.py", line 156, in _dispatch
    res = dispatch(*args)
  File "/trytond/protocols/dispatcher.py", line 154, in dispatch
    result = rpc.result(meth(*args, **kwargs))
  File "/trytond/model/modelsql.py", line 326, in create
    tuple(upd2))
  File "/trytond/backend/postgresql/database.py", line 307, in execute
    res = self.cursor.execute(sql, params)
ProgrammingError: column "in_time" is of type timestamp without time zone but expression is of type time without time zone
LINE 1: ..., create_date) VALUES ( NULL, '2013-02-06'::date, '09:00:00'...
                                                             ^
HINT:  You will need to rewrite or cast the expression.
msg12447 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2013-02-06.13:48:02
Did you put a default value for this field?
If yes, which one?
msg12446 (view) Author: [hidden] (shalabhaggarwal) Date: 2013-02-06.13:17:17
The `Time` field seems broken is 2.6.

Below is the stacktrace of the error:

File "tryton/gui/window/form.pyc", line 338, in sig_new

  File "tryton/gui/window/view_form/screen/screen.pyc", line 449, in new

  File "tryton/gui/window/view_form/screen/screen.pyc", line 694, in display

  File "tryton/gui/window/view_form/view/form.pyc", line 137, in display

  File "tryton/gui/window/view_form/view/form_gtk/calendar.pyc", line 61, in display

  File "tryton/gui/window/view_form/model/field.pyc", line 272, in get_client

Error: 'str' object has no attribute 'strftime'

I have tried this on Mac as well as Linux clients. It breaks on both with same error.
History
Date User Action Args
2013-03-06 23:41:52cedsetstatus: testing -> resolved
assignedto: ced
messages: + msg12663
2013-02-07 00:55:55cedsetmessages: + msg12456
2013-02-07 00:48:07oscarsetmessages: + msg12455
2013-02-06 22:52:13cedsetstatus: need-eg -> testing
messages: + msg12454
2013-02-06 22:24:51oscarsetmessages: + msg12453
2013-02-06 22:21:59oscarsetnosy: + oscar
messages: + msg12452
2013-02-06 18:19:12cedsetmessages: + msg12449
2013-02-06 14:09:08shalabhaggarwalsetmessages: + msg12448
2013-02-06 13:48:02cedsetstatus: unread -> need-eg
nosy: + ced
messages: + msg12447
2013-02-06 13:17:18shalabhaggarwalcreate

Showing 10 items. Show all history (warning: this could be VERY long)