소스 검색

Cantidad disponible de productos en TPV

SEBAS 1 년 전
커밋
c06abd66e4
13개의 변경된 파일235개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      README.rst
  2. 0 0
      __init__.py
  3. BIN
      __init__.pyc
  4. 17 0
      __openerp__.py
  5. 10 0
      data.xml
  6. 14 0
      doc/changelog.rst
  7. BIN
      static/description/icon.png
  8. 63 0
      static/description/index.html
  9. BIN
      static/description/screenshot-2.png
  10. BIN
      static/description/screenshot.png
  11. 24 0
      static/src/css/pos.css
  12. 79 0
      static/src/js/pos.js
  13. 20 0
      static/src/xml/pos.xml

+ 8 - 0
README.rst

@@ -0,0 +1,8 @@
+.. image:: https://itpp.dev/images/infinity-readme.png
+   :alt: Tested and maintained by IT Projects Labs
+   :target: https://itpp.dev
+
+Available quantity of products in POS
+=====================================
+
+Description: https://apps.odoo.com/apps/modules/8.0/pos_product_available/

+ 0 - 0
__init__.py


BIN
__init__.pyc


+ 17 - 0
__openerp__.py

@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+{
+    'name': 'Available quantity of products in POS',
+    'version': '1.0.2',
+    'author': 'IT-Projects LLC, Ivan Yelizariev',
+    'license': 'GPL-3',
+    'category': 'Point Of Sale',
+    'website': 'https://twitter.com/yelizariev',
+    'depends': ['point_of_sale', 'stock'],
+    'data': [
+        'data.xml',
+    ],
+    'qweb': [
+        'static/src/xml/pos.xml',
+    ],
+    'installable': True,
+}

+ 10 - 0
data.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <template id="assets_backend" name="pos assets" inherit_id="point_of_sale.assets_backend">
+            <xpath expr="." position="inside">
+                <script type="text/javascript" src="/pos_product_available/static/src/js/pos.js"></script>
+            </xpath>
+        </template>
+    </data>
+</openerp>

+ 14 - 0
doc/changelog.rst

@@ -0,0 +1,14 @@
+.. _changelog:
+
+Updates
+=========
+
+`1.0.2`
+-------
+
+- [FIX] update product counter when sale via invoice
+
+`1.0.1`
+-------
+
+- Show quantity related to POS's stock location only.

BIN
static/description/icon.png


+ 63 - 0
static/description/index.html

@@ -0,0 +1,63 @@
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2 class="oe_slogan">Available quantity of products in POS</h2>
+            <h3 class="oe_slogan">Let a cashier know how many products are available</h3>
+        </div>
+
+        <div class="oe_span6">
+            <div class="oe_demo oe_picture oe_screenshot">
+                <img src="screenshot.png"/>
+            </div>
+        </div>
+        <div class="oe_span6">
+            <p class="oe_mt32">
+                Adds available quantity at order panel
+            </p>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container oe_dark">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span6">
+            <p class="oe_mt32">
+                Adds available quantity at products.
+            </p>
+        </div>
+
+        <div class="oe_span6">
+            <div class="oe_demo oe_picture oe_screenshot">
+                <img src="screenshot-2.png"/>
+            </div>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2>Usage</h2>
+            <p class="oe_mt32">
+                There no any settings. Just install the module and start POS.
+            </p>
+            <p class="oe_mt32">
+                Works in offline mode.
+            </p>
+        </div>
+    </div>
+</section>
+
+<section class="oe_container">
+    <div class="oe_row oe_spaced">
+        <div class="oe_span12">
+            <h2>Need our service?</h2>
+            <p class="oe_mt32">Contact us by <a href="mailto:it@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p>
+            <ul>
+                <li><a href="mailto:it@it-projects.info">it@it-projects.info <i class="fa fa-envelope-o"></i></a></li>
+                <li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">
+https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li>
+            </ul>
+        </div>
+    </div>
+</section>

BIN
static/description/screenshot-2.png


BIN
static/description/screenshot.png


+ 24 - 0
static/src/css/pos.css

