|
@@ -0,0 +1,104 @@
|
|
|
+(function() {
|
|
|
+
|
|
|
+ var QWeb = openerp.web.qweb;
|
|
|
+ openerp.widgetInstance = null;
|
|
|
+ openerp.PurchasesButtons = {};
|
|
|
+
|
|
|
+ openerp.PurchasesButtons = openerp.Widget.extend({
|
|
|
+ template: 'purchases_buttons.PurchasesButtonsWidget',
|
|
|
+ row_id_select: undefined,
|
|
|
+
|
|
|
+ init: function (parent) {
|
|
|
+ this._super(parent);
|
|
|
+ },
|
|
|
+
|
|
|
+ start: function () {
|
|
|
+ var self = this;
|
|
|
+ var modal_button = this.$el.find('.add-purchase-modal');
|
|
|
+ modal_button.click(function() {
|
|
|
+ self.fectchModal();
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ updateId: function(id) {
|
|
|
+ var self = this;
|
|
|
+ self.id = id;
|
|
|
+ },
|
|
|
+
|
|
|
+ removeModal: function() {
|
|
|
+ $('.purchases-modal').remove();
|
|
|
+ $('.modal-backdrop').remove();
|
|
|
+ },
|
|
|
+
|
|
|
+ fectchModal: function() {
|
|
|
+ var self = this;
|
|
|
+ self.showModal();
|
|
|
+ },
|
|
|
+
|
|
|
+ showModal: function() {
|
|
|
+ var self = this;
|
|
|
+ var defer =$.Deferred();
|
|
|
+ var results = true;
|
|
|
+
|
|
|
+ var modal = QWeb.render('PurchaseModal');
|
|
|
+ $('.openerp_webclient_container').after(modal);
|
|
|
+ $('.purchases-modal').modal();
|
|
|
+
|
|
|
+ $('.purchase').click(function(){
|
|
|
+
|
|
|
+ self.do_action({
|
|
|
+
|
|
|
+ type: 'ir.actions.client',
|
|
|
+ tag: "eiru_purchases.action_launch",
|
|
|
+ target: 'current',
|
|
|
+ params: {'mode': 'purchase'},
|
|
|
+ context: self.session.user_context,
|
|
|
+
|
|
|
+ });
|
|
|
+ self.removeModal();
|
|
|
+ });
|
|
|
+ $('.expense').click(function(){
|
|
|
+
|
|
|
+ self.do_action({
|
|
|
+
|
|
|
+ type: 'ir.actions.client',
|
|
|
+ tag: "eiru_purchases.action_launch",
|
|
|
+ target: 'current',
|
|
|
+ params: {'mode': 'expense'},
|
|
|
+ context: self.session.user_context,
|
|
|
+
|
|
|
+ });
|
|
|
+ self.removeModal();
|
|
|
+ });
|
|
|
+
|
|
|
+ $('.purchases-modal').on('hidden.bs.modal', function (e) {
|
|
|
+ results = false;
|
|
|
+ defer.resolve(results);
|
|
|
+ self.removeModal(e);
|
|
|
+ });
|
|
|
+
|
|
|
+ return defer;
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ if(openerp.web && openerp.web.ListView){
|
|
|
+ openerp.web.ListView.include({
|
|
|
+ do_show: function(record) {
|
|
|
+ this._super.apply(this, arguments);
|
|
|
+ if (this.model != 'account.invoice' || this.dataset.context.default_type !== 'in_invoice') return
|
|
|
+ openerp.parentInstance = this;
|
|
|
+ if (openerp.widgetInstance) {
|
|
|
+ openerp.widgetInstance.updateId(record.id);
|
|
|
+ }
|
|
|
+ if (this.$el.find('.purchase-button').length !== 0 )
|
|
|
+ return;
|
|
|
+ openerp.widgetInstance = new openerp.PurchasesButtons(this);
|
|
|
+ var elemento = $('.oe_view_manager_buttons');
|
|
|
+ elemento = elemento.find('.oe_list_buttons');
|
|
|
+ openerp.widgetInstance.appendTo(elemento);
|
|
|
+ openerp.widgetInstance.updateId(record.id);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+})();
|