verify_interest_invoice_status.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. (function() {
  2. openerp.widgetInstanceInterestInvoiceVerifyState = null;
  3. openerp.parentInstanceInterestInvoiceVerifyState = {};
  4. var QWeb = openerp.web.qweb;
  5. var instanceWeb = openerp.web;
  6. openerp.VerifyInterestInvoiceVerifyState = openerp.Widget.extend({
  7. template: 'verifyInterestInvoice.Status',
  8. buttons: undefined,
  9. accountInvoice: [],
  10. insteresConfig: [],
  11. /* init */
  12. init: function(parent) {
  13. this._super(parent);
  14. this.buttons = parent.$buttons;
  15. },
  16. start: function () {
  17. var self = this;
  18. this.$el.click(function(){
  19. self.fetchInitial();
  20. });
  21. },
  22. /* Reload Page*/
  23. reloadPage: function() {
  24. openerp.parentInstanceInterestInvoiceVerifyState.reload();
  25. },
  26. // /* Método inicial */
  27. fetchInitial: function() {
  28. var self = this;
  29. self.verifyInvoiceState().then(function(accountInvoice){
  30. return accountInvoice;
  31. }).then(function(accountInvoice) {
  32. self.accountInvoice = accountInvoice;
  33. instanceWeb.notification.do_warn("Atencion","Verificación Terminada.");
  34. return self.reloadPage();
  35. });
  36. },
  37. /* Verificar Estado de las factura */
  38. verifyInvoiceState: function() {
  39. var invoice = new instanceWeb.Model('account.invoice');
  40. return invoice.call('eiru_invoice_verify_status',{
  41. context: new instanceWeb.CompoundContext()
  42. });
  43. }
  44. });
  45. if (openerp.web && openerp.web.FormView) {
  46. openerp.web.FormView.include({
  47. load_record: function(record) {
  48. this._super.apply(this, arguments);
  49. if (this.model !== 'account.interest.config')
  50. return;
  51. openerp.parentInstanceInterestInvoiceVerifyState = this;
  52. if (openerp.widgetInstanceInterestInvoiceVerifyState) {
  53. if (this.$el.find('.button-invoice-state').length !== 0)
  54. return;
  55. }
  56. if (this.$el.find('.button-invoice-state').length !== 0)
  57. return;
  58. openerp.widgetInstanceInterestInvoiceVerifyState = new openerp.VerifyInterestInvoiceVerifyState(this);
  59. var element =this.$el.find('.oe_form').find('.verify-interest-invoice-state');
  60. openerp.widgetInstanceInterestInvoiceVerifyState.appendTo(element[0]);
  61. }
  62. });
  63. }
  64. })();