Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How to declare my JS for my module

Subscriure's

Get notified when there's activity on this post

This question has been flagged
javascriptjsdefine10.0
4 Respostes
10962 Vistes
Avatar
Marc Aubry

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>
1
Avatar
Descartar
Mohammed Amal N

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

Avatar
Axel Mendoza
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>
1
Avatar
Descartar
Avatar
Dima_vv
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.

1
Avatar
Descartar
cabrejua

I tried with

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

instead of

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

and it works for me!

Avatar
Marc Aubry
Autor 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

0
Avatar
Descartar
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
how to read field values using js Solved
javascript js
Avatar
Avatar
1
de maig 25
9095
Patch JS function that doesn't belong to a class Solved
javascript js patch
Avatar
1
de nov. 24
6246
Trouble Importing JavaScript Between Custom Odoo Modules
javascript inheritance js
Avatar
0
de maig 24
3366
Odoo 14: Reload Point Of Sale Solved
javascript js point_of_sale
Avatar
Avatar
1
d’abr. 24
2817
NumpadState in POS
pos js 10.0
Avatar
Avatar
1
de juny 22
3939
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now