You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

  1. /*
  2. Copyright 2019 Coop IT Easy SCRLfs
  3. Robin Keunen <robin@coopiteasy.be>
  4. License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. */
  6. odoo.define(
  7. 'pos_require_product_quantity.pos_require_product_quantity',
  8. function (require) {
  9. "use strict";
  10. var core = require('web.core');
  11. var screens = require("point_of_sale.screens");
  12. var _t = core._t;
  13. screens.ActionpadWidget = screens.ActionpadWidget.include({
  14. renderElement: function () {
  15. var self = this;
  16. this._super();
  17. this.$('.pay').click(function () {
  18. if (self.pos.config.require_product_quantity) {
  19. var orderlines = self.pos.get_order().orderlines;
  20. var qty_unset_list = [];
  21. for (var i = 0; i < orderlines.length; i++) {
  22. var line = orderlines.models[i];
  23. if (line.quantity === 0) {
  24. qty_unset_list.push(line);
  25. }
  26. }
  27. if (qty_unset_list.length > 0) {
  28. self.gui.back();
  29. var body = _t('No quantity set for products:');
  30. for (var j = 0; j < qty_unset_list.length; j++) {
  31. body = (
  32. body
  33. + ' - '
  34. + qty_unset_list[j].product.display_name
  35. );
  36. }
  37. self.gui.show_popup(
  38. 'alert',
  39. {
  40. 'title': _t('Missing quantities'),
  41. 'body': body,
  42. },
  43. );
  44. }
  45. }
  46. });
  47. }
  48. })
  49. }
  50. );