Browse Source

[IMP] pos_lot_selection: clone control no longer needed

With PR https://github.com/odoo/odoo/pull/23698 merged, clone control is
no longer needed for lots.

[FIX] pos_lot_selection: group lots by quants

fixup! [FIX] pos_lot_selection: group lots by quants

fixup! fixup! [FIX] pos_lot_selection: group lots by quants
pull/285/head
David 7 years ago
committed by Nacho Alés López
parent
commit
d468af0655
  1. 2
      pos_lot_selection/README.rst
  2. 28
      pos_lot_selection/static/src/js/chrome.js
  3. 11
      pos_lot_selection/static/src/js/models.js
  4. 3
      pos_lot_selection/static/src/xml/pos.xml

2
pos_lot_selection/README.rst

@ -29,8 +29,6 @@ Usage
* 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

28
pos_lot_selection/static/src/js/chrome.js

@ -13,7 +13,6 @@ odoo.define("pos_lot_selection.chrome", function (require) {
// 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
@ -21,39 +20,18 @@ odoo.define("pos_lot_selection.chrome", function (require) {
// 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 $select = $(event.target);
var $option = this.$("select.packlot-line-select option");
var $input = this.$el.find("input[cid='" + this.active_cid + "']");
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;
});
};
// 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;
},

11
pos_lot_selection/static/src/js/models.js

@ -17,13 +17,14 @@ odoo.define("pos_lot_selection.models", function (require) {
["product_id", "=", product],
["lot_id", "!=", false]]
}, {'async': false}).then(function (result) {
var product_lot = [];
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],
'quantity': result.records[i].quantity,
});
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);

3
pos_lot_selection/static/src/xml/pos.xml

@ -19,9 +19,6 @@
</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>
Loading…
Cancel
Save