Browse Source

[12.0][MIG] pos_lot_selection

pull/503/head
KolushovAlexandr 5 years ago
parent
commit
4cb00ab712
No known key found for this signature in database GPG Key ID: C3E04B793421FD2
  1. 82
      pos_lot_selection/README.rst
  2. 0
      pos_lot_selection/__init__.py
  3. 23
      pos_lot_selection/__manifest__.py
  4. 27
      pos_lot_selection/i18n/es.po
  5. 22
      pos_lot_selection/i18n/pos_lot_selection.pot
  6. BIN
      pos_lot_selection/static/description/icon.png
  7. 29
      pos_lot_selection/static/src/css/pos.css
  8. 41
      pos_lot_selection/static/src/js/chrome.js
  9. 56
      pos_lot_selection/static/src/js/models.js
  10. 24
      pos_lot_selection/static/src/xml/pos.xml
  11. 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.
.. 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/12.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)
* Ignacio Ales <ignacio.ales@guadaltech.es>
* Kiril Vangelovski <kiril@lambda-is.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.

0
pos_lot_selection/__init__.py

23
pos_lot_selection/__manifest__.py

@ -0,0 +1,23 @@
# 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': '12.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,
}

27
pos_lot_selection/i18n/es.po

@ -0,0 +1,27 @@
# 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"
"Language: \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
#. 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"
#~ msgid "Quants"
#~ msgstr "Quants"

22
pos_lot_selection/i18n/pos_lot_selection.pot

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_lot_selection
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \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
#. openerp-web
#: code:addons/pos_lot_selection/static/src/xml/pos.xml:12
#, python-format
msgid "Select a Serial/Lot Number"
msgstr ""

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;
}

41
pos_lot_selection/static/src/js/chrome.js

@ -0,0 +1,41 @@
/* Copyright 2018 Tecnativa - David Vidal
Copyright 2019 Lambda IS DOOEL <https://www.lambda-is.com>
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",
};
packlotline.events = _.extend(
packlotline.events, events
);
// Add methods over instanced popup
// Write the value in the corresponding input
packlotline.lot_to_input = function (event) {
var $select = $(event.target);
var $option = this.$("select.packlot-line-select option");
var $input = this.$el.find("input");
if ($input.length) {
$input[0].value = $select[0].value;
$input.blur();
$input.focus();
}
$option.prop('selected', function () {
return this.defaultSelected;
});
};
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 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++) {
if (product_lot[result.records[i].lot_id[1]]) {
product_lot[result.records[i].lot_id[1]] += result.records[i].quantity;
} else {
product_lot[result.records[i].lot_id[1]] = result.records[i].quantity;
}
}
}
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 = Object.keys(product_lot);
for (var i = 0; i < lot_name.length; i++) {
if (product_lot[lot_name[i]] < compute_lot_lines.order_line.quantity) {
lot_name.splice(i, 1);
}
}
compute_lot_lines.lot_name = lot_name;
done.resolve(compute_lot_lines);
});
return compute_lot_lines;
},
});
});

24
pos_lot_selection/static/src/xml/pos.xml

@ -0,0 +1,24 @@
<?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>
</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