Просмотр исходного кода

[ADD] Agrupación por tipo de caja

adrielso 7 лет назад
Родитель
Сommit
f89da67129

+ 32 - 32
models/account_bank_statement.py

@@ -8,69 +8,69 @@ class AccountBankStatement(models.Model):
 
     @api.model
     def get_statement_point_of_sale(self, id):
-        accountStatement = self._get_statement(id)
+        accountStatement = self.env['account.bank.statement'].browse(id)
         decimal_precision = self.env['decimal.precision'].precision_get('Account')
-
         if (not accountStatement):
-            return False;
-
-        accountStatementLine = self._get_statement_line(accountStatement.id)
+            return False
 
         statementPointOfSale = self._get_statement_point_of_sale(accountStatement)
+        if (not statementPointOfSale):
+            return False
+
         statementLine = []
 
         for line in statementPointOfSale:
             lineStatement = self.env['account.bank.statement.line'].search([('name', '=', line['name'])])
             if (not lineStatement):
                 amount = line['amount']
+
                 statementLine.append([0, False, {
                     'name': line['name'],
-                    'ref' : 'Point of sale',
+                    'ref' : 'Responsable/'+line['userName'],
                     'amount': round(float(amount), decimal_precision),
                     'journal_id': accountStatement.journal_id.id,
                     'account_id': accountStatement.journal_id.internal_account_id.id,
                     'statement_id': accountStatement.id,
                     'date': line['date'],
                 }])
+
         line = []
-        if (statementLine):
-            line = accountStatement.write({'line_ids': statementLine})
 
-        return line
+        if (not statementLine):
+            return False
 
+        line = accountStatement.write({'line_ids': statementLine})
+        if (not line):
+            return False
 
-    '''
-        Get Account Bank Statement
-    '''
-    def _get_statement(self, id):
-        return self.env['account.bank.statement'].browse(id)
+        return len(statementLine)
 
-    '''
-        Get Account Bank Statement Line
-    '''
-    def _get_statement_line(self, statementId):
-        return self.env['account.bank.statement.line'].search([('statement_id', 'in', [statementId])])
     '''
         Get Account Bank Statement Point of Sale
     '''
     def _get_statement_point_of_sale(self, statement):
-        statementPoint = self.env['account.bank.statement'].search([('date','=',statement.date),('journal_id.id', '=',statement.journal_id.id),('period_id.id', '=', statement.period_id.id), ('pos_session_id', '!=', False),('state', '=', 'confirm')], order='id')
+        statementPoint = self.env['account.bank.statement'].search([
+                                                                    ('date','=',statement.date),
+                                                                    ('journal_id.id', '=',statement.journal_id.id),
+                                                                    ('period_id.id', '=', statement.period_id.id),
+                                                                    ('type_statement', '=', 'normal'),
+                                                                    ('state', '=', 'confirm')], order='id')
         pointSatatement = []
-
         for statementP in statementPoint:
             amount = 0.0
             for line in statementP.line_ids:
                 amount += line.amount
-
-            pointSatatement.append({
-                'name': statementP.name,
-                'date': statementP.date,
-                'journalId': statementP.journal_id.id,
-                'periodId': statementP.period_id.id,
-                'userId': statementP.user_id.id,
-                'posSessionId': statementP.pos_session_id.id,
-                'posSessionName': statementP.pos_session_id.name,
-                'amount': amount
-            })
+            if (amount > 0):
+                pointSatatement.append({
+                    'name': statementP.name,
+                    'date': statementP.date,
+                    'journalId': statementP.journal_id.id,
+                    'periodId': statementP.period_id.id,
+                    'userId': statementP.user_id.id,
+                    'userName': statementP.user_id.name,
+                    'posSessionId': statementP.pos_session_id.id,
+                    'posSessionName': statementP.pos_session_id.name,
+                    'amount': amount
+                })
 
         return pointSatatement

BIN
models/account_bank_statement.pyc


+ 33 - 7
static/src/js/import_statement.js

