Sfoglia il codice sorgente

[ADD] Commit inicial

adrielso 7 anni fa
commit
a425407ce0

+ 2 - 0
__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+import models

BIN
__init__.pyc


+ 21 - 0
__openerp__.py

@@ -0,0 +1,21 @@
+# -*- coding ;utf-8 -*-
+{
+    'name': 'Eiru Import Statement',
+    'author':  'Adrielso Kunert',
+    'version': '0.1',
+    'category': 'account',
+    'description': "Permite Importar los resultado de los movimiento de de las cajas Normales a la caja General.",
+    'depends': [
+        'account',
+        'eiru_assets',
+    ],
+    'data': [
+        'views/template.xml',
+        'views/import_statement.xml'
+    ],
+    'qweb': [
+        'static/src/xml/*.xml'
+    ],
+
+    'installable': True,
+}

+ 2 - 0
models/__init__.py

@@ -0,0 +1,2 @@
+# -*- coding:utf-8 -*-
+import account_bank_statement

BIN
models/__init__.pyc


+ 76 - 0
models/account_bank_statement.py

@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+from openerp import models, fields, tools, api
+
+class AccountBankStatement(models.Model):
+    _inherit = 'account.bank.statement'
+
+    type_statement = fields.Selection([('normal', 'Normal'),('general', 'General')],'Tipo de Caja ', default="normal", help="Tipo de caja")
+
+    @api.model
+    def get_statement_point_of_sale(self, id):
+        accountStatement = self._get_statement(id)
+        decimal_precision = self.env['decimal.precision'].precision_get('Account')
+
+        if (not accountStatement):
+            return False;
+
+        accountStatementLine = self._get_statement_line(accountStatement.id)
+
+        statementPointOfSale = self._get_statement_point_of_sale(accountStatement)
+        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',
+                    '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
+
+
+    '''
+        Get Account Bank Statement
+    '''
+    def _get_statement(self, id):
+        return self.env['account.bank.statement'].browse(id)
+
+    '''
+        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')
+        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
+            })
+
+        return pointSatatement

BIN
models/account_bank_statement.pyc


BIN
static/description/icon.png


+ 4 - 0
static/src/css/style.css

@@ -0,0 +1,4 @@
+.import-statement {
+    width: auto;
+    float: left;
+}

+ 87 - 0
static/src/js/import_statement.js

@@ -0,0 +1,87 @@
+openerp.eiru_import_statement = function (instance, local) {
+    local.widgetInstance = null;
+    local.parentInstance = null;
+
+    local.VoucherImportWidget = instance.Widget.extend({
+        template: 'EiruImport.Statement',
+        id: undefined,
+        bankStatement: [],
+
+        init: function (parent) {
+            this._super(parent);
+        },
+        // Actualizar id del Objeto
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+        },
+        start: function() {
+            var self = this;
+            this.$el.click(function() {
+                self.fetchInitial();
+            });
+        },
+        /* Iniciar */
+        fetchInitial: function() {
+            var self = this;
+
+            self.$el.attr("disabled", true);
+
+            self.fetchBankStatement(self.id).then(function(bankStatement) {
+                return bankStatement;
+            }).then(function(bankStatement) {
+                self.bankStatement = bankStatement;
+                if (!!self.bankStatement.length && !!self.bankStatement[0].pos_session_id){
+                    instance.web.notification.do_notify("Atención","Esta opción solo esta disponible para la caja general.");
+                    return false;
+                }
+                return self.fetchStatementPointOfSale(self.id).then(function(statementPoinOfSale){
+                    return statementPoinOfSale;
+                }).then(function(statementPoinOfSale){
+                    self.statementPoinOfSale = statementPoinOfSale;
+                });
+            }).then(function() {
+                local.parentInstance.reload();
+                self.$el.removeAttr("disabled");
+            });
+        },
+        /* Registro de Caja */
+        fetchBankStatement: function(id) {
+            var fields = ['id', 'journal_id', 'pos_session_id', 'date'];
+            var domain = [['id', '=', id]];
+            var statement = new instance.web.Model('account.bank.statement');
+            return statement.query(fields).filter(domain).all();
+        },
+        /* Get Statement Point of Sale*/
+        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()
+            });
+        }
+    });
+
+    if (instance.web && instance.web.FormView) {
+        instance.web.FormView.include({
+            load_record: function (record) {
+                this._super.apply(this, arguments);
+
+                if (this.model !== 'account.bank.statement') return;
+
+                local.parentInstance = this;
+
+                if (local.widgetInstance)
+                    local.widgetInstance.updateId(record.id);
+
+                if (this.$el.find('.button-import-statement').length !== 0) return;
+
+                local.widgetInstance = new local.VoucherImportWidget(this);
+                var element = this.$el.find('.oe_form').find('.import-statement');
+
+                local.widgetInstance.appendTo(element);
+                local.widgetInstance.updateId(record.id);
+            }
+        });
+    }
+
+}

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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="EiruImport.Statement">
+        <button class="button-import-statement oe_button oe_form_button oe_highlight">
+            <div>Importar Caja</div>
+        </button>
+  </t>
+</templates>

+ 34 - 0
views/import_statement.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+		<!-- Registros de caja -->
+        <record id="views_import_statement_cash" model="ir.ui.view">
+            <field name="name">views.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">
+				<field name='state' position="before">
+					<div class="import-statement" attrs="{'invisible': [('state','!=','open')]}"> </div>
+				</field>
+				<field name="journal_id" position='after'>
+					<field name="type_statement"/>
+				</field>
+            </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>
+            <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>
+				</field>
+				<field name="journal_id" position='after'>
+					<field name="type_statement"/>
+				</field>
+            </field>
+        </record>
+
+	</data>
+</openerp>

+ 10 - 0
views/template.xml

@@ -0,0 +1,10 @@
+<openerp>
+    <data>
+        <template id="eiru_import_statement.eiru_assets" name="eiru_import_statement_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+                <link rel="stylesheet" href="/eiru_import_statement/static/src/css/style.css"/>
+                <script type="text/javascript" src="/eiru_import_statement/static/src/js/import_statement.js"/>
+            </xpath>
+        </template>
+    </data>
+</openerp>