Skip to Content
Menu
This question has been flagged
4 Replies
10435 Views

Hello,

Working with Odoo 10 community.

So I have made a bit of JS to add some custom class in my PivotView. It's working well so far, but only in the debug=assets mode. I guess I have made some mistake in the way to declare my module with "define".

Here my file from the module "easymile_timesheet" at path "easymile_timesheet/static/src/js/hour_report.js"

odoo.define('easymile_timesheet.hour_report', function (require) {
"use strict";

var PivotView = require ('web.PivotView');

PivotView.include({

display_table: function () {
var self = this;

this._super(parent);
             <My code here>
Avatar
Discard

Your code looks ok. have you js in your xml file?

Best Answer

Hi Mark

You could do it by defining it in an xml like this:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="easymile_timesheet_assets_backend" name="easymile_timesheet assets" inherit_id="web..assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/easymile_timesheet/static/src/js/hour_report.js"></script>
</xpath>
</template>
</data>
</odoo>
Avatar
Discard
Best Answer

I have same problem, js in my module works until i disable the developer mode (with assets).

I've tried different ways to include js in my template:

<xpath expr="." position="inside">


and 

<xpath expr="//script[last()]" position="after">


but both methods works only in developer mode with assets.

also odoo 10.

As bad workaround i've added my  script directly in web.assets_backend in .../dist-packages/odoo/addons/web/views/webclient_templates.xml file.

Please reply, if you solve this problem.

Avatar
Discard

I tried with

<xpath expr="//script[last()]" position="after">

instead of

<xpath expr="." position="inside">

and it works for me!

Author Best Answer

Hi Axel,

I did that, otherwise my code won't be able to work in debug mode.

My question is how to keep it working after all the compressed in one file in production.

Thanks for taking time to answer me.

Marc

Avatar
Discard
Related Posts Replies Views Activity
1
May 25
8019
1
Nov 24
4647
0
May 24
1890
1
Apr 24
1909
1
Jun 22
3402