@@ -0,0 +1,24 @@
+.pos .product .qty-tag {
+    position: absolute;
+    top: 2px;
+    left: 2px;
+    vertical-align: top;
+    color: white;
+    line-height: 13px;
+    background: #7f82ac;
+    padding: 2px 5px;
+    border-radius: 2px;
+	font-weight: bold;
+}
+.pos .product .qty-tag.not-available {
+    background: #d882ac;
+}
+
+.pos .order .orderline .qty-info{
+	color: #777;
+	font-weight: bold;
+	font-style: normal;
+}
+.pos .order .orderline .qty-info.not-available{
+	color:red;
+}

+ 79 - 0
static/src/js/pos.js

@@ -0,0 +1,79 @@
+function pos_product_available(instance, module){
+
+    var PosModelSuper = module.PosModel;
+    module.PosModel = module.PosModel.extend({
+        load_server_data: function(){
+            var self = this;
+            var loaded = PosModelSuper.prototype.load_server_data.call(this);
+
+            loaded = loaded.then(function(){
+                return self.fetch(
+                    'product.product',
+                    ['qty_available'],
+                    [['sale_ok','=',true],['available_in_pos','=',true]],
+                    {'location': self.config.stock_location_id[0]}
+                );
+
+            }).then(function(products){
+                $.each(products, function(){
+                    $.extend(self.db.get_product_by_id(this.id) || {}, this);
+                });
+                return $.when();
+            });
+            return loaded;
+        },
+        refresh_qty_available:function(product){
+            var $elem = $("[data-product-id='"+product.id+"'] .qty-tag");
+            $elem.html(product.qty_available);
+            if (product.qty_available <= 0 && !$elem.hasClass('not-available')){
+                $elem.addClass('not-available');
+            }
+        },
+        push_order: function(order){
+            var self = this;
+            var pushed = PosModelSuper.prototype.push_order.call(this, order);
+            if (order){
+                order.get('orderLines').each(function(line){
+                    var product = line.get_product();
+                    product.qty_available -= line.get_quantity();
+                    self.refresh_qty_available(product);
+                });
+            }
+            return pushed;
+        },
+        push_and_invoice_order: function(order){
+            var self = this;
+            var invoiced = PosModelSuper.prototype.push_and_invoice_order.call(this, order);
+
+            if (order && order.get_client()){
+                if (order.get("orderLines")){
+                    order.get("orderLines").each(function(line){
+                        var product = line.get_product();
+                        product.qty_available -= line.get_quantity();
+                        self.refresh_qty_available(product);
+                    });
+                } else if (order.orderlines){
+                    order.orderlines.each(function(line){
+                        var product = line.get_product();
+                        product.qty_available -= line.get_quantity();
+                        self.refresh_qty_available(product);
+                    });
+                }
+            }
+
+            return invoiced;
+        },
+    });
+}
+
+(function(){
+    var _super = window.openerp.point_of_sale;
+    window.openerp.point_of_sale = function(instance){
+        _super(instance);
+        var module = instance.point_of_sale;
+
+        pos_product_available(instance, module);
+
+        $('<link rel="stylesheet" href="/pos_product_available/static/src/css/pos.css"/>').appendTo($("head"));
+    };
+})();

+ 20 - 0
static/src/xml/pos.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates id="template" xml:space="preserve">
+    <t t-extend="Product">
+        <t t-jquery=".product-img" t-operation="append">
+            <span t-attf-class="qty-tag #{product.qty_available lte 0 ? 'not-available':''}">
+                <t t-esc="product.qty_available"/>
+            </span>
+        </t>
+    </t>
+    <t t-extend="Orderline">
+        <t t-jquery=".info-list>t:first-child">
+            this.attr('t-if', "line.get_quantity_str() !== '1' || line.selected || line.get_product().qty_available lt line.quantity ");
+        </t>
+        <t t-jquery="t[t-esc='line.get_quantity_str()']" t-operation="after">
+            <t t-set='qty_available' t-value='line.get_product().qty_available'/>
+            (of <span t-attf-class="qty-info #{qty_available lt line.quantity ? 'not-available':''}"><t t-esc="qty_available"/></span>)
+        </t>
+    </t>
+
+</templates>