You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. openerp.web_warning_sound = function(instance) {
  2. var QWeb = instance.web.qweb;
  3. var _t = instance.web._t;
  4. instance.web.FormView = instance.web.FormView.extend({
  5. on_processed_onchange: function(result, processed) {
  6. try {
  7. if (!_.isEmpty(result.sound)) {
  8. var audio = new Audio(result.sound);
  9. audio.play();
  10. }
  11. } catch(e) {
  12. console.error(e);
  13. }
  14. return this._super.apply(this, arguments);
  15. },
  16. });
  17. instance.web.CrashManager = instance.web.CrashManager.extend({
  18. show_warning: function(error) {
  19. if (!this.active) {
  20. return;
  21. }
  22. var re = /{{\s*sound\s*:\s*(\S*)+\s*}}/;
  23. var matches = error.data.fault_code.match(re);
  24. if (matches && matches.length == 2) {
  25. var audio = new Audio(matches[1]);
  26. audio.play();
  27. error.data.fault_code = error.data.fault_code.replace(re, '');
  28. }
  29. return this._super.apply(this, arguments);
  30. },
  31. });
  32. }