Contributing a code patch to webERP


Contributing code to webERP is easy, and is accessible for everyone. All contributions are gratefully accepted, from a one line bug fix, to a new module. This article is intended to show how best to submit this contribution.

Process Summary:
  1. Checkout from subversion
  1. Edit code
  1. Update Change.log.html
  1. Make a diff file
  1. Email to submissions@weberp.org

webERP uses a version control system called subversion to track changes in the code. For the purposes of this article I will be using Ubuntu Linux, and the instructions I will give will use the command line.

There are GUI tools available for both windows and Linux which are able to do any of these tasks as well. In order to follow this article you will have to have one of these GUI tools or the subversion package downloaded.

There is a bug in the current svn version of GLJournal.php (revision 3233 http://web-erp.svn.sourceforge.net/viewvc/web-erp/trunk/GLJournal.php?revision=3233) which prevents the footer being shown once the journal has been processed. Let us see how we can fix this problem.

First we need to get a working copy of the code from svn. Create a folder on your file system where you want to keep your working copy of the code. On my system the commands are as follows:
tim@aglovale:~$ mkdir temp


For this article we will be using the main trunk of webERP code as our base, so to checkout this code into the temp folder we just created we need the following command:

tim@aglovale:~$ svn co https://web-erp.svn.sourceforge.net/svnroot/web-erp/trunk temp


Now if we enter that folder we can see we have all the code from the development branch of webERP. Now choose your favourite text editor and edit GLJournal.php. Lines 121 to 125 read as follows:
    /*Set up a newy in case user wishes to enter another */
    echo "<br><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . "&NewJournal=Yes'>"._('Enter Another General Ledger Journal').'</a>';
    /*And post the journal too */
    include ('includes/GLPostings.inc');
    exit;

We can see that the journal is posted, and then the script is immediately exited without showing the footer. To correct this we need to insert the line:
    include ('includes/footer.inc');

between the GLPostings.inc include and the exit statement. Now we just need to test our code in the browser, and the footer should now appear correctly at the end of the journal.

We now need to make an entry for our change in the change log. In your text editor open the file doc/Change.log.html. Insert a new line at line 3, and filling the details of your code. Date, your name, file changed, and a description of the change. So in our case the line looks like:
<p>15/04/10 Tim: GLJournal.php - Fix to show the footer on completion of the journal.</p>

Having fixed the problem we now need to submit our change. First we should update our code to the latest svn in case something has changed from when we initially checked out our code. To do this we use the following command:
tim@aglovale:~/temp$ svn update

Fetching external item into 'xmlrpc'
External at revision 73.

At revision 3418.
tim@aglovale:~/temp$

Any file changes since your checkout will be shown here, and your code updated. SVN provides a method to show the differences between the code in your working copy and the code in the svn repository. To get this use the command:
tim@aglovale:~/temp$ svn diff
Index: doc/Change.log.html
===================================================================
--- doc/Change.log.html (revision 3418)
+++ doc/Change.log.html (working copy)
@@ -1,5 +1,6 @@
 <p><font SIZE=4 COLOR=BLUE><b>webERP Change Log</b></font></p>
 <p></p>
+<p>15/04/10 Tim: GLJournal.php - Fix to show the footer on completion of the journal.</p>
 <p>15/04/10 Tim: SystemParameters.php - Add in picking note parameter</p>
 <p>14/04/10 Tim: SelectOrdderitems.php and DeliveryDetails.php - Improvements to layout and design of sales order entry</p>
 <p>08/04/10 Tim: SuppTransGLAnalysis.php - Correct typo in sql statement.</p>
Index: GLJournal.php
===================================================================
--- GLJournal.php       (revision 3418)
+++ GLJournal.php       (working copy)
@@ -122,6 +122,7 @@
        echo "<br><a href='" . $_SERVER['PHP_SELF'] . '?' . SID . "&NewJournal=Yes'>"._('Enter Another General Ledger Journal').'</a>';
        /*And post the journal too */
        include ('includes/GLPostings.inc');
+       include ('includes/footer.inc');
        exit;
 
 } elseif (isset($_GET['Delete'])){
@@ -421,4 +422,4 @@
 
 echo '</form>';
 include('includes/footer.inc');
-?>
\ No newline at end of file
+?>


As you can see the output gives the two differences that we have created. However we need to send this output to the developers, so we need to re-direct the output to a file as follows:
tim@aglovale:~/temp$ svn diff > GLJournal.php.diff

This will create a file called GLJournal.php.diff. Substitute GLJournal.php for something more appropriate for your change.

Now just send the file via email to submissions@weberp.org. This will be dealt with by one of the administrators. You will always hear back even if your code is not accepted, so if you hear nothing within a week then resubmit the change as it may have got lost along the way.

That is it, you have now contributed to webERP.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki