Rodney Enciso Arias 7 lat temu
commit
37b21cfc5d

+ 1 - 0
__init__.py

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

BIN
__init__.pyc


+ 23 - 0
__openerp__.py

@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Pos and Purchases Buttons',
+    'version': '1.0',
+    'author': 'Eiru',
+    'category': 'extra tool',
+    'depends': ['account','eiru_pos','eiru_purchases'],
+    'data': [
+        'views/templates.xml',
+        'views/account_invoice_button_view.xml',
+        'views/account_voucher_button_view.xml',
+        'views/purchase_order_button_view.xml',
+        'views/sale_order_button_view.xml',
+        'views/menus.xml',
+    ],
+    'qweb': [
+        'static/src/xml/*.xml',
+        'static/src/xml/modal/*.xml',
+    ],
+
+    'installable': True,
+    'auto_install': False,
+ }

BIN
static/description/icon.png


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

@@ -0,0 +1,6 @@
+.modal-buttons{
+    width: 100% !important;
+    height: 80px;
+    font-size: 20px !important;
+    background: #ffffff !important;
+}

+ 104 - 0
static/src/js/pos_buttons.js

@@ -0,0 +1,104 @@
+(function() {
+
+    var QWeb = openerp.web.qweb;
+    openerp.widgetInstance = null;
+    openerp.PosButtons = {};
+
+    openerp.PosButtons = openerp.Widget.extend({
+        template: 'pos_buttons.PosButtonsWidget',
+        row_id_select: undefined,
+        
+        init: function (parent) {
+            this._super(parent);
+        },
+        
+        start: function () {
+            var self = this;
+            var modal_button = this.$el.find('.add-modal');
+            modal_button.click(function() {
+                self.fectchModal();
+            });
+        },
+        
+        updateId: function(id) {
+            var self = this;
+            self.id = id;
+        },
+        
+        removeModal: function() {
+            $('.pos-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('PosModal');
+            $('.openerp_webclient_container').after(modal);
+            $('.pos-modal').modal();
+
+            $('.sale').click(function(){
+                
+                self.do_action({
+                    
+                    type: 'ir.actions.client',
+                    tag: "eiru_pos.action_launch",
+                    target: 'current',
+                    params: {'mode': 'sale'},
+                    context: self.session.user_context,
+
+                });
+                self.removeModal();
+            });
+            $('.budget').click(function(){
+                
+                self.do_action({
+                    
+                    type: 'ir.actions.client',
+                    tag: "eiru_pos.action_launch",
+                    target: 'current',
+                    params: {'mode': 'budget'},
+                    context: self.session.user_context,
+
+                });
+                self.removeModal();
+            });
+
+            $('.pos-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 !== 'out_invoice') return
+                openerp.parentInstance = this;
+                if (openerp.widgetInstance) {
+                    openerp.widgetInstance.updateId(record.id);
+                }
+                if (this.$el.find('.pos-button').length !== 0 )
+                    return;
+                openerp.widgetInstance = new openerp.PosButtons(this);
+                var elemento = $('.oe_view_manager_buttons');
+                elemento = elemento.find('.oe_list_buttons');
+                openerp.widgetInstance.appendTo(elemento);
+                openerp.widgetInstance.updateId(record.id);
+            }
+        })
+    }
+
+})();

+ 104 - 0
static/src/js/purchases_buttons.js

@@ -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);
+            }
+        })
+    }
+
+})();

+ 29 - 0
static/src/xml/modal/pos_modal.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="PosModal">
+        <div class="modal in pos-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content openerp">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title">
+                            Crear
+                        </h3>
+                    </div>
+                    <div class="modal-body">
+                        <div class="">
+                            <div class="row">
+                                <div class="col-md-6">
+                                    <button type="button" class="oe_form_button oe_button modal-buttons sale">Venta</button>
+                                </div>
+                                <div class="col-md-6">
+                                    <button type="button" class="oe_form_button oe_button modal-buttons budget">Presupuesto</button>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 29 - 0
static/src/xml/modal/purchases_modal.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="PurchaseModal">
+        <div class="modal in purchases-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog" role="document">
+                <div class="modal-content openerp">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">×</button>
+                        <h3 class="modal-title">
+                            Crear
+                        </h3>
+                    </div>
+                    <div class="modal-body">
+                        <div class="">
+                            <div class="row">
+                                <div class="col-md-6">
+                                    <button type="button" class="oe_form_button oe_button modal-buttons purchase">Compra</button>
+                                </div>
+                                <div class="col-md-6">
+                                    <button type="button" class="oe_form_button oe_button modal-buttons expense">Gasto</button>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="pos_buttons.PosButtonsWidget">
+        <div class="pos-button">
+            <button class="oe_button oe_list_add oe_highlight add-modal" type="button">Crear</button>
+        </div>
+  </t>
+</templates>

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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+    <t t-name="purchases_buttons.PurchasesButtonsWidget">
+        <div class="purchase-button">
+            <button class="oe_button oe_list_add oe_highlight add-purchase-modal" type="button">Crear</button>
+        </div>
+  </t>
+</templates>

