Browse Source

[10.0][ADD] pos_lot_selection: New module (#256)

pull/285/head
David Vidal 7 years ago
committed by Ignacio Ales
parent
commit
1fe6e52314
  1. 82
      pos_lot_selection/README.rst
  2. 1
      pos_lot_selection/__init__.py
  3. 24
      pos_lot_selection/__manifest__.py
  4. 28
      pos_lot_selection/i18n/es.po
  5. BIN
      pos_lot_selection/static/description/icon.png
  6. 29
      pos_lot_selection/static/src/css/pos.css
  7. 62
      pos_lot_selection/static/src/js/chrome.js
  8. 56
      pos_lot_selection/static/src/js/models.js
  9. 27
      pos_lot_selection/static/src/xml/pos.xml
  10. 15
      pos_lot_selection/templates/assets.xml

82
pos_lot_selection/README.rst

@ -0,0 +1,82 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
=================
POS Lot Selection
=================
This module allows to pick between existing lots in POS frontend.
Configuration
=============
1. Go to *Inventory > Settings* and set the option *Track lots or serial
numbers*
2. Chose a product that is stockable, go to its *Inventory*
tab, and set *Tracking* to *By Lots*.
3. Go to its *Sales* tab and set it as *Available in the Point of Sale*.
4. Click on *Update Qty On Hand*, chose the same location configured in the
POS you want the lot available in; write a quantity; unfold the *Lot/Serial
Number* field and pick create one if none is available yet.
5. Create a new lot with the serial number of your choice.
Usage
=====
* Open a POS Session.
* Choose a product with required lot.
* There is a new select field with the lots available for that product.
* If lot quantity can't cover the order line demand it won't be available to
pick.
* If there were many lots to fill the value of one of them can be propagated to
the rest with the new clone control on the right of the lot field.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/184/10.0
Known issues / Roadmap
======================
* Lot selection is only available when the POS is online. In offline mode the
select isn't loaded and the lot has to be manually set.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/pos/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
Contributors
------------
* David <david.vidal@tecnativa.com>
* (https://www.tecnativa.com)
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

1
pos_lot_selection/__init__.py

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

24
pos_lot_selection/__manifest__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Tecnativa S.L. - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'POS Lot Selection',
'version': '10.0.1.0.0',
'category': 'Point of Sale',
'author': 'Tecnativa,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/pos',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
'templates/assets.xml',
],
'qweb': [
'static/src/xml/pos.xml'
],
'application': False,
'installable': True,
}

28
pos_lot_selection/i18n/es.po

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_lot_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-13 09:16+0000\n"
"PO-Revision-Date: 2018-03-13 09:16+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_lot_selection
#: model:ir.model,name:pos_lot_selection.model_stock_quant
msgid "Quants"
msgstr "Quants"
#. module: pos_lot_selection
#. openerp-web
#: code:addons/pos_lot_selection/static/src/xml/pos.xml:12
#, python-format
msgid "Select a Serial/Lot Number"
msgstr "Escoja un nº de Serie / de Lote"

BIN
pos_lot_selection/static/description/icon.png

After

Width: 499  |  Height: 499  |  Size: 3.9 KiB

29
pos_lot_selection/static/src/css/pos.css

@ -0,0 +1,29 @@
/* Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
*/
.pos .popup .packlot-select {
border-bottom: solid 1px rgba(60,60,60,0.1);
margin-top: 3px;
}
.pos .popup select {
text-align: left;
padding: 10px;
display: inline-block;
border-radius: 3px;
border: solid 1px #cecbcb;
margin-bottom: 4px;
background: white;
font-family: "Lato","Lucida Grande", Helvetica, Verdana, Arial;
color: #444;
width: 80%;
min-height: 44px;
font-size: 20px;
box-sizing: border-box;
}
.pos .popup select:focus, .pos .popup select:active {
outline: none;
box-shadow: 0px 0px 0px 3px #6EC89B;
}

62
pos_lot_selection/static/src/js/chrome.js

