[Python] Set default value for date field in portal odoo18

Discussão em 'Python' iniciado por Stack, Abril 30, 2025.

  1. Stack

    Stack Membro Participativo

    In Odoo18, I created template for a portal user which inherit another template, In my custom template, I want a date fields 'birthday' to be auto filled

    <t t-set="last_app" t-value="request.env['hr.applicant'].search([ ('partner_id', '=', partner.id), '|', ('active', '=', False), ('active', '=', True)], order='id desc', limit=1)"/>
    <xpath expr="//input[@name='birthday']" position="replace">
    <input id="birthday_input"
    type="text"
    name="birthday"
    class="form-control o_website_form_date"
    t-att-value="last_app.birthday and last_app.birthday.strftime('%Y-%m-%d') or ''"
    data-date-format="yyyy-mm-dd"
    required="required"
    placeholder="YYYY-MM-DD"/>
    </xpath>


    but I still got a wrong value 01/01/1970

    Continue reading...

Compartilhe esta Página