@@ -5,21 +5,42 @@ openerp.eiru_import_statement = function (instance, local) {
     local.VoucherImportWidget = instance.Widget.extend({
         template: 'EiruImport.Statement',
         id: undefined,
+        buttons: undefined,
         bankStatement: [],
-
+        /* Init */
         init: function (parent) {
             this._super(parent);
+            this.buttons = parent.$buttons;
         },
-        // Actualizar id del Objeto
-        updateId: function(id) {
+        /* Actualizar id del Objeto */
+        updateId: function(id, type) {
             var self = this;
             self.id = id;
+            this.$el.css('display','flex');
+           if (type === 'normal'){
+               this.$el.css('display','none');
+           }
         },
+        /* start */
         start: function() {
             var self = this;
             this.$el.click(function() {
                 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');
+            });
         },
         /* Iniciar */
         fetchInitial: function() {
@@ -31,7 +52,7 @@ openerp.eiru_import_statement = function (instance, local) {
                 return bankStatement;
             }).then(function(bankStatement) {
                 self.bankStatement = bankStatement;
-                if (!!self.bankStatement.length && !!self.bankStatement[0].pos_session_id){
+                if (!!self.bankStatement.length && self.bankStatement[0].type_statement === 'normal'){
                     instance.web.notification.do_notify("Atención","Esta opción solo esta disponible para la caja general.");
                     return false;
                 }
@@ -39,6 +60,11 @@ openerp.eiru_import_statement = function (instance, local) {
                     return statementPoinOfSale;
                 }).then(function(statementPoinOfSale){
                     self.statementPoinOfSale = statementPoinOfSale;
+                    if (!!statementPoinOfSale) {
+                        instance.web.notification.do_notify("Atención"," "+statementPoinOfSale+" caja/s fueron importada .");
+                        return
+                    }
+                    instance.web.notification.do_notify("Atención","Nada que hacer.");
                 });
             }).then(function() {
                 local.parentInstance.reload();
@@ -53,7 +79,7 @@ openerp.eiru_import_statement = function (instance, local) {
             return statement.query(fields).filter(domain).all();
         },
         /* Get Statement Point of Sale*/
-        fetchStatementPointOfSale: function(id){
+        fetchStatementPointOfSale: function(id) {
             var invoiceMoveLine = new instance.web.Model('account.bank.statement');
             return invoiceMoveLine.call('get_statement_point_of_sale',[id], {
                 context: new instance.web.CompoundContext()
@@ -71,7 +97,7 @@ openerp.eiru_import_statement = function (instance, local) {
                 local.parentInstance = this;
 
                 if (local.widgetInstance)
-                    local.widgetInstance.updateId(record.id);
+                    local.widgetInstance.updateId(record.id, record.type_statement);
 
                 if (this.$el.find('.button-import-statement').length !== 0) return;
 
@@ -79,7 +105,7 @@ openerp.eiru_import_statement = function (instance, local) {
                 var element = this.$el.find('.oe_form').find('.import-statement');
 
                 local.widgetInstance.appendTo(element);
-                local.widgetInstance.updateId(record.id);
+                local.widgetInstance.updateId(record.id, record.type_statement);
             }
         });
     }

+ 18 - 6
views/import_statement.xml

@@ -2,8 +2,8 @@
 <openerp>
 	<data>
 		<!-- Registros de caja -->
-        <record id="views_import_statement_cash" model="ir.ui.view">
-            <field name="name">views.import.statement.cash</field>
+        <record id="eiru_import_statement_cash" model="ir.ui.view">
+            <field name="name">eiru.import.statement.cash</field>
             <field name="model">account.bank.statement</field>
             <field name="inherit_id" ref="account.view_bank_statement_form2"/>
             <field name="arch" type="xml">
@@ -16,19 +16,31 @@
             </field>
         </record>
 		<!-- Extractos bancarios -->
-		<record id="views_account_bank_voucher_import_bank" model="ir.ui.view">
-            <field name="name">account.bank.statement.import.voucher.bank</field>
+		<record id="eiru_import_statement_bank" model="ir.ui.view">
+            <field name="name">eiru.import.statement.bank</field>
             <field name="model">account.bank.statement</field>
             <field name="inherit_id" ref="account.view_bank_statement_form"/>
             <field name="arch" type="xml">
 				<field name='state' position="before">
-					<div class="import-statement" attrs="{'invisible': [('state','!=','open')]}"> </div>
+					<div class="import-statement" attrs="{'invisible': [('state','!=','draft')]}"> </div>
 				</field>
 				<field name="journal_id" position='after'>
 					<field name="type_statement"/>
 				</field>
             </field>
         </record>
-
+		<!-- Agrupación por tipo de caja  -->
+		<record id="eiru_import_statement_search" model="ir.ui.view">
+			<field name="name">eiru.import.statement.search</field>
+			<field name="model">account.bank.statement</field>
+			<field name="inherit_id" ref="account.view_account_bank_statement_filter"/>
+			<field name="arch" type="xml">
+				<search>
+					 <group expand="0" string="Group By">
+						<filter string="Tipo de Caja" context="{'group_by':'type_statement'}"/>
+					</group>
+				</search>
+			</field>
+		</record>
 	</data>
 </openerp>