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.

86 lines
3.1 KiB

  1. odoo.define('account_financial_report.account_financial_report_widget', function
  2. (require) {
  3. 'use strict';
  4. var Widget = require('web.Widget');
  5. var accountFinancialReportWidget = Widget.extend({
  6. events: {
  7. 'click .o_account_financial_reports_web_action':
  8. 'boundLink',
  9. 'click .o_account_financial_reports_web_action_multi':
  10. 'boundLinkmulti',
  11. 'click .o_account_financial_reports_web_action_monetary':
  12. 'boundLinkMonetary',
  13. 'click .o_account_financial_reports_web_action_monetary_multi':
  14. 'boundLinkMonetarymulti',
  15. },
  16. init: function () {
  17. this._super.apply(this, arguments);
  18. },
  19. start: function () {
  20. return this._super.apply(this, arguments);
  21. },
  22. boundLink: function (e) {
  23. var res_model = $(e.target).data('res-model');
  24. var res_id = $(e.target).data('active-id');
  25. return this.do_action({
  26. type: 'ir.actions.act_window',
  27. res_model: res_model,
  28. res_id: res_id,
  29. views: [[false, 'form']],
  30. target: 'current',
  31. });
  32. },
  33. boundLinkmulti: function (e) {
  34. var res_model = $(e.target).data('res-model');
  35. var domain = $(e.target).data('domain');
  36. if (!res_model) {
  37. res_model = $(e.target.parentElement).data('res-model');
  38. }
  39. if (!domain) {
  40. domain = $(e.target.parentElement).data('domain');
  41. }
  42. return this.do_action({
  43. type: 'ir.actions.act_window',
  44. name: this._toTitleCase(res_model.split('.').join(' ')),
  45. res_model: res_model,
  46. domain: domain,
  47. views: [[false, "list"], [false, "form"]],
  48. target: 'current',
  49. });
  50. },
  51. boundLinkMonetary: function (e) {
  52. var res_model = $(e.target.parentElement).data('res-model');
  53. var res_id = $(e.target.parentElement).data('active-id');
  54. return this.do_action({
  55. type: 'ir.actions.act_window',
  56. res_model: res_model,
  57. res_id: res_id,
  58. views: [[false, 'form']],
  59. target: 'current',
  60. });
  61. },
  62. boundLinkMonetarymulti: function (e) {
  63. var res_model = $(e.target.parentElement).data('res-model');
  64. var domain = $(e.target.parentElement).data('domain');
  65. return this.do_action({
  66. type: 'ir.actions.act_window',
  67. res_model: res_model,
  68. domain: domain,
  69. views: [[false, "list"], [false, "form"]],
  70. target: 'current',
  71. });
  72. },
  73. _toTitleCase: function (str) {
  74. return str.replace(/\w\S*/g, function (txt) {
  75. return txt.charAt(0).toUpperCase() +
  76. txt.substr(1).toLowerCase();
  77. });
  78. },
  79. });
  80. return accountFinancialReportWidget;
  81. });