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.

56 lines
1.5 KiB

  1. /**
  2. Copyright (C) 2015 - Today: GRAP (http://www.grap.coop)
  3. @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  4. License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. **/
  6. odoo.define('pos_place.gui', function (require) {
  7. "use strict";
  8. var gui = require('point_of_sale.gui');
  9. var core = require('web.core');
  10. var _t = core._t;
  11. gui.Gui.include({
  12. select_place: function () {
  13. var def = new $.Deferred();
  14. var current_place = this.pos.get_place();
  15. var list = [];
  16. for (var i = 0; i < this.pos.places.length; i++) {
  17. var item = this.pos.places[i];
  18. list.push({
  19. 'label': item.code + " - " + item.name,
  20. 'item': item,
  21. });
  22. }
  23. this.show_popup('selection', {
  24. title: _t("Select a Place"),
  25. list: list,
  26. confirm: function (place) {
  27. def.resolve(place);
  28. },
  29. cancel: function () {
  30. def.resolve(null);
  31. },
  32. is_selected: function (place) {
  33. if (current_place) {
  34. return place.id === current_place.id;
  35. }
  36. return false;
  37. },
  38. });
  39. return def.then(function (place) {
  40. return place;
  41. });
  42. },
  43. });
  44. });