Search code examples
widgetodooodoo-9odoo-view

Odoo v9 : In weekly timesheet form view only want current date entry edittable when adding a line


how can I edit weekly_timesheet widget. The xml file calls the widget which is used to add line in the weekly timesheet.

I want user to only edit current date's time in the new or existing line.

How can I do so? Looks easy in XML but I don't know where from I can edit the widget.

regards,


Solution

  • To edit widgets defined in templates, you create a new template and do something similar to this.

    <?xml version="1.0" encoding="UTF-8"?>
    <templates id="template" xml:space="preserve">
        <t t-extend="sales_team.SalesDashboard">
            <t t-jquery=".o_welcome_content" t-operation="replace">
                <div class="o_welcome_content">
                    <h2>Bonjour!</h2>
                    <h4>Une bonne journée commence par un pipeline de ventes bien organisé.</h4>
                    <h4>Ajoutez-lui quelques opportunités!</h4>
                    <a class="btn btn-primary o_dashboard_action" name="crm.action_your_pipeline">Mon pipeline</a>
                </div>
            </t>
        </t>
    </templates>
    

    Here I extend the SalesDashboard widget in the module sales_team. You just put the name of the tag (in my case it was <t t-name="sales_team.SalesDashboard") on the t-extend part.

    Then it's like inheritance of views, but instead of using xpath you use jQuery selectors (so like CSS selector then) and replace, after, before on t-operation. Here's a link on the subject : https://www.odoo.com/documentation/10.0/reference/qweb.html#javascript