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.

51 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.models', function (require) {
  7. "use strict";
  8. var models = require('point_of_sale.models');
  9. var _super_order = models.Order.prototype;
  10. // Load pos.place model
  11. models.load_models({
  12. model: 'pos.place',
  13. loaded: function (self, places) {
  14. self.places = [];
  15. for (var i = 0; i < places.length; i++) {
  16. self.places.push(places[i]);
  17. }
  18. },
  19. });
  20. // Make place persistent in the session
  21. models.PosModel = models.PosModel.extend({
  22. get_place: function () {
  23. return this.get('current_place') ||
  24. this.db.load('current_place');
  25. },
  26. set_place: function (place) {
  27. this.set('current_place', place);
  28. this.db.save('current_place', place || null);
  29. },
  30. });
  31. models.Order = models.Order.extend({
  32. export_for_printing: function () {
  33. var res = _super_order.export_for_printing.apply(this, arguments);
  34. res.place = this.pos.get_place();
  35. return res;
  36. },
  37. export_as_JSON: function () {
  38. var json = _super_order.export_as_JSON.apply(this, arguments);
  39. var place = this.pos.get_place();
  40. json.place_id = place ? place.id : false;
  41. return json;
  42. },
  43. });
  44. });