Thursday 11 November 2021

Increase Swap size of server

 

  1. First disable the swap and delete it

     sudo swapoff /swapfile  
     sudo rm  /swapfile
    
  2. Create new swap space of size 16 GB (16 * 1024 = 16384). bs is the block size. Basically bs * count = bytes to be allocated (in this case 16 GB). Here bs = 1M (M stands for mega, so we are assigning 1MB block size) and we are allocating 16384 * 1MB (=16GB) to swap.

     sudo dd if=/dev/zero of=/swapfile bs=1M count=16384
    
  3. Give it the read/write permission for root

     sudo chmod 600 /swapfile
    
  4. Format it to swap

     sudo mkswap /swapfile
    
  5. Turn on swap again

     sudo swapon /swapfile
    
  6. Now reboot the PC for the above changes to take place.

Thursday 21 October 2021

ERPNext13 installation in Ubuntu 20

 On a clean fresh server on “root” login make sure to add a user for the ERPNext install…

(Obviously replace [USER] with your username everywhere in this posting)

adduser frappe
usermod -aG sudo frappe

Then while still logged in as root, update the system to the latest packages…

apt-get update
apt-get upgrade

Now, logout as the root user and login with the new user you just created. Perform the following steps:

export LC_ALL=C.UTF-8

sudo apt install git libffi-dev python3-minimal build-essential python3-distutils python3-setuptools python3-pip python3-testresources libssl-dev wkhtmltopdf redis

Nest we need to fix a potential problem in the redis config file:

sudo vi /etc/redis/redis.conf

When the editor is open, search for: bind 127.0.0.1 ::1 and edit our the 2 colons and the 1 so it looks like bind 127.0.0.1 then save the file.

wget https://raw.githubusercontent.com/frappe/bench/develop/install.py

sudo python3 install.py --verbose --production --user [USER] --mariadb-version 10.5 --frappe-branch version-13 --erpnext-branch version-13


Tuesday 19 October 2021

Sales Invoice Custom report

<table>
<tr>
<td style="width: 20%;">
&nbsp;<br>
</td>
<td style="width: 35%;">
<br><small>{{doc.branch_address}}</small>
</td>
<td style="width: 45%;">
GSTIN: {{ doc.gstin }}<br>
(Under Composition Scheme)<br>
<h2>Invoice: {{ doc.name }}<br><small>Date: {{ doc.get_formatted("posting_date") }}</small></h2>
</td>
</tr>
</table>
<hr>
<table style="width: 100%;">
<tr>
<td >
<strong>Customer Name: {{doc.customer_name}}</strong>
</td>
<td>
&nbsp;
</td>
</tr>
</table>
<table style="width: 100%;" border="1">
<tr>
<td width: 10%; text-align: left;"><strong>S.No.</strong></td>
<td width: 15%; text-align: left;"><strong>Item Code</strong></td>
<td width: 40%; text-align: center;"><strong>Item Name</strong></td>
<td width: 10%; text-align: center;"><strong>Quantity</strong></td>
<td width: 25%; text-align: center;"><strong>Amount</strong></td>
</tr>
{%- for row in doc.items -%}
<tr>
<td> {{ row.idx }}</td>
<td> {{ row.item_code }}</td>
<td class='alnleft';"> {{ row.item_name }}</td>
<td class='alnright';">{{ row.qty }}</td>
<td class='alnright';">{{row.get_formatted("amount", doc) }}</td>
</tr>
{%- endfor -%}
</table>
<table style="width: 100%;" border="0">
<tr>
<td style="width: 75%;" class='alnright';>
<strong>
Total Amount:<br>
Discount Amount:<br>
Net Total:
</strong>
</td>
<td style="width: 25%;" class='alnright';>
<strong>
{{ "₹ {:,.2f}".format(doc.total) }}<br>
{{ "₹ {:,.2f}".format(doc.discount_amount) }}<br>
{{ "₹ {:,.2f}".format(doc.grand_total) }}
</strong>
</td>
</tr>
</table>

Set current form field through client script

 frappe.ui.form.on("Journal Entry", {

            after_save: function(frm) {

            frm.doc.title = frm.doc.name;

            }

            });

Client Script Events

 

Event NameDescription
setupTriggered once when the form is created for the first time
before_loadTriggered before the form is about to load
onloadTriggered when the form is loaded and is about to render
refreshTriggered when the form is loaded and rendered.
onload_post_renderTriggered after the form is loaded and rendered
validateTriggered before before_save
before_saveTriggered before save is called
after_saveTriggered after form is saved
before_submitTriggered before submit is called
on_submitTriggered after form is submitted
before_cancelTriggered before cancel is called
after_cancelTriggered after form is cancelled
timeline_refreshTriggered after form timeline is rendered
{fieldname}_on_form_renderedTriggered when a row is opened as a form in a Table field
{fieldname}Triggered when the value of fieldname is changed

Monday 26 April 2021

Managing Github repository for custom app

Creating Github repository

echo "# custext" >> README.md

git init

git add README.md

git commit -m "first commit"

git branch -M main

git remote add origin https://github.com/valignit/custext.git

git push -u origin main


Updating Github repository

git status

git add .

git commit -m "v-x.y"

git push


Sunday 11 April 2021

Allowing non root users to login through putty

 vi /etc/ssh/sshd_config append last line AllowUsers erpuser

service sshd restart

mkdir /home/erpuser/.ssh

cp ~/.ssh/authorized_keys /home/erpuser/.ssh/authorized_keys

chown erpuser /home/erpuser/.ssh/authorized_keys

su erpuser

chmod 600 /home/erpuser/.ssh/authorized_keys

exit

service sshd restart

Wednesday 31 March 2021

How to setup vncserver in

SERVER SIDE
===========
apt update
apt install xfce4 xfce4-goodies tightvncserver
apt install xfonts-base x11-xserver-utils

# Prompts to set up password for VNC server here...
vncserver

# Allow clients to connect to X server from any host
export DISPLAY=:1
xhost +
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

# Creating proper config and restarting the server
cat << EOF > ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
EOF

# Creating a user account
chmod +x ~/.vnc/xstartup
export USERNAME="vncuser"
useradd --create-home $USERNAME
adduser $USERNAME sudo
passwd $USERNAME

# Copy ssh keys to new user
mkdir -p /home/$USERNAME/.ssh
cp ~/.ssh/authorized_keys /home/$USERNAME/.ssh/
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh

# Copy VNC settings to a new user
mkdir -p /home/$USERNAME/.vnc
cp ~/.vnc/xstartup /home/$USERNAME/.vnc/
chown -R $USERNAME:$USERNAME /home/$USERNAME/.vnc/
touch ~/.Xauthority Log


# Stop command. Just in case. Ignore errors here
su $USERNAME -c "vncserver -kill :1"

# Start VNC server
su $USERNAME -c "vncserver -depth 24 -geometry 1280x800"
su vncuser -c vncserver

CLIENT SIDE
===========
Download and install tightvnc viewer
https://www.tightvnc.com/download.php
Ensure vncserver is started in server side
Launch tightc vncviewer
specify ipaddress as server-ip-address:port 
(eample:143.198.113.69:5901)
Password will be accepted

VNC TERMINAL will be launched