Przeglądaj źródła

[ADD] agregado ventana modal para elegir pedido de compra

Rodney Elpidio Enciso Arias 7 lat temu
rodzic
commit
b945601c9d

+ 2 - 2
__openerp__.py

@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
 {
 {
     'name' : 'Eiru Purchase to Sale',
     'name' : 'Eiru Purchase to Sale',
-    'version' : '1.0',
+    'version' : '2.0',
     'description' : """
     'description' : """
     """,
     """,
     'author' : 'Eiru',
     'author' : 'Eiru',
@@ -15,7 +15,7 @@
         'views/template.xml',
         'views/template.xml',
         'views/sale_order_search_box.xml',
         'views/sale_order_search_box.xml',
     ],
     ],
-    'qweb' : ['static/src/xml/*.xml',],
+    'qweb' : ['static/src/xml/*.xml','static/src/xml/modal/*.xml'],
     'installable' : True,
     'installable' : True,
     'auto_install' : False,
     'auto_install' : False,
 }
 }

+ 2 - 0
model/sale_order.py

@@ -19,7 +19,9 @@ class SaleOrder(models.Model):
 				'order_id': x['order_id'],
 				'order_id': x['order_id'],
                 'product_id': x['product_id'],
                 'product_id': x['product_id'],
                 'product_uom_qty': x['product_uom_qty'],
                 'product_uom_qty': x['product_uom_qty'],
+                'product_uos': x['product_uos'],
 			})
 			})
+			# print sale_order_line
 			new_line.create(sale_order_line)
 			new_line.create(sale_order_line)
 
 
 	@api.depends('order_line.price_subtotal')
 	@api.depends('order_line.price_subtotal')

BIN
model/sale_order.pyc


+ 62 - 54
static/src/js/main.js

@@ -2,11 +2,16 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
     local.widgetInstance = null;
     local.widgetInstance = null;
     local.parentInstance = null;
     local.parentInstance = null;
 
 
+    var model = openerp;
+    var Qweb = openerp.web.qweb;
+
     local.PurchaseToSaleWidget = instance.Widget.extend({
     local.PurchaseToSaleWidget = instance.Widget.extend({
         template : "eiru_purchase_to_sale.PurchaseToSale",
         template : "eiru_purchase_to_sale.PurchaseToSale",
+        
         init:function(parent){
         init:function(parent){
             this._super(parent);
             this._super(parent);
             this.buttons = parent.$buttons;
             this.buttons = parent.$buttons;
+
         },
         },
 
 
         updateId : function(id){
         updateId : function(id){
@@ -24,34 +29,6 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
                 self.fecthInitial();
                 self.fecthInitial();
             });
             });
         },
         },
-        showMensaje : function(){
-            var self = this;
-            $("#dialog" ).dialog({
-                autoOpen: true,
-                resizable: false,
-                modal: true,
-                title: 'Atención',
-                width: 500,
-                open: function() {
-                    $(this).html('Debe guardar el pedido anter de continuar');
-                },
-                show: {
-                    effect: "fade",
-                    duration: 200
-                },
-                hide: {
-                    effect: "fade",
-                    duration: 200
-                },
-                buttons: {
-                    Aceptar: function() {
-                        $(this).dialog('close');
-                        // self.renderReport();
-                    }
-                }
-            });
-            return
-        },
 
 
         fecthInitial: function(){
         fecthInitial: function(){
             var id= openerp.webclient._current_state.id;
             var id= openerp.webclient._current_state.id;
@@ -66,7 +43,7 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
                 return self.fetchPurchaseOrderLine();
                 return self.fetchPurchaseOrderLine();
             }).then(function(PurchaseOrderLine){
             }).then(function(PurchaseOrderLine){
                 self.PurchaseOrderLine = PurchaseOrderLine;
                 self.PurchaseOrderLine = PurchaseOrderLine;
-                self.inicializarBuscador();
+                self.showModal();
             });
             });
             return false;
             return false;
         },
         },
