I'm trying to add number of week in the grid of timesheet in Odoo V16.
But my new function in my inherit js doesn't be call and i don't know why ?
This is my xml file (inherit from web_grid) :
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-inherit="web_grid.Table" t-inherit-mode="extension" owl="1">
<xpath expr="//th[@class='o_grid_title_header']" position="inside">
<b>"<t t-esc="numberWeek"/>"</b>
</xpath>
</t>
</templates>
And this is my inherit js (inherit from web_grid.grid_renderer.js) :
odoo.define('my_custom_addon.GridRenderer', function (require) {
"use strict";
var GridRenderer = require('web_grid.GridRenderer');
class ModifiedGridRenderer extends GridRenderer {
get numberWeek() {
console.log(this.props.timeBoundariesContext);
return "Week 26";
};
};
return ModifiedGridRenderer;
});
My xml file is correctly inherit because when i had manually number week, it appear without problems. But when i use my function numberWeek in my xml, i don't have any error but nothing appear.
Do you have any idea ?
Thank's in advance :)
The thing it's that your Custom Renderer ModifiedGridRenderer
wouldn't be used at all by the Grid View
You could patch the original GridRenderer
OWL Component to add your function
or
You could directly set the GridView.config.Renderer = ModifiedGridRenderer
in order to be used by the GridView