Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
4 Replies
10449 Tampilan

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
Buang

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

Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang

I tried with

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

instead of

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

and it works for me!

Penulis Jawaban Terbai

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Mei 25
8062
1
Nov 24
4699
0
Mei 24
1925
1
Apr 24
1935
1
Jun 22
3417