@@ -84,7 +61,7 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
 
 
         fetchPurchaseOrder: function () {
         fetchPurchaseOrder: function () {
             var defer = $.Deferred();
             var defer = $.Deferred();
-            var fields=['id','name'];
+            var fields=['id','name','picking_type_id','partner_id','amount_total'];
             var domain=[['state','=','draft']];
             var domain=[['state','=','draft']];
             var PurchaseOrder = new instance.web.Model('purchase.order');
             var PurchaseOrder = new instance.web.Model('purchase.order');
             PurchaseOrder.query(fields).filter(domain).order_by('id').all().then(function(results){
             PurchaseOrder.query(fields).filter(domain).order_by('id').all().then(function(results){
@@ -95,7 +72,7 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
 
 
         fetchPurchaseOrderLine: function () {
         fetchPurchaseOrderLine: function () {
             var defer = $.Deferred();
             var defer = $.Deferred();
-            var fields=['id','product_id','order_id','product_qty'];
+            var fields=['id','product_id','order_id','product_qty','product_uom'];
             var domain=[['state','=','draft']];
             var domain=[['state','=','draft']];
             var PurchaseOrderLine = new instance.web.Model('purchase.order.line');
             var PurchaseOrderLine = new instance.web.Model('purchase.order.line');
             PurchaseOrderLine.query(fields).filter(domain).all().then(function(results){
             PurchaseOrderLine.query(fields).filter(domain).all().then(function(results){
@@ -104,28 +81,60 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
             return defer;
             return defer;
         },
         },
 
 
-        inicializarBuscador: function () {
+        showModal: function (e) {
             var self = this;
             var self = this;
-            var SelectOrder;
-            var results = self.PurchaseOrder;
-            results = _.map(results, function (item) {
-            return {
-                    label: item.name,
-                    value: item.id + '-' + item.name
+            if (self.data <=0) {
+                model.web.notification.do_warn("Atención","Sin datos");
+                return
+            }
+
+            var PurchaseOrder = self.PurchaseOrder;
+            var titleData = [
+                {
+                    title: "Pedidos"
+                }
+            ];
+            var headerModal = [
+                {
+                    title: "Proveedor"
+                },
+                {
+                    title: "Numero"
+                },
+                {
+                    title: "Destino"
+                },
+                {
+                    title: "Monto"
                 }
                 }
+            ];
+
+            var modal = Qweb.render('PurchaseModal', {
+                data: PurchaseOrder,
+                dataThead: headerModal,
+                modalTitle: titleData
             });
             });
-            $('#PurchaseSearch').autocomplete({
-                source: results,
-                minLength: 3,
-                select: function (e, ui) {
-                    $(this).val('');
-                    SelectOrder = ui.item;
-                    self.factInsertProduct(SelectOrder);
-                    return false;
-                }  
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal()
+            $('.expired-account-modal').on('hidden.bs.modal', function (e) {
+                self.removeModal(e);
+            })
+
+            var contenido = $('.expired-account-modal').find('.table-tbody');
+            contenido.click(function (e) {
+                $(contenido).find('tr').removeClass('table-row-select');
+                $(e.target).closest('tr').addClass('table-row-select');
+                var children_id =$(e.target).closest('tr').children()[0].textContent;
+                self.Insert(children_id);
             });
             });
         },
         },
 
 
+        removeModal: function (e) {
+            $('.expired-account-modal').remove();
+            $('.modal-backdrop').remove();
+        },
+
         getPurchaseOrderLine:function(id) {
         getPurchaseOrderLine:function(id) {
             var self = this;
             var self = this;
             return _.flatten(_.filter(self.PurchaseOrderLine,function (inv) {
             return _.flatten(_.filter(self.PurchaseOrderLine,function (inv) {
@@ -133,18 +142,17 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
             }));
             }));
         },
         },
 
 
-        factInsertProduct:function(selectProduct){
+        Insert:function(id){
             var self = this;
             var self = this;
             var data = [];
             var data = [];
-            console.log(self);
-            var order = selectProduct.value.split('-');
-            var order_line = self.getPurchaseOrderLine(order[0]);
+            var order_line = self.getPurchaseOrderLine(id);
             if(self.SaleOrder.length > 0){
             if(self.SaleOrder.length > 0){
                 _.each(order_line, function(item){
                 _.each(order_line, function(item){
                     data.push({
                     data.push({
                         order_id: self.SaleOrder[0].id,
                         order_id: self.SaleOrder[0].id,
                         product_id: item.product_id[0],
                         product_id: item.product_id[0],
-                        product_uom_qty: item.product_qty
+                        product_uom_qty: item.product_qty,
+                        product_uos: item.product_uom[0],
                     });
                     });
                 });
                 });
                 self.joinSaleLine(data).then(function(results) {
                 self.joinSaleLine(data).then(function(results) {
@@ -152,9 +160,8 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
                 }).then(function(){
                 }).then(function(){
                     self.reloadLine();
                     self.reloadLine();
                 });
                 });
-            }else{
-                self.showMensaje();
             }
             }
+            // console.log(data);
         },
         },
 
 
         joinSaleLine: function(data) {
         joinSaleLine: function(data) {
@@ -166,6 +173,7 @@ openerp.eiru_purchase_to_sale = function (instance, local) {
             }).then(function(results) {
             }).then(function(results) {
                 defer.resolve(results);
                 defer.resolve(results);
             });
             });
+            self.removeModal();
             return defer;
             return defer;
         },
         },
     });
     });

+ 61 - 0
static/src/xml/modal/purchase_modal.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="PurchaseModal">
+        <div class="modal in expired-account-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg" role="document">
+                <div class="modal-content openerp">
+                    <!-- title  -->
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">x</button>
+                        <h3 class="modal-title" t-foreach="modalTitle" t-as="title">
+                            <t t-esc="title_value.title"/>
+                        </h3>
+                    </div>
+                    <div class="oe_view_manager_body table-model">
+                        <!-- tabla Head -->
+                        <div class="modal-head-wrapper">
+                            <table class="oe_list_content">
+                                <thead >
+                                    <tr class="oe_list_header_columns" >
+                                        <th t-foreach="dataThead" t-as="head" class="oe_list_header_char oe_sortable">
+                                            <t t-esc="head_value.title"/>
+                                        </th>
+                                    </tr>
+                                </thead>
+                            </table>
+                        </div>
+                        <!-- table body -->
+                        <div class="modal-items-wrapper">
+                            <table class="oe_list_content">
+                                <tbody class="table-tbody">
+                                    <!-- <colgroup>
+                                        <col width='30%'/>
+                                        <col width='20%'/>
+                                        <col width='30%'/>
+                                        <col width='20%'/>
+                                    </colgroup> -->
+                                    <tr t-foreach="data" t-as="field">
+                                        <td style="display:none;"><t t-esc="field_value.id"/></td>
+                                        <td><t t-esc="field_value.partner_id[1]"/></td>
+                                        <td><t t-esc="field_value.name"/></td>
+                                        <td><t t-esc="field_value.picking_type_id[1]"/></td>
+                                        <td>
+                                            <t t-set="monto" t-value="field_value.amount_total"/>
+                                            <t t-js="ctx">
+                                                ctx.monto = accounting.formatNumber(ctx.monto,0,'.',',');
+                                            </t>
+                                            <t t-esc="monto"/>
+                                        </td>
+                                    </tr>
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <div class="modal-footer">
+                        <!-- <button type="button" class="btn btn-default " data-dismiss="modal">Aceptar</button> -->
+                    </div>
+                </div> 
+            </div>
+        </div>
+    </t>
+</template>

+ 1 - 9
static/src/xml/view.xml

@@ -1,14 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <template xml:space="preserve">
 <template xml:space="preserve">
     <t t-name="eiru_purchase_to_sale.PurchaseToSale">
     <t t-name="eiru_purchase_to_sale.PurchaseToSale">
-        <div class="ui-widget">
-        	<div class="ui-widget col-md-4 col-md-offset-4">
-        		<div id="dialog"></div>
-			    <div class="form-group">
-		    		<label for="PurchaseSearch">Buscar Solicitud de compra: </label>
-			  		<input id="PurchaseSearch" class="form-control"/>
-		    	</div>	
-        	</div>
-		</div>
+        <button type="button" class="oe_button oe_form_button oe_highlight order">Pedidos</button>
     </t>
     </t>
 </template>
 </template>

+ 1 - 3
views/sale_order_search_box.xml

@@ -7,9 +7,7 @@
             <field name="inherit_id" ref="sale.view_order_form"/>
             <field name="inherit_id" ref="sale.view_order_form"/>
             <field name="arch" type="xml">
             <field name="arch" type="xml">
                 <field name="order_line" position="before">
                 <field name="order_line" position="before">
-                    <div class="oe_edit_only">
-                        <div class="product_search_box" attrs="{'invisible': [('state','not in',['draft','sent'])]}"></div>
-                    </div>
+                    <div class="product_search_box" attrs="{'invisible': [('state','not in',['draft','sent'])]}"></div>
                 </field>
                 </field>
             </field>
             </field>
         </record>
         </record>

+ 1 - 0
views/template.xml

@@ -3,6 +3,7 @@
         <template id="eiru_purchase_to_sale.assets_backend" name="purchase_to_sale_assets" inherit_id="eiru_assets.assets">
         <template id="eiru_purchase_to_sale.assets_backend" name="purchase_to_sale_assets" inherit_id="eiru_assets.assets">
             <xpath expr="." position="inside">
             <xpath expr="." position="inside">
                 <script type="text/javascript" src="/eiru_purchase_to_sale/static/src/js/main.js"/>
                 <script type="text/javascript" src="/eiru_purchase_to_sale/static/src/js/main.js"/>
+                <!-- <script type="text/javascript" src="/eiru_purchase_to_sale/static/src/js/custom.js"/> -->
             </xpath>
             </xpath>
         </template>
         </template>
     </data>
     </data>