@ -0,0 +1,62 @@
/* Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
odoo.define("pos_lot_selection.chrome", function (require) {
"use strict";
var chrome = require("point_of_sale.chrome");
chrome.Chrome.include({
build_widgets: function () {
var res = this._super.apply(this, arguments);
var packlotline = this.gui.popup_instances.packlotline;
// Add events over instanced popup
var events = {
"change .packlot-line-select": "lot_to_input",
"click .lot-clone": "clone_input",
};
packlotline.events = Object.assign(
packlotline.events, events
);
// Add methods over instanced popup
// Write the value in the corresponding input
packlotline.lot_to_input = function (event) {
var $select = this.$("select.packlot-line-select");
var $option = this.$("select.packlot-line-select option");
var $input = this.$el.find("input[cid='" + this.active_cid + "']");
if ($input.length) {
$input[0].value = $select[0].value;
$input.focus();
}
$option.prop('selected', function () {
return this.defaultSelected;
});
};
// Tracks the last selected input
packlotline.lose_input_focus = function (event) {
var $input = $(event.target),
cid = $input.attr('cid');
this.active_cid = cid;
var lot_model = this.options.pack_lot_lines.get({cid: cid});
lot_model.set_lot_name($input.val());
};
// Clones content of input to all the others
packlotline.clone_input = function (event) {
var $input = $(event.target).prev().prev(),
cid = $input.attr('cid');
var $clone_input = this.$el.find("input");
if ($clone_input.length > 1) {
for (var i = 0; i < $clone_input.length; i++) {
if ($clone_input[i].getAttribute('cid') != cid) {
$clone_input[i].value = $input.val();
$clone_input[i].blur();
}
}
}
}
this.gui.popup_instances.packlotline = packlotline;
return res;
},
});
});

56
pos_lot_selection/static/src/js/models.js

@ -0,0 +1,56 @@
/* Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */
odoo.define("pos_lot_selection.models", function (require) {
"use strict";
var models = require("point_of_sale.models");
var Model = require("web.DataModel");
var session = require("web.session");
models.PosModel = models.PosModel.extend({
get_lot: function(product, location_id) {
var done = new $.Deferred();
session.rpc("/web/dataset/search_read", {
"model": "stock.quant",
"domain": [
["location_id", "=", location_id],
["product_id", "=", product],
["lot_id", "!=", false]],
}, {'async': false}).then(function (result) {
var product_lot = [];
if (result.length) {
for (var i = 0; i < result.length; i++) {
product_lot.push({
'lot_name': result.records[i].lot_id[1],
'qty': result.records[i].qty,
});
}
}
done.resolve(product_lot);
});
return done;
},
});
var _orderline_super = models.Orderline.prototype;
models.Orderline = models.Orderline.extend({
compute_lot_lines: function(){
var done = new $.Deferred();
var compute_lot_lines = _orderline_super.compute_lot_lines.apply(this, arguments);
this.pos.get_lot(this.product.id, this.pos.config.stock_location_id[0])
.then(function (product_lot) {
var lot_name = [];
for (var i = 0; i < product_lot.length; i++) {
if (product_lot[i].qty >= compute_lot_lines.order_line.quantity) {
lot_name.push(product_lot[i].lot_name);
}
}
compute_lot_lines.lot_name = lot_name;
done.resolve(compute_lot_lines);
});
return compute_lot_lines;
},
});
});

27
pos_lot_selection/static/src/xml/pos.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
<templates>
<t t-extend="PackLotLinePopupWidget">
<t t-jquery=".title" t-operation="append">
<div class="packlot-select">
<t t-if="widget.options.pack_lot_lines and widget.options.pack_lot_lines.lot_name">
<select class="packlot-line-select">
<option disabled="" selected="" value="">Select a Serial/Lot Number</option>
<t t-foreach="widget.options.pack_lot_lines.lot_name" t-as="lot_name">
<option t-att-value="lot_name">
<t t-esc="lot_name"/>
</option>
</t>
</select>
</t>
</div>
</t>
<t t-jquery="i.remove-lot" t-operation="after">
<i t-attf-class="oe_link_icon lot-clone fa fa-clone #{widget.options.pack_lot_lines.lot_name.length &lt; 1 ? 'oe_hidden' : ''}"></i>
</t>
</t>
</templates>

15
pos_lot_selection/templates/assets.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Tecnativa - David Vidal
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr=".">
<script type="text/javascript" src="/pos_lot_selection/static/src/js/models.js"/>
<script type="text/javascript" src="/pos_lot_selection/static/src/js/chrome.js"/>
<link rel="stylesheet" href="/pos_lot_selection/static/src/css/pos.css" />
</xpath>
</template>
</odoo>
Loading…
Cancel
Save