View source | Discuss this page | Page history | Printable version   

Retail:Developers Guide/Backbone Models and Collections

Contents

Introduction

Openbravo Web POS uses Backbone.Model and Backbone.Collection to work with data. This article provides an overview of the models and collections.

Models

By convention Openbravo Web POS provides the models as part of OB.Model object:

Collections

The available collections are part of the OB.Collection:

Bulbgraph.png   Note: By convention the collection name must be the ModelName plus List suffix

Examples

Code snippets that uses OB.Dal and one of the listed model/collection

Search for pending orders:

OB.Dal.find(OB.Model.Order, {
  hasbeenpaid: 'N'
}, function(pendingOrderList, me) {
  // success
}, function(tx, error) {
  // error
}, this);

Searching business partners:

/* rest of the code */
var criteria = {};
if (filter && filter !== '') { // filter is a parameter of the function
  criteria._identifier = {
    operator: OB.Dal.CONTAINS,
    value: filter
  };
}
 
OB.Dal.find(OB.Model.BusinessPartner, criteria, successCallbackBPs, errorCallback); // success and error callbacks are previously defined

Back to Concepts

Retrieved from "http://wiki.openbravo.com/wiki/Retail:Developers_Guide/Backbone_Models_and_Collections"

This page has been accessed 5,340 times. This page was last modified on 19 July 2013, at 10:35. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.