How to add products to the sales pannel

From iDempiere en
Jump to navigation Jump to search

How this came about

I just went through this question to make it clearer. On sales panel say you can see five columns: Item, Price, Unit, Taxes, Value. To include a new column, say inventory stock count,paste this code fragment into your resources Ticket.Line.

<column name="label.value" width="80" align="right" value="$

This my brother is an Openbravo Script. It gives the name value to the column we want to create, sets the size to 80, aligns right and the interesting part, it has to call the method printIventoryCount() found in the class To get more info on this, I'll refer you to the Open bravo wiki page .

Phase 2

Now, about that java class aforementioned, the method does not normally exist you have to create it.

1. Browse through your eclipse package explorer

2. Go to src-pos > com.openbravo.pos.form and find

3. Import the following as exlained in this wiki

 import com.openbravo.pos.forms.DataLogicSales; 
 import com.openbravo.pos.ticket.ProductInfoExt; 
 import com.openbravo.pos.ticket.TicketLineInfo;

4.Declare object

 DataLogicSales logic = new DataLogicSales();

Just incase you'd want to know, has the performs the SQL queries through prepares sentences.

5.Create method

  public String printInventoryCount() {
   	String sDBUrl = "jdbc:postgresql://localhost:5432/o";
   	String sDBUser = "leo";
   	String sDBPassword = "leo";
   	Session session = null; 
   	if (sDBUser != null && sDBPassword != null &&
   	sDBPassword.startsWith("crypt:")) {
   	AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser);
   	sDBPassword = cypher.decrypt(sDBPassword.substring(6));
   	try {
   	session = new Session(sDBUrl, sDBUser, sDBPassword);
   	} catch (SQLException ex) {
   	Logger.getLogger(TicketLineInfo.class.getName()).log(Level.SEVERE, null,
   	try {
   	double scnt = logic.findProductStock("0",getProductID(),
   	return Formats.DOUBLE.formatValue(scnt);
   	} catch (BasicException ex) {
   	Logger.getLogger(TicketLineInfo.class.getName()).log(Level.SEVERE, null,
   	return "err..";

Allow me to explain a few things. JDBC is a Java-based data access technology (Java Standard Edition platform) from Oracle Corporation. This technology is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. It's implementation is what you see here


The data I want comes like I said from the class which uses PreparedStatements. The usual practice is to abstract the database logic into an entirely different class and to pass preprocessed strings (perhaps derived themselves from a further abstracted class) containing SQL statements and the connection to the required methods. Abstracting the data model from the application code makes it more likely that changes to the application and data model can be made independently.

6. Resolve imports or insert these ones

 import java.sql.SQLException;
 import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;

7. This last step is pretty ugly, you have to delete your database and create a new one will the appropriate configurations.

I'd look for a way to solve that, God willing. This is alot troublesome especially if you don't have your data centrally stored some where you could pull from and push to. Prochain arrêt. How to activate the POSSync and OrderSync buttons.