[imp] improvements related to pos
bzr revid: nicolas.vanhoren@openerp.com-20111108162153-1dmhodcgu1emlxs0
This commit is contained in:
@@ -421,11 +421,11 @@ openerp.point_of_sale = function(db) {
|
||||
Shop.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Shop.prototype.defaults = {
|
||||
orders: new OrderCollection,
|
||||
products: new ProductCollection
|
||||
};
|
||||
Shop.prototype.initialize = function() {
|
||||
this.set({
|
||||
orders: new OrderCollection(),
|
||||
products: new ProductCollection()
|
||||
});
|
||||
this.set({
|
||||
cashRegisters: new CashRegisterCollection(pos.store.get('account.bank.statement')),
|
||||
});
|
||||
@@ -751,6 +751,10 @@ openerp.point_of_sale = function(db) {
|
||||
function CategoryView() {
|
||||
CategoryView.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
CategoryView.prototype.events = {
|
||||
'click .oe-pos-categories-list a': 'changeCategory'
|
||||
};
|
||||
|
||||
CategoryView.prototype.template = qweb_template('pos-category-template');
|
||||
CategoryView.prototype.render = function(ancestors, children) {
|
||||
@@ -776,6 +780,10 @@ openerp.point_of_sale = function(db) {
|
||||
})()
|
||||
}));
|
||||
};
|
||||
CategoryView.prototype.changeCategory = function(a) {
|
||||
var id = $(a.target).data("category-id");
|
||||
this.trigger("changeCategory", id);
|
||||
};
|
||||
return CategoryView;
|
||||
})();
|
||||
ProductView = (function() {
|
||||
@@ -1131,22 +1139,20 @@ openerp.point_of_sale = function(db) {
|
||||
return ShopView;
|
||||
})();
|
||||
App = (function() {
|
||||
__extends(App, Backbone.Router);
|
||||
function App() {
|
||||
App.__super__.constructor.apply(this, arguments);
|
||||
function App($element) {
|
||||
this.initialize($element);
|
||||
}
|
||||
|
||||
App.prototype.routes = {
|
||||
'': 'category',
|
||||
'category/:id': 'category'
|
||||
};
|
||||
App.prototype.initialize = function($element) {
|
||||
this.shop = new Shop;
|
||||
this.shopView = new ShopView({
|
||||
shop: this.shop,
|
||||
el: $element
|
||||
});
|
||||
return this.categoryView = new CategoryView;
|
||||
this.categoryView = new CategoryView;
|
||||
this.categoryView.bind("changeCategory", this.category, this);
|
||||
this.category();
|
||||
return this.categoryView;
|
||||
};
|
||||
App.prototype.category = function(id) {
|
||||
var c, products;
|
||||
@@ -1155,6 +1161,7 @@ openerp.point_of_sale = function(db) {
|
||||
}
|
||||
c = pos.categories[id];
|
||||
$('#products-screen').html(this.categoryView.render(c.ancestors, c.children));
|
||||
this.categoryView.delegateEvents();
|
||||
products = pos.store.get('product.product').filter( function(p) {
|
||||
var _ref;
|
||||
return _ref = p.pos_categ_id[0], __indexOf.call(c.subtree, _ref) >= 0;
|
||||
@@ -1188,14 +1195,13 @@ openerp.point_of_sale = function(db) {
|
||||
db.point_of_sale.PointOfSale = db.web.Widget.extend({
|
||||
template: "PointOfSale",
|
||||
start: function() {
|
||||
// FIXME: absolutely horrible hack to avoid conflict
|
||||
// between backbone's history and al's action
|
||||
// thingie
|
||||
window.location.hash = '';
|
||||
var self = this;
|
||||
this.$element.find("#loggedas button").click(function() {
|
||||
self.stop();
|
||||
});
|
||||
|
||||
if (pos)
|
||||
throw "It is not possible to instantiate multiple instances"+
|
||||
throw "It is not possible to instantiate multiple instances "+
|
||||
"of the point of sale at the same time.";
|
||||
pos = new Pos(this.session);
|
||||
|
||||
@@ -1203,7 +1209,6 @@ openerp.point_of_sale = function(db) {
|
||||
|
||||
return pos.ready.then( function() {
|
||||
pos.app = new App(self.$element);
|
||||
return Backbone.history.start();
|
||||
});
|
||||
},
|
||||
stop: function() {
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<ol id="orders"></ol>
|
||||
</div>
|
||||
</div>
|
||||
<div id="loggedas">
|
||||
<button>Back</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
|
||||
@@ -140,15 +143,15 @@
|
||||
<t t-name="pos-category-template">
|
||||
<header>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a href="#">
|
||||
<li class="oe-pos-categories-list">
|
||||
<a href="javascript:void(0)">
|
||||
<img src="/point_of_sale/static/src/img/home.png" class="homeimg" />
|
||||
</a>
|
||||
</li>
|
||||
<t t-foreach="breadcrumb" t-as="category">
|
||||
<li>
|
||||
<li class="oe-pos-categories-list">
|
||||
<img src="/point_of_sale/static/src/img/bc-arrow.png" class="bc-arrow" />
|
||||
<a t-att-href="'#category/' + category.id">
|
||||
<a href="javascript:void(0)" t-att-data-category-id="category.id">
|
||||
<t t-esc="category.name"/>
|
||||
</a>
|
||||
</li>
|
||||
@@ -163,8 +166,8 @@
|
||||
<h4>Categories:</h4>
|
||||
<ol>
|
||||
<t t-foreach="categories" t-as="category">
|
||||
<li>
|
||||
<a t-att-href="'#category/' + category.id" class="button">
|
||||
<li class="oe-pos-categories-list">
|
||||
<a href="javascript:void(0)" t-att-data-category-id="category.id" class="button">
|
||||
<t t-esc="category.name"/>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user