First of all, we need to set the quantity of document line to be calculated by selecting “1st quantity, variable” from the settings-> Purchases / Sales->Line’s settings-> Additional Units. Calculate.

We set active this function in the document by going to  Settings-> Purchases / Sales-> Documents. We select the document from the special fields and choose “Measurement unit 2”.

Then we need to set the amount of packaging to each item.

Finally, we see that the total quantity is automatically calculated based on the quantity of packaging.