Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Redirecting trough javascript with window action problem

Subscribe

Get notified when there's activity on this post

This question has been flagged
javascriptnotificationxmlrpcwindow_actionodoo10
2 Replies
8070 Views
Avatar
Samo Arko

I'm trying to create a task with a button on a notification and then redirect to the created record. I'm doing this like the calendars event reminders. So I've extended the notification with a button and added the class. Extended the JS for notification with click event that when its clicked it calls a controller with the action ID. The controller creates the task, fills the res_id for the action and returns it and executes the action.

The problem is that sometimes it redirects and sometimes not and I don't know how to find the problem. When it doesn't redirect it creates the task but the javascript doesn't get the return. The return action has the exactly same data both times.

JS:

var TablaCallNotification = Notification.extend({
template: "TablaCallNotification",

init: function(parent, title, text, eid, show_details) {

this._super(parent, title, text, true, show_details);
this.show_details = show_details;
this.eid = eid;

this.events = _.extend(this.events || {}, {
'click .link2createtask': function() {
var self = this;
this.rpc("/calls/create/task", {
call_id: eid,
action_id: "tabla_asterisk_calls.action_show_call_ticket",
}).then(function(r) {
console.log('Create Task action: ' + r)
return self.do_action(r);
});
this.destroy(true);
},

'click .link2cancel': function() {
this.destroy(true);
},
});
},
});

Notification view

<template>
<t t-name="TablaCallNotification" t-extend="Notification">
<t t-jquery=".o_notification_title > t" t-operation="replace">
<span t-attf-class="link2event eid_{{widget.eid}}">
<t t-esc="widget.title"/>
</span>
</t>
<t t-jquery=".o_notification_content" t-operation="append">
<br/><br/>
<button type="button" class="btn btn-sm btn-primary link2createtask">Ustvari Opravilo</button>
<button type="button" class="btn btn-sm btn-link link2cancel">Cancel</button>
</t>
</t>
</template>

Action

<record id="action_show_call_ticket" model="ir.actions.act_window">
<field name="name">Show Call Ticket</field>
<field name="res_model">project.task</field>
<field name="view_mode">form</field>
<field name="view_id" ref="project.view_task_form2"/>
</record>

When it doesn't redirect to the created task the console.log doesn't get executed. 

I'm using a reverse proxy. The site configuration for SSL is on another server and that one redirects to the Odoo server. So on the Odoo server I get only request only on port 80. 

Odoo.conf

[options]
 

db_host = False
db_port = False
db_user = user
db_password = False
dbfilter = ^%h$

addons_path = /opt/odoo/odoo10/addons,/opt/odoo/customaddons
logfile = /var/log/odoo/odoo.log
log_handler = odoo.sql_db:ERROR
log_level = warn
log_db_level = warn
logrotate = True

longpolling_port = 8072
xmlrpc_port = 8069

proxy_mode = True

workers = 2
max_cron_threads = 1

limit_time_cpu = 600
limit_time_real = 1200

NxginX site conf

server {
listen 80;
server_name somedomain.si;

access_log /var/log/nginx/moj.access.log;
error_log /var/log/nginx/moj.error.log;

proxy_buffers 16 64k;
proxy_buffer_size 128k;

client_max_body_size 24000M;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;

# Proxy Headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;

location / {
proxy_pass http://odoo;
}

location /longpolling {
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_pass http://odoo-lp;
}
}

NginX conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
}

http {
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;
gzip_disable "msie6";

upstream odoo {
server 127.0.0.1:8069 weight=1 fail_timeout=3000s;
}
upstream odoo-lp {
server 127.0.0.1:8072;
}

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

Can someone help me with this problem? Does anyone know what can cause it? I'm really out of ideas. 





 

0
Avatar
Discard
Avatar
Ravi Gadhia
Best Answer

I think it's due to this.destroy(true) in link2createtask.  create task async call take time to complete and before that widget is destroyed no action performs. sometimes it redirects due to async call resolved before destroy 

1
Avatar
Discard
Samo Arko
Author

Thanks for the answer... the first tests look promising.

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

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

Sign up
Related Posts Replies Views Activity
How to remove (x) button in window action?
window_action odoo10
Avatar
0
Jun 21
4299
XMLRPC create picklist in odoo 10 API Solved
xmlrpc odoo10
Avatar
3
Aug 17
7528
openerp where to set response.header
javascript xmlrpc
Avatar
0
Mar 16
6567
how to call javascript function on button with xml in odoo? Solved
javascript xml odoo10
Avatar
Avatar
2
Jun 23
44852
How to replace/update the values on message_ids field in odoo 10.
xmlrpc python2.7 odoo10
Avatar
0
May 23
4053
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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