Bladeren bron

[ADD] Validaciones de eliminar entras/salidas de dinero

adrielso 6 jaren geleden
bovenliggende
commit
5f1a6cf185

+ 0 - 2
models/__init__.py

@@ -3,7 +3,5 @@ import account_bank_statement_config
 import account_bank_statement_type
 import account_bank_statement_utility
 import account_bank_statement_cashbox
-# import account_bank_statement_cashbox_input
-# import account_bank_statement_cashbox_output
 import account_bank_statement
 import cash_box_transfer

+ 136 - 2
models/account_bank_statement_utility.py

@@ -300,8 +300,8 @@ class AccountBankStatementUtility(models.Model):
     '''
         Write cash box transfer
     '''
-    def _write_cash_box_transfer(self, transfer, message, user):
-        return transfer.write({
+    def _write_cash_box_transfer(self, casbox, message, user):
+        return casbox.write({
             'message_deleted': message,
             'active': False,
             'write_uid': user.id
@@ -400,6 +400,68 @@ class AccountBankStatementUtility(models.Model):
       \____\__,_|___/____/ \___/_/\_\  |___|_| |_|          \___/ \__,_|\__|
 
     '''
+    '''
+        GET CashBox In
+    '''
+    @api.model
+    def eiru_get_cash_box_in(self, id):
+        return [{
+            'id': box_in.id,
+            'name': box_in.name,
+            'amount': box_in.amount,
+            'ref': box_in.ref,
+            'date': box_in.date,
+            'type': 'in',
+            'statement': {
+                'id': box_in.statement_id.id,
+                'name': box_in.statement_id.name,
+                'state': box_in.statement_id.state,
+                'typeJournal': box_in.statement_id.journal_id.type,
+                'date': box_in.statement_id.date,
+                'userId': box_in.statement_id.user_id.id,
+                'currency': {
+                    'symbol': box_in.statement_id.currency.symbol,
+                    'thousandsSeparator': box_in.statement_id.currency.thousands_separator,
+                    'decimalSeparator': box_in.statement_id.currency.decimal_separator,
+                    'decimalPlaces': box_in.statement_id.currency.decimal_places,
+                    }
+            },
+            'statementLine': {
+                'id': box_in.line_id.id
+            }
+        } for box_in in self.env['cash.box.in'].search([('statement_id.id', '=', id)])]
+
+    '''
+        GET CashBox out
+    '''
+    @api.model
+    def eiru_get_cash_box_out(self, id):
+        return [{
+            'id': box_out.id,
+            'name': box_out.name,
+            'amount': box_out.amount,
+            'ref': box_out.ref,
+            'date': box_out.date,
+            'type': 'out',
+            'statement': {
+                'id': box_out.statement_id.id,
+                'name': box_out.statement_id.name,
+                'state': box_out.statement_id.state,
+                'typeJournal': box_out.statement_id.journal_id.type,
+                'date': box_out.statement_id.date,
+                'userId': box_out.statement_id.user_id.id,
+                'currency': {
+                    'symbol': box_out.statement_id.currency.symbol,
+                    'thousandsSeparator': box_out.statement_id.currency.thousands_separator,
+                    'decimalSeparator': box_out.statement_id.currency.decimal_separator,
+                    'decimalPlaces': box_out.statement_id.currency.decimal_places,
+                    }
+            },
+            'statementLine': {
+                'id': box_out.line_id.id
+            }
+        } for box_out in self.env['cash.box.out'].search([('statement_id.id', '=', id)])]
+
     '''
         Create Statement Line
     '''
@@ -457,3 +519,75 @@ class AccountBankStatementUtility(models.Model):
         return {
             'state': True
         }
+
+    '''
+          _   _       _ _       _                    _     _                 _          __          _
+         | | | |_ __ | (_)_ __ | | __   ___ __ _ ___| |__ | |__   _____  __ (_)_ __    / /__  _   _| |_
+         | | | | '_ \| | | '_ \| |/ /  / __/ _` / __| '_ \| '_ \ / _ \ \/ / | | '_ \  / / _ \| | | | __|
+         | |_| | | | | | | | | |   <  | (_| (_| \__ \ | | | |_) | (_) >  <  | | | | |/ / (_) | |_| | |_
+          \___/|_| |_|_|_|_| |_|_|\_\  \___\__,_|___/_| |_|_.__/ \___/_/\_\ |_|_| |_/_/ \___/ \__,_|\__|
+    '''
+    '''
+        get Cash box in - out
+    '''
+    def _get_cash_box_in_out(self, id, type):
+        if (type == 'in'):
+            return self.env['cash.box.in'].browse(id)
+        if (type == 'out'):
+            return self.env['cash.box.out'].browse(id)
+
+    '''
+        Unlink cash box in/out
+    '''
+    @api.model
+    def unlink_cashbox_in_out(self, values):
+        ### user
+        user = self.env.user
+        ### date server
+        date_server = self.get_server_datetime()
+        ### account Statement
+        statement = self._get_statement_transfer(values['statementId'])
+        if (not statement):
+            return {
+                'state' : False,
+                'message': "No se pudo completar la operación."
+            }
+
+        ### cas box
+        cashBox =  self._get_cash_box_in_out(values['cashboxID'], values['type'])
+        if (not cashBox):
+            return {
+                'state' : False,
+                'message': "No se pudo completar la operación."
+            }
+
+        ### Line statement
+        lineStatement = self._get_statement_Line(cashBox.line_id.id)
+        if (not lineStatement):
+            return {
+                'state' : False,
+                'message': "No se pudo completar la operación."
+            }
+
+        ## updtae line
+        writelinet = self._write_statement_line_transfer(lineStatement)
+        ## unlink line
+        unlinkline = self._unlink_statement_line_transfer(lineStatement)
+        if (not unlinkline):
+            return {
+                'state' : False,
+                'message': "No se pudo completar la operación, error al eliminar la transferencia"
+            }
+
+        message = values['message']+" \nEliminado por la caja "+str(statement.name)+" y por Usuario "+str(user.name)+" en "+str(date_server)
+
+        writeTransfer = self._write_cash_box_transfer(cashBox, message, user)
+        if (not writeTransfer):
+            return {
+                'state' : False,
+                'message': "No se pudo completar la operación"
+            }
+
+        return { 'state': True,
+                'message': 'Operación realizada con éxito'
+        }

+ 2 - 0
security/ir.model.access.csv

@@ -2,3 +2,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
 access_bank_statement_config,account.bank.statement.config,model_account_bank_statement_config,account.group_account_user,1,1,1,1
 access_bank_statement_type,account.bank.statement.type,model_account_bank_statement_type,account.group_account_user,1,1,1,1
 access_cash_box_transfer,cash.box.transfer,model_cash_box_transfer,account.group_account_user,1,1,1,1
+access_cash_box_in,cash.box.in,model_cash_box_in,account.group_account_user,1,1,1,1
+access_cash_box_out,cash.box.out,model_cash_box_out,account.group_account_user,1,1,1,1

+ 112 - 3
static/src/css/style.css

@@ -23,8 +23,9 @@
     color: #ccc;
 }
 .from-title-hr {
-    margin-bottom: 10px;
-    margin-top: 5px
+    margin-bottom: 15px !important;
+    margin-top: 10px !important;
+    /* border: 0px; */
 }
 .transfer-check {
     padding-left:  90px;
@@ -81,7 +82,7 @@
 }
 
 
-/*table*/
+/*table transferencia */
 .transfer-deleted-table{
     margin-top: 0px !important;
 }
@@ -169,6 +170,114 @@
     font-size: 14pt;
     font-weight: bold;
 }
+
 .is_output{
     display: none;
 }
+.cash-box-radio-group {
+    height: 55px;
+    text-align: center;
+    padding-top: 8px;
+    border-left: 2px solid #ffffff;
+    border-right: 2px solid #ffffff;
+}
+.cash-box-radio-label{
+    font-size: 12pt;
+}
+.boby-cash-input {
+    display: none;
+}
+.boby-cash-output {
+    display: none;
+}
+.is-selectd-cashbox {
+    display: none;
+}
+/*table cashBos input output*/
+.casbox-deleted-table {
+    margin-top: 0px !important;
+}
+.expired-account-modal .table-row-select {
+     background: #d4e2f3  !important;
+}
+.expired-account-modal  .modal-head-wrapper-statement-casbox {
+    width: 100%;
+}
+.expired-account-modal .modal-item-statement-casbox {
+    width: 100%;
+    height: 110px;
+    overflow-y: auto;
+}
+.expired-account-modal .casbox-deleted-table table tbody tr {
+    height: 35px;
+}
+.expired-account-modal .casbox-deleted-table table thead tr {
+    height: 40px !important;
+}
+/*id*/
+.expired-account-modal .casbox-deleted-table table tbody tr td:nth-child(1){
+    display: none;
+}
+.expired-account-modal .casbox-deleted-table table thead tr th:nth-child(1){
+    display: none;
+}
+/* Date */
+.expired-account-modal .casbox-deleted-table table tbody tr td:nth-child(2){
+    width: 150px ;
+    font-size: 12pt;
+    text-align: left;
+    padding-left: 10px;
+    padding-top: 8px;
+}
+.expired-account-modal .casbox-deleted-table table thead tr th:nth-child(2){
+    width: 150px;
+    padding-right: 10px;
+    text-align: left;
+    font-size: 14pt;
+    font-weight: bold;
+}
+/* statement */
+.expired-account-modal .casbox-deleted-table table tbody tr td:nth-child(3){
+    width: 488px ;
+    padding-right: 10px;
+    text-align: left;
+    font-size: 12pt;
+    padding-top: 8px;
+}
+.expired-account-modal .casbox-deleted-table table thead tr th:nth-child(3){
+    width: 488px;
+    padding-right: 10px;
+    text-align: left;
+    font-size: 14pt;
+    font-weight: bold;
+}
+/* Amout */
+.expired-account-modal .casbox-deleted-table table tbody tr td:nth-child(4){
+    width: 200px ;
+    padding-right: 10px;
+    text-align: right;
+    font-size: 12pt;
+    padding-top: 8px;
+}
+.expired-account-modal .casbox-deleted-table table thead tr th:nth-child(4){
+    width: 200px;
+    padding-right: 10px;
+    text-align: center;
+    font-size: 14pt;
+    font-weight: bold;
+}
+.messege-is-cash-input{
+    font-size: 10pt;
+}
+.messege-is-cash-output{
+    font-size: 10pt;
+}
+.warning-message {
+    display: none;
+}
+.message-error {
+    color: red;
+    font-size: 17pt;
+    text-align: center;
+    font-weight: bold;
+}

+ 376 - 0
static/src/js/eiru_statement_cashbox_deleted.js

@@ -0,0 +1,376 @@
+(function() {
+
+    openerp.widgetInstanceStatementCashBoxDeleted = null;
+    openerp.parentInstanceStatementCashBoxDeleted = {};
+    var QWeb = openerp.web.qweb;
+    var instanceWeb = openerp.web;
+
+    openerp.EiruStatementCashBoxDeleted = openerp.Widget.extend({
+        template: 'EiruStatementUtility.CasBoxDeleted',
+        id: undefined,
+        buttons: undefined,
+        bankStatement: [],
+        cashBoxInput: [],
+        cashBoxOutput: [],
+        statementConfig: [],
+        resUser: [],
+        /* init */
+        init: function(parent) {
+            this._super(parent);
+            this.buttons = parent.$buttons;
+        },
+        /* start */
+        start: function () {
+            var self = this
+            this.$el.click(function() {
+                // self.showModal()
+                self.fetchInitial();
+            });
+            self.buttons.click(function(e) {
+                /* C (Crear) */
+                if (e.target.accessKey === 'C')
+                    self.$el.css('display','none');
+                /* E (Editar) */
+                if (e.target.accessKey === 'E')
+                    self.$el.css('display','none');
+                /* S (Guarrdar) */
+                if (e.target.accessKey === 'S')
+                    self.$el.css('display','flex');
+                /* D (Cancelar) */
+                if (e.target.accessKey === 'D')
+                    self.$el.css('display','flex');
+            });
+        },
+        /* Actualizar Id de la visat actual  */
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+        },
+        /* Reload Page*/
+        reloadPage: function() {
+             openerp.parentInstanceStatementCashBoxDeleted.reload();
+        },
+        /* Description: Función para remover el modal */
+        removeModal: function() {
+            $('.expired-account-modal').remove();
+            $('.modal-backdrop').remove();
+        },
+        /*Get User*/
+        fetchGetUserLogin: function(){
+            var bankStatementUser = new instanceWeb.Model('account.bank.statement');
+            return bankStatementUser.call('eiru_transfers_get_user', {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /* statement Config */
+        fetchStatementConfigTransfer: function() {
+            var fields = ['id', 'name', 'delete_input_user_ids', 'delete_output_user_ids'];
+            var domain = [['active', '=', true]];
+            var statementConfig = new openerp.web.Model('account.bank.statement.config');
+            return statementConfig.query(fields).filter(domain).all();
+        },
+        /* Método inicial */
+        fetchInitial: function() {
+            var self = this;
+            self.fetchBankStatement(self.id).then(function(bankStatement) {
+                return bankStatement;
+            }).then(function(bankStatement) {
+                self.bankStatement = bankStatement;
+                return self.fetchCashBoxInput(self.id);
+            }).then(function(cashBoxInput) {
+                self.cashBoxInput = cashBoxInput;
+                return self.fetchCashBoxOutput(self.id);
+            }).then(function(cashBoxOutput) {
+                self.cashBoxOutput = cashBoxOutput;
+                return self.fetchStatementConfigTransfer();
+            }).then(function(statementConfig) {
+                self.statementConfig = statementConfig;
+                return self.fetchGetUserLogin();
+            }).then(function(resUser) {
+                self.resUser = resUser;
+                if (!self.statementConfig.length) {
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación, no existe configuración de caja.");
+                    return  false;
+                }
+                if (!self.resUser.length) {
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación");
+                    return  false;
+                }
+                if (!self.bankStatement.length) {
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación.");
+                    return  false;
+                }
+
+                return self.showModal();
+            });
+        },
+        /* Account bank Statement */
+        fetchBankStatement: function(id) {
+            var bankStatement = new instanceWeb.Model('account.bank.statement');
+            return bankStatement.call('get_account_bank_statement_utility',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /* cash_box_Input*/
+        fetchCashBoxInput: function(id) {
+            var cashBoxInput = new instanceWeb.Model('account.bank.statement');
+            return cashBoxInput.call('eiru_get_cash_box_in',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /* cash_box_output*/
+        fetchCashBoxOutput: function(id) {
+            var cashBoxOutput = new instanceWeb.Model('account.bank.statement');
+            return cashBoxOutput.call('eiru_get_cash_box_out',[id], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+        /*filter line transfer selected*/
+        filterRowSelected: function(id, type){
+            var self = this;
+            if (type === 'input') {
+                return _.filter(self.cashBoxInput, function(item){
+                    return item.id === id;
+                });
+            }
+            if (type === 'output') {
+                return _.filter(self.cashBoxOutput, function(item){
+                    return item.id === id;
+                });
+            }
+        },
+        /*Modal  Transfer */
+        showModal: function() {
+            var self = this;
+            var defer =$.Deferred();
+            var results = true;
+            var rowSelected = [];
+            var statementBank = self.bankStatement[0]
+            var modal = QWeb.render('ModalStatementUtility.CasBoxDeleted',{
+                'boxInput': self.cashBoxInput,
+                'boxOutput': self.cashBoxOutput
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal();
+
+            /*Table*/
+            var tableInput = $('.expired-account-modal').find('.tbody-input').find('tr');
+            var tableOutput = $('.expired-account-modal').find('.tbody-output').find('tr');
+            /* selectr type cash*/
+            var cashInput = $('.expired-account-modal').find('.cash-input');
+            $('.expired-account-modal').find('.messege-is-cash-input').text("Tienes "+self.cashBoxInput.length+" registro de entrada de dinero");
+            if (!self.cashBoxInput.length) {
+                cashInput.attr("disabled", true);
+                $('.expired-account-modal').find('.messege-is-cash-input').text("No existe registros.");
+            }
+            var cashOutput = $('.expired-account-modal').find('.cash-output');
+            $('.expired-account-modal').find('.messege-is-cash-output').text("Tienes "+self.cashBoxOutput.length+" registro de extracción de dinero");
+            if (!self.cashBoxOutput.length) {
+                cashOutput.attr("disabled", true);
+                $('.expired-account-modal').find('.messege-is-cash-output').text("No existe registros.");
+            }
+
+            var cashInputSelected = null;
+            var cashOutputSelected = null;
+            /* */
+            var casboxRef = $('.expired-account-modal').find('.casbox-ref');
+            var casboxAmount = $('.expired-account-modal').find('.casbox-amount');
+            var casboxAmountSymbol = $('.expired-account-modal').find('.casbox-amount-symbol');
+            casboxAmountSymbol.text(statementBank.currencystatement.symbol);
+            var casboxRefDeleted = $('.expired-account-modal').find('.casbox-ref-deleted');
+            /* Button*/
+            var buttonDeleted = $('.expired-account-modal').find('.button-deleted');
+            buttonDeleted.attr("disabled", true);
+
+            /* Entrada */
+            cashInput.click(function(e) {
+                $('.expired-account-modal').find('.is-cash-input').css('background','#ffffff');
+                $('.expired-account-modal').find('.boby-cash-input').css('display','none');
+                $('.expired-account-modal').find('.is-cash-output').css('background','#ffffff');
+                $('.expired-account-modal').find('.boby-cash-output').css('display','none');
+                $('.expired-account-modal').find('.is-selectd-cashbox').css('display','none');
+                $('.expired-account-modal').find('.warning-message').css('display','none');
+                $('.expired-account-modal').find('.message-error').text("");
+                cashInputSelected = e.target;
+                casboxRef.val('');
+                casboxAmount.val('0');
+                casboxRefDeleted.val('');
+                buttonDeleted.attr("disabled", true);
+                rowSelected = [];
+                tableInput.removeClass('table-row-select');
+                tableOutput.removeClass('table-row-select');
+
+                if (this.checked) {
+                    if (!(_.contains(self.statementConfig[0].delete_input_user_ids, self.resUser[0].id))){
+                        $('.expired-account-modal').find('.warning-message').css('display','flex');
+                        $('.expired-account-modal').find('.message-error').text("No tienes autorización para eliminar las entradas de dinero..");
+                        return false;
+                    }
+                    $('.expired-account-modal').find('.is-cash-input').css('background','#d4e2f3');
+                    $('.expired-account-modal').find('.boby-cash-input').css('display','flex');
+                    $('.expired-account-modal').find('.is-selectd-cashbox').css('display','flex');
+                }
+            });
+            /* Salida */
+            cashOutput.click(function(e){
+                cashOutputSelected = e.target;
+                $('.expired-account-modal').find('.is-cash-output').css('background','#ffffff');
+                $('.expired-account-modal').find('.boby-cash-output').css('display','none');
+                $('.expired-account-modal').find('.is-cash-input').css('background','#ffffff');
+                $('.expired-account-modal').find('.boby-cash-input').css('display','none');
+                $('.expired-account-modal').find('.is-selectd-cashbox').css('display','none');
+                $('.expired-account-modal').find('.warning-message').css('display','none');
+                $('.expired-account-modal').find('.message-error').text("");
+                casboxRef.val('');
+                casboxAmount.val('0');
+                casboxRefDeleted.val('');
+                buttonDeleted.attr("disabled", true);
+                rowSelected = [];
+                tableInput.removeClass('table-row-select');
+                tableOutput.removeClass('table-row-select');
+
+                if (this.checked) {
+                    if (!(_.contains(self.statementConfig[0].delete_output_user_ids, self.resUser[0].id))){
+                        $('.expired-account-modal').find('.warning-message').css('display','flex');
+                        $('.expired-account-modal').find('.message-error').text("No tienes autorización para eliminar las salidas de dinero.");
+                        return false;
+                    }
+                    $('.expired-account-modal').find('.is-cash-output').css('background','#d4e2f3');
+                    $('.expired-account-modal').find('.boby-cash-output').css('display','flex');
+                    $('.expired-account-modal').find('.is-selectd-cashbox').css('display','flex');
+                }
+            });
+            /* table input */
+            tableInput.click(function(e){
+                /* clear */
+                casboxRef.val('');
+                casboxAmount.val('0');
+                casboxRefDeleted.val('');
+                buttonDeleted.attr("disabled", true);
+
+                tableInput.removeClass('table-row-select');
+                tableOutput.removeClass('table-row-select');
+                $(e.target).closest('tr').addClass('table-row-select');
+
+                var idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                rowSelected = self.filterRowSelected(idRow, 'input').shift();
+
+                if (!!rowSelected) {
+                    casboxRef.val(rowSelected.ref);
+                    casboxAmount.val(accounting.formatNumber(rowSelected.amount, rowSelected.statement.currency.decimalPlaces, rowSelected.statement.currency.thousandsSeparator,rowSelected.statement.currency.decimalSeparator));
+                    buttonDeleted.removeAttr("disabled");
+                }
+            });
+            /* table output*/
+            tableOutput.click(function(e){
+                /* clear */
+                casboxRef.val('');
+                casboxAmount.val('0');
+                casboxRefDeleted.val('');
+                buttonDeleted.attr("disabled", true);
+
+                tableInput.removeClass('table-row-select');
+                tableOutput.removeClass('table-row-select');
+                $(e.target).closest('tr').addClass('table-row-select');
+
+                var idRow = parseInt(($(e.target).closest('tr').children()[0].textContent).trim());
+                rowSelected = self.filterRowSelected(idRow, 'output').shift();
+
+                if (!!rowSelected) {
+                    casboxRef.val(rowSelected.ref);
+                    casboxAmount.val(accounting.formatNumber(rowSelected.amount, rowSelected.statement.currency.decimalPlaces, rowSelected.statement.currency.thousandsSeparator,rowSelected.statement.currency.decimalSeparator));
+                    buttonDeleted.removeAttr("disabled");
+                }
+            });
+
+            casboxRefDeleted.keyup(function(e){
+                if (e.keyCode === 13) {
+                    buttonDeleted.focus();
+                }
+            });
+            casboxRefDeleted.focusout(function(e){
+                if (!casboxRefDeleted.val()) {
+                    instanceWeb.notification.do_warn("Atencion", "Debes de ingresar un motivo para continuar.");
+                    casboxRefDeleted.focus();
+                    return false;
+                }
+            });
+            /* button click */
+            buttonDeleted.click(function(e) {
+                if (!rowSelected){
+                    instanceWeb.notification.do_warn("Atencion", "Debes de seleccionar un ítem para continuar");
+                    return false;
+                }
+                if (!casboxRefDeleted.val()) {
+                    instanceWeb.notification.do_warn("Atencion", "Debes de ingresar un motivo para continuar.");
+                    buttonDeleted.css('border-color','red');
+                    buttonDeleted.focus();
+                    return  false;
+                }
+                buttonDeleted.css('border-color','#ccc');
+
+                var cashbox = {
+                    'cashboxID': rowSelected.id,
+                    'statementId': self.id,
+                    'type': rowSelected.type,
+                    'message': casboxRefDeleted.val()
+                }
+
+                self.unlinkCashBox(cashbox).then(function(cashboxUnlink){
+                    return cashboxUnlink;
+                }).then(function(cashboxUnlink){
+                    self.reloadPage();
+                    self.removeModal(e);
+                    if (!cashboxUnlink)
+                        results = false;
+                })
+                defer.resolve(results);
+            });
+
+            /* Click Cerrar */
+            $('.expired-account-modal').on('hidden.bs.modal', function(e) {
+                results = false;
+                defer.resolve(results);
+                self.removeModal(e);
+            });
+
+            return defer;
+        },
+        /* Unlink Cash Box */
+        unlinkCashBox: function(values){
+            var bankStatementTransfer = new instanceWeb.Model('account.bank.statement');
+            return bankStatementTransfer.call('unlink_cashbox_in_out',[values], {
+                context: new instanceWeb.CompoundContext()
+            });
+        },
+    });
+
+    if (openerp.web && openerp.web.FormView) {
+        openerp.web.FormView.include({
+            load_record: function(record) {
+                this._super.apply(this, arguments);
+
+                if (this.model !== 'account.bank.statement')
+                    return;
+
+                openerp.parentInstanceStatementCashBoxDeleted = this;
+
+                if (openerp.widgetInstanceStatementCashBoxDeleted) {
+                    openerp.widgetInstanceStatementCashBoxDeleted.updateId(record.id);
+                    if (this.$el.find('.button-statement-cashbox-deleted').length !== 0 )
+                        return ;
+                }
+
+                if (this.$el.find('.button-statement-cashbox-deleted').length !== 0 )
+                    return;
+
+                openerp.widgetInstanceStatementCashBoxDeleted = new openerp.EiruStatementCashBoxDeleted(this);
+                var element =this.$el.find('.oe_form').find('.eiru-statement-utility');
+
+                openerp.widgetInstanceStatementCashBoxDeleted.appendTo(element[0]);
+                openerp.widgetInstanceStatementCashBoxDeleted.updateId(record.id);
+            }
+        });
+    }
+})();

+ 4 - 4
static/src/js/eiru_statement_cashbox_input.js

@@ -81,11 +81,11 @@
                 self.resUser = resUser;
 
                 if (!self.statementConfig.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar las configuración de las caja.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación, no existe configuración de caja.");
                     return  false;
                 }
                 if (!self.resUser.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar el usuario.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación.");
                     return  false;
                 }
                 if (!!self.bankStatement.length) {
@@ -94,12 +94,12 @@
                     var statementUser = self.bankStatement[0];
                     /*  Verificar si el tipo caja tiene permiso para la transferencia */
                     if (!(_.contains(statementConfig.input_cash_box_statement_ids, statementUser.typeStatement))) {
-                        instanceWeb.notification.do_warn("Atencion", "El tipo de caja no tiene permiso para poner dinero.");
+                        instanceWeb.notification.do_warn("Atencion", "El tipo de caja no tiene autorización para poner dinero.");
                         return  false;
                     }
                     /* Verificar si el usuario tiene permiso para la transferencia*/
                     if (!(_.contains(statementConfig.input_cash_box_user_id, resUser.id))) {
-                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene permiso para poner dinero.");
+                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene autorización para poner dinero.");
                         return false;
                     }
                 }

+ 6 - 6
static/src/js/eiru_statement_cashbox_output.js

@@ -81,11 +81,11 @@
                 self.resUser = resUser;
 
                 if (!self.statementConfig.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar las configuración de las caja.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación, no existe configuración de caja.");
                     return  false;
                 }
                 if (!self.resUser.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar el usuario.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación.");
                     return  false;
                 }
                 if (!!self.bankStatement.length) {
@@ -94,21 +94,21 @@
                     var statementUser = self.bankStatement[0];
                     /*  Verificar si el tipo caja tiene permiso para la transferencia */
                     if (!(_.contains(statementConfig.output_cash_box_statement_ids, statementUser.typeStatement))) {
-                        instanceWeb.notification.do_warn("Atencion", "El tipo caja no tiene permiso para sacar dinero.");
+                        instanceWeb.notification.do_warn("Atencion", "El tipo de caja no tiene autorización para realizar extracción de dinero.");
                         return  false;
                     }
                     /* Verificar si el usuario tiene permiso para la transferencia*/
                     if (!(_.contains(statementConfig.output_cash_box_user_id, resUser.id))) {
-                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene permiso para sacar dinero .");
+                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene autorización para realizar extracción de dinero.");
                         return false;
                     }
                     if (statementUser.amount <= 0) {
                         if (!statementConfig) {
-                            instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
+                            instanceWeb.notification.do_warn("Atencion", "Caja sin saldo.");
                             return false;
                         }
                         if (!statementConfig.output_negative_amount) {
-                            instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
+                            instanceWeb.notification.do_warn("Atencion", "Caja sin saldo.");
                             return false;
                         }
                     }

+ 8 - 8
static/src/js/eiru_statement_transfer.js

@@ -90,11 +90,11 @@
             }).then(function(resUser) {
                 self.resUser = resUser;
                 if (!self.statementConfig.length){
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar las configuración de las caja.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar transferencia, no existe configuración de caja.");
                     return  false;
                 }
                 if (!self.resUser.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar el usuario.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar transferencia.");
                     return  false;
                 }
                 // if (!!self.statementConfig.length && !!self.resUser.length && !!self.bankStatement.length) {
@@ -104,23 +104,23 @@
                     var statementUser = self.bankStatement[0];
                     /*  Verificar si el tipo caja tiene permiso para la transferencia */
                     if (!(_.contains(statementConfig.transfer_statement_ids, statementUser.typeStatement))) {
-                        instanceWeb.notification.do_warn("Atencion", "El tipo caja no tiene permiso para realizar transferencia.");
+                        instanceWeb.notification.do_warn("Atencion", "El tipo de caja no tiene autorización para realizar transferencia.");
                         return  false;
                     }
                     /* Verificar si el usuario tiene permiso para la transferencia*/
                     if (!(_.contains(statementConfig.transfer_user_ids, resUser.id))) {
-                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene permiso para realizar transferencia.");
+                        instanceWeb.notification.do_warn("Atencion", "El usuario no tiene autorización para realizar transferencia.");
                         return false;
                     }
                 }
 
                 if (self.bankStatement[0].amount <= 0) {
                     if (!self.statementConfig.length){
-                        instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
+                        instanceWeb.notification.do_warn("Atencion", "Caja sin saldo.");
                         return false;
                     }
                     if (!self.statementConfig[0].transfer_negative_amount){
-                        instanceWeb.notification.do_warn("Atencion", "La caja seleccionada no tiene saldo disponible.");
+                        instanceWeb.notification.do_warn("Atencion", "Caja sin saldo.");
                         return false;
                     }
                 }
@@ -129,7 +129,7 @@
                 }).then(function(accountJournal) {
                     self.accountJournal = accountJournal;
                     if (!accountJournal[0].statementJournal.length){
-                        instanceWeb.notification.do_warn("Atencion", "No tienes ninguna caja abierta.");
+                        instanceWeb.notification.do_warn("Atencion", "No tienes otra caja abierta para realizar la transferencia.");
                         return false;
                     }
 
@@ -230,7 +230,7 @@
                 var amount = Math.abs(accounting.unformat(amountTransfer.val(),currency.decimalSeparator));
 
                 if (amountAvailable < amount && !self.statementConfig[0].transfer_negative_amount) {
-                    instanceWeb.notification.do_warn("Atencion", "El valor a transferir supera el saldo disponible de la caja .");
+                    instanceWeb.notification.do_warn("Atencion", "El valor a transferir supera el saldo disponible de la caja.");
                     amountTransfer.css('border-color','red');
                     amountTransfer.focus();
                     return false;

+ 3 - 3
static/src/js/eiru_statement_transfer_deleted.js

@@ -81,15 +81,15 @@
             }).then(function(resUser) {
                 self.resUser = resUser;
                 if (!self.statementConfig.length){
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar las configuración de las cajas.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación, no existe configuración de caja.");
                     return  false;
                 }
                 if (!self.resUser.length){
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar el usuario.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación.");
                     return  false;
                 }
                 if (!self.bankStatement.length) {
-                    instanceWeb.notification.do_warn("Atencion", "No fue posible localizar el usuario.");
+                    instanceWeb.notification.do_warn("Atencion", "No estas autorizado a realizar esta operación.");
                     return  false;
                 }
 

+ 8 - 0
static/src/xml/eiru_statement_cashbox_deleted.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="EiruStatementUtility.CasBoxDeleted">
+        <button class="button-statement-cashbox-deleted eiru-statement-button oe_button oe_form_button oe_highlight">
+            <span>Eliminar E/S</span>
+        </button>
+  </t>
+</templates>

+ 172 - 0
static/src/xml/modal/modal_statement_cashbox_deleted.xml

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ModalStatementUtility.CasBoxDeleted">
+        <div class="modal in expired-account-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg" role="document">
+                <div class="modal-content openerp">
+                    <div class="modal-header paymnets-invoice-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title">Eliminar entrada/salida de dinero</h3>
+
+                    </div>
+                    <!-- Body -->
+                    <div class="modal-body">
+                        <div class="row">
+                            <div class="col-xs-6 cash-box-radio-group is-cash-input">
+                                <input type="checkbox" class="cash-input"></input>
+                                <label class="cash-box-radio-label">Entrada</label>
+                                <div class="messege-is-cash-input"></div>
+                            </div>
+                            <div class="col-xs-6 cash-box-radio-group is-cash-output">
+                                <input type="checkbox" class="cash-output"></input>
+                                <label class="cash-box-radio-label">Salida</label>
+                                <div class="messege-is-cash-output"></div>
+                            </div>
+                        </div>
+
+                        <hr class="from-title-hr warning-message"/>
+                        <!-- message -->
+                        <div class="row warning-message">
+                            <div class="col-xs-12">
+                                <div class="message-error"></div>
+                            </div>
+                        </div>
+
+                        <hr class="from-title-hr is-selectd-cashbox"/>
+                        <!-- ENTRADA -->
+                        <div class="boby-cash-input">
+                            <div class=" oe_view_manager_body casbox-deleted-table">
+                                <div class="modal-head-wrapper-statement-casbox">
+                                    <table class="oe_list_content">
+                                        <thead >
+                                            <tr class="oe_list_header_columns"  >
+                                                <th class="oe_list_header_char oe_sortable"></th>
+                                                <th class="oe_list_header_char oe_sortable">Fecha</th>
+                                                <th class="oe_list_header_char oe_sortable">Caja</th>
+                                                <th class="oe_list_header_char oe_sortable">Valor</th>
+                                            </tr>
+                                        </thead>
+                                    </table>
+                                </div>
+                                <div class="modal-item-statement-casbox">
+                                    <table class="oe_list_content">
+                                        <tbody class="table-tbody tbody-input">
+                                            <tr t-foreach="boxInput" t-as="input">
+                                                <td>
+                                                    <t t-esc="input_value.id"/>
+                                                </td>
+                                                <td>
+                                                    <t t-set="date" t-value="input_value.date"/>
+                                                    <t t-js="ctx">
+                                                        ctx.date = moment(ctx.date).format("DD-MM-YYYY");
+                                                    </t>
+                                                    <t t-esc="date"/>
+                                                </td>
+                                                <td>
+                                                    <t t-esc="input_value.statement.name"/>
+                                                </td>
+                                                <td>
+                                                    <t t-set="monto" t-value="input_value.amount"/>
+                                                    <t t-set="decimalSeparator" t-value="input_value.statement.currency.decimalSeparator"/>
+                                                    <t t-set="thousandsSeparator" t-value="input_value.statement.currency.thousandsSeparator"/>
+                                                    <t t-set="decimalPlaces" t-value="input_value.statement.currency.decimalPlaces"/>
+                                                    <t t-set="symbol" t-value="input_value.statement.currency.symbol"/>
+                                                    <t t-js="ctx">
+                                                        ctx.monto = accounting.formatMoney(ctx.monto, ctx.symbol,ctx.decimalPlaces,ctx.thousandsSeparator,ctx.decimalSeparator);
+                                                    </t>
+                                                    <t t-esc="monto"/>
+                                                </td>
+                                            </tr>
+                                        </tbody>
+                                    </table>
+                                </div>
+                            </div>
+                        </div>
+                        <!-- SALIDA -->
+                        <div class="boby-cash-output">
+                            <div class=" oe_view_manager_body casbox-deleted-table">
+                                <div class="modal-head-wrapper-statement-casbox">
+                                    <table class="oe_list_content">
+                                        <thead >
+                                            <tr class="oe_list_header_columns"  >
+                                                <th class="oe_list_header_char oe_sortable"></th>
+                                                <th class="oe_list_header_char oe_sortable">Fecha</th>
+                                                <th class="oe_list_header_char oe_sortable">Caja</th>
+                                                <th class="oe_list_header_char oe_sortable">Valor</th>
+                                            </tr>
+                                        </thead>
+                                    </table>
+                                </div>
+                                <div class="modal-item-statement-casbox">
+                                    <table class="oe_list_content">
+                                        <tbody class="table-tbody tbody-output">
+                                            <tr t-foreach="boxOutput" t-as="output">
+                                                <td>
+                                                    <t t-esc="output_value.id"/>
+                                                </td>
+                                                <td>
+                                                    <t t-set="date" t-value="output_value.date"/>
+                                                    <t t-js="ctx">
+                                                        ctx.date = moment(ctx.date).format("DD-MM-YYYY");
+                                                    </t>
+                                                    <t t-esc="date"/>
+                                                </td>
+                                                <td>
+                                                    <t t-esc="output_value.statement.name"/>
+                                                </td>
+                                                <td>
+                                                    <t t-set="monto" t-value="output_value.amount"/>
+                                                    <t t-set="decimalSeparator" t-value="output_value.statement.currency.decimalSeparator"/>
+                                                    <t t-set="thousandsSeparator" t-value="output_value.statement.currency.thousandsSeparator"/>
+                                                    <t t-set="decimalPlaces" t-value="output_value.statement.currency.decimalPlaces"/>
+                                                    <t t-set="symbol" t-value="output_value.statement.currency.symbol"/>
+                                                    <t t-js="ctx">
+                                                        ctx.monto = accounting.formatMoney(ctx.monto, ctx.symbol,ctx.decimalPlaces,ctx.thousandsSeparator,ctx.decimalSeparator);
+                                                    </t>
+                                                    <t t-esc="monto"/>
+                                                </td>
+                                            </tr>
+                                        </tbody>
+                                    </table>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="row is-selectd-cashbox">
+                            <div class="col-xs-6">
+                                <label class="statement-input-labe">Referencia</label>
+                                <div class="statement-input-group">
+                                    <input type="text" class="form-control statement-input-number input-letters casbox-ref" readonly="readonly"></input>
+                                </div>
+                            </div>
+                            <div class="col-xs-6">
+                                <label class="statement-input-labe">Monto</label>
+                                <div class="statement-input-group">
+                                    <input type="text" class="form-control statement-input-number casbox-amount" readonly="readonly" value="0"></input>
+                                    <div class="statement-input-symbol casbox-amount-symbol">
+                                        <span class="input-group-text"></span>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="row is-selectd-cashbox">
+                            <div class="col-xs-12">
+                                <label class="statement-input-labe">Motivo</label>
+                                <div class="statement-input-group">
+                                    <input type="text" class="form-control statement-input-number input-letters casbox-ref-deleted"></input>
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    <!-- Pie de Pagina -->
+                    <div class="modal-footer statement-utility-footer">
+                        <button type="button" class="oe_button oe_form_button oe_highlight statement-utility-button button-deleted">Guardar</button>
+                        <button type="button" class="oe_button oe_form_button oe_link dismmis-modal statement-utility-button" data-dismiss="modal">Salir</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 30 - 26
views/account_bank_statemente_config.xml

@@ -67,11 +67,39 @@
                             </group>
                         </page>
 
+                        <!-- Poner Dinero -->
+                        <page string="Poner dinero">
+                            <separator string="Permitir poner dinero"/>
+                            <div class="openerp oe_form oe_form_field">
+                                <span class="oe_form_text_content">
+                                    Permite a los usuario ingresar dinero en las cajas.
+                                </span>
+                            </div>
+                            <group col="2">
+                                <group style="margin: 0px" string="Cajas permitidas">
+                                    <label for="input_cash_box_statement_ids" string="Tipos de caja permitidas" style="width: 200px"></label>
+                                    <field name="input_cash_box_statement_ids" widget="many2many_checkboxes"  nolabel="1"/>
+                                </group>
+                                <group style="margin: 0px"  string="Usuarios permitidos">
+                                    <label for="input_cash_box_user_id" string="Usuarios permitidos" style="width: 200px"></label>
+                                    <field name="input_cash_box_user_id" widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
+                                </group>
+                            </group>
+                            <group col="2">
+                                <group string="Eliminar las entradas de dinero">
+                                    <label for="delete_input_user_ids" string="Usuarios permitidos" style="width: 200px"></label>
+                                    <field name="delete_input_user_ids" class="oe_inline"  widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
+                                </group>
+                            </group>
+                        </page>
+
                         <!-- Sacar Dinero -->
                         <page string="Sacar dinero">
                             <separator string="Permitir sacar dinero"/>
                             <div class="openerp oe_form oe_form_field">
-                                <span class="oe_form_text_content"></span>
+                                <span class="oe_form_text_content">
+                                    Permite a los usuario extraer dinero de las cajas.
+                                </span>
                             </div>
                             <group col="2">
                                 <group style="margin: 0px" string="Cajas permitidas">
@@ -88,36 +116,12 @@
                                     <label for="output_negative_amount" string="Permitir sacar dinero" style="width: 200px"></label>
                                     <field name="output_negative_amount" class="oe_inline" nolabel="1"/>
                                 </group>
-                                <group string="Eliminar Line">
+                                <group string="Eliminar las extracción de dinero">
                                     <label for="delete_output_user_ids" string="Usuarios permitidos" style="width: 200px"></label>
                                     <field name="delete_output_user_ids" class="oe_inline"  widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
                                 </group>
                             </group>
                         </page>
-
-                        <!-- Poner Dinero -->
-                        <page string="Poner dinero">
-                            <separator string="Permitir poner dinero"/>
-                            <div class="openerp oe_form oe_form_field">
-                                <span class="oe_form_text_content"></span>
-                            </div>
-                            <group col="2">
-                                <group style="margin: 0px" string="Cajas permitidas">
-                                    <label for="input_cash_box_statement_ids" string="Tipos de caja permitidas" style="width: 200px"></label>
-                                    <field name="input_cash_box_statement_ids" widget="many2many_checkboxes"  nolabel="1"/>
-                                </group>
-                                <group style="margin: 0px"  string="Usuarios permitidos">
-                                    <label for="input_cash_box_user_id" string="Usuarios permitidos" style="width: 200px"></label>
-                                    <field name="input_cash_box_user_id" widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
-                                </group>
-                            </group>
-                            <group col="2">
-                                <group string="Eliminar Line">
-                                    <label for="delete_input_user_ids" string="Usuarios permitidos" style="width: 200px"></label>
-                                    <field name="delete_input_user_ids" class="oe_inline"  widget="many2many_tags" options="{'no_create': True}" nolabel="1"/>
-                                </group>
-                            </group>
-                        </page>
                     </notebook>
                 </form>
             </field>

+ 1 - 1
views/template.xml

@@ -8,9 +8,9 @@
                 <script type="text/javascript" src="/eiru_account_bank_statement_utility/static/src/js/eiru_statement_transfer_deleted.js"/>
                 <!-- Poner dinero  -->
                 <script type="text/javascript" src="/eiru_account_bank_statement_utility/static/src/js/eiru_statement_cashbox_input.js"/>
-
                 <!-- Sacar dinero  -->
                 <script type="text/javascript" src="/eiru_account_bank_statement_utility/static/src/js/eiru_statement_cashbox_output.js"/>
+                <script type="text/javascript" src="/eiru_account_bank_statement_utility/static/src/js/eiru_statement_cashbox_deleted.js"/>
 
                 <!-- <script type="text/javascript" src="/eiru_account_bank_statement_utility/static/src/js/import_statement.js"/> -->
             </xpath>