+ 46 - 0
views/account_invoice_button_view.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data> 
+        <!-- Account Invoice Tree -->
+        <record id="account_invoice_button_tree" model="ir.ui.view">
+            <field name="name">pos_buttons.account.invoice.button.tree</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr='//tree[@string="Invoice"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+            </field>
+        </record>
+        
+        <!-- Customer: Account Invoice Form -->
+        <record id="account_invoice_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.account.invoice.button.form</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Invoice"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Invoice"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record>
+        
+        <!-- Supplier: Account Invoice Form -->
+        <record id="account_supplier_invoice_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.account.supplier.invoice.button.form</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_supplier_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Supplier Invoice"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Supplier Invoice"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record>    
+    </data>
+</openerp>

+ 46 - 0
views/account_voucher_button_view.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data> 
+        <!-- Account Voucher Tree -->
+        <record id="account_voucher_button_tree" model="ir.ui.view">
+            <field name="name">pos_buttons.account.voucher.button.tree</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_voucher_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr='//tree[@string="Voucher Entries"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+            </field>
+        </record>
+        
+        <!-- Customer: Account Voucher Form -->
+        <record id="account_supplier_voucher_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.account.voucher.button.form</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_vendor_receipt_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Receipt"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Receipt"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record> 
+
+        <!-- Supplier: Account Voucher Form -->
+        <record id="account_supplier_voucher_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.account.supplier.voucher.button.form</field>
+            <field name="model">account.voucher</field>
+            <field name="inherit_id" ref="account_voucher.view_vendor_payment_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Voucher Payment"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Voucher Payment"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record>   
+    </data>
+</openerp>

+ 47 - 0
views/menus.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data> 
+        
+        <!-- Pedido de Venta -->
+        <menuitem id="pos_buttons.new_sale" name="Nueva venta" parent="base.menu_sales" action="eiru_pos.pos_action" sequence="6"/>
+        
+        <!-- Presupuesto -->
+        <menuitem id="pos_buttons.new_budget" name="Nuevo presupuesto" parent="base.menu_sales" action="eiru_pos.budget_action" sequence="7"/>
+        
+        <!-- Pedido de compra -->
+        <menuitem id="pos_buttons.new_purchase" name="Nueva compra" parent="purchase.menu_procurement_management" action="eiru_purchases.purchases_action" sequence="7" />
+
+        <!-- Gastos -->
+        <menuitem id="pos_buttons.new_expense" name="Nuevo gasto" parent="purchase.menu_procurement_management" action="eiru_purchases.expenses_action" sequence="8" />  
+
+        <!-- Historico de compras -->
+		<record id="action_unified_purchase_order" model="ir.actions.act_window">
+            <field name="name">Historico de Compras</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">purchase.order</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="purchase.purchase_order_tree"/>
+            <field name="view_mode">tree,form,calendar,graph</field>
+            <field name="search_view_id" ref="purchase.view_purchase_order_filter"/>
+        </record>
+
+        <menuitem id="menu_unified_purchase_order"
+                action="action_unified_purchase_order" parent="purchase.menu_procurement_management"
+                sequence="1"/>
+
+        <!-- Historico de ventas -->
+         <record id="action_unified_order" model="ir.actions.act_window">
+            <field name="name">Historico de Ventas</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">sale.order</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="sale.view_quotation_tree"/>
+            <field name="view_mode">tree,form,calendar,graph</field>
+            <field name="search_view_id" ref="sale.view_sales_order_filter"/>
+        </record>
+
+        <menuitem id="menu_unified_order"
+                action="action_unified_order" parent="base.menu_sales"
+                sequence="2"/>
+    </data>
+</openerp>

+ 31 - 0
views/purchase_order_button_view.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data> 
+        <!-- Purchase Order Tree -->
+        <record id="purchase_order_button_tree" model="ir.ui.view">
+            <field name="name">pos_buttons.purchase.order.button.tree</field>
+            <field name="model">purchase.order</field>
+            <field name="inherit_id" ref="purchase.purchase_order_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr='//tree[@string="Purchase Order"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+            </field>
+        </record>
+        
+        <!-- Purchase Order Form -->
+        <record id="purchase_order_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.purchase.order.button.form</field>
+            <field name="model">purchase.order</field>
+            <field name="inherit_id" ref="purchase.purchase_order_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Purchase Order"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Purchase Order"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record>    
+    </data>
+</openerp>

+ 42 - 0
views/sale_order_button_view.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data> 
+        <!-- Sale Order Tree -->
+        <record id="sale_order_button_tree" model="ir.ui.view">
+            <field name="name">pos_buttons.sale.order.button.tree</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr='//tree[@string="Sales Orders"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+            </field>
+        </record>
+
+         <record id="sale_order_button_quotation_tree" model="ir.ui.view">
+            <field name="name">pos_buttons.sale.order.button.quotation.tree</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_quotation_tree"/>
+            <field name="arch" type="xml">
+                <xpath expr='//tree[@string="Quotation"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+            </field>
+        </record>
+        
+        <!-- Sale Order Form -->
+        <record id="sale_order_button_form" model="ir.ui.view">
+            <field name="name">pos_buttons.sale.order.button.form</field>
+            <field name="model">sale.order</field>
+            <field name="inherit_id" ref="sale.view_order_form"/>
+            <field name="arch" type="xml">
+                <xpath expr='//form[@string="Sales Order"]' position='attributes'>
+                    <attribute name="create">false</attribute>
+                </xpath>
+                <xpath expr='//form[@string="Sales Order"]' position='attributes'>
+                    <attribute name="edit">false</attribute>
+                </xpath>
+            </field>
+        </record>    
+    </data>
+</openerp>

+ 11 - 0
views/templates.xml

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