Showing DateTime field

I have below class:

class RaRemark(ModelSQL, ModelView):
    "RA Remark"
    __name__ = 'afx.crm.ra.remark'

    parent = fields.Many2One('afx.crm.ra', 'Parent')
    remark = fields.Text('Remark', required=True)
    datetime = fields.DateTime('Date Time', required=True)
    phase = fields.Selection([], 'Phase', sort=False)

    @classmethod
    def __setup__(cls):
        cls.phase.selection = cls._get_phases()
        super(RaRemark, cls).__setup__()
        
    @classmethod
    def default_datetime(cls):
        return dt.datetime.now()

Then I have below tree xml to display the above class:

<tree>
   <field name="datetime"/>
   <field name="remark"/>
   <field name="phase"/>
</tree>

When ever I try to render this in browser, I got error like below:

But when I comment out the field ‘datetime’, all works well. Did I missed something?

Bromo

There is no datetime widget for tree view. So you must split the field into one date and another time widget.

You can do that by updating your view to:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.