This question has been flagged
1 Reply
5336 Views

I am using Odoo v9 and receive the following TypeError when I open the page to look at the calendar and also when I click on the calendar to create an event. I believe the problem is either date_start references a String and not a DateTime, or I need to specify additional fields in the Calendar view. How do I fix this issue?

My class in Python:

class Appointments(models.Model):

   apt_date_start = fields.Datetime()

   apt_date_stop = fields.Datetime()

   notes = fields.Char()


Calendar view

 <record id="fix_tribe_appointments_calendar" model="ir.ui.view">

    <field name="name">FixTribe Appointments Calendar</field>

    <field name="model">fix_tribe.appointments</field>

    <field name="arch" type="xml">

        <calendar string="Appointments"

            mode="day"   date_stop="apt_date_stop"

            date_start="apt_date_start" quick_add="False" >

            <field name="notes"/>

        </calendar>

    </field>

</record>



The error:

Uncaught TypeError: Cannot read property 'type' of undefined

http://localhost:8069/web/content/714-5d121d4/web.assets_backend.js:4746
Traceback:
TypeError: Cannot read property 'type' of undefined
    at http://localhost:8069/web/content/714-5d121d4/web.assets_backend.js:4746:165
    at Function._.each._.forEach (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:12:558)
    at Object.<anonymous> (http://localhost:8069/web/content/714-5d121d4/web.assets_backend.js:4746:110)
    at fire (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:644:299)
    at Object.self.fireWith [as resolveWith] (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:649:198)
    at Object.<anonymous> (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:650:874)
    at fire (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:644:299)
    at Object.self.fireWith [as resolveWith] (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:649:198)
    at Object.deferred.(anonymous function) (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:651:56)
    at fire (http://localhost:8069/web/content/703-114de7a/web.assets_common.js:644:299)
Avatar
Discard

Hi Trevor,

I know the post is quite old but I do have the same issue on exactly same Odoo version (v9). How did you solve the error? Thank you in advance

Author

Hey Paulo. You're right about this being a very old post! Unfortunately, I don't know how or if the problem was solved. I quit working with Odoo because I found it to be very poorly documented. Perhaps this has changed in recent years. Based on my experience, I recommend searching for a different framework entirely. Best of luck, Trevor.

Best Answer

Hello Trevor,


You give date_start field as a Char which is wrong for the Calendar view.


Change type of apt_date_start  Char to Datetime.

apt_date_start = fields.Datetime()

and also import datetime through

from datetime import datetime


Thanks,

Avatar
Discard
Author

I've put out a new version (now shown in the post) that changed Char to Datetime, but the error persists. I even cascaded dropped the Appointments table, and added on an end time to see if that would work. Still doesn't