Tryton - Issues



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

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

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?

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/
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):
    __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')

    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">
                <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"/>
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:

line 338, in sig_new

line 430, in new

line 342, in switch_view, context=context)

line 447, in new
    group.add(record, self.new_model_position())

line 284, in add
    self.signal('group-changed', record)

line 14, in signal
    fnct(self, signal_data, *data)

line 245, in _group_changed

line 694, in display

line 140, in display
    widget.display(record, field)

line 61, in display
    value = field.get_client(record)

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/", line 123, in _marshaled_dispatch
    response['result'] = dispatch_method(method, params)
  File "/trytond/protocols/", line 156, in _dispatch
    res = dispatch(*args)
  File "/trytond/protocols/", line 154, in dispatch
    result = rpc.result(meth(*args, **kwargs))
  File "/trytond/model/", line 326, in create
  File "/trytond/backend/postgresql/", 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.
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)