How can I remove the round function of price_unit in purchase_order_line?
Whenever I create a Purchase order and my price_unit = 0.21429 and my qty = 20000 (for example), I should have the amount of 4285.8 but because price_unit in rounded off, my new price_unit will become 0.21 and I will have an amount of 4200.00. So if you will notice i will have a 85.8 difference of to amount.
How can I remove the round function in price_unit in purchase_order_line so that i will have a more accurate result in my purchase order?
BTW, I am using v5.0.3
Thank you,
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Jay Vora (Serpent Consulting Services)
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello,
Following steps you need to follow :
1. Start the server with option :=> --price_accuracy=5
2. Create new database.
3. In the new database you will not faced the above mention problem.
Thanks.
Revision history for this message
|
#2 |
yes I already did that, but my problem is whenever i click on the compute button in purchase order my price_unit then rounded to 2 decimal places.
Revision history for this message
|
#3 |
Hello,
can you apply the following patch and notify me :
=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py 2009-11-09 07:25:32 +0000
+++ bin/osv/orm.py 2009-11-12 10:25:37 +0000
@@ -1854,14 +1854,19 @@
+ if f.digits:
+ field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1]
+ if field_size != f_pg_size:
+ logger.
+
- ok = True
- cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
- cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
- cr.execute(('UPDATE "%s" SET "%s"=temp_
- cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
- cr.commit()
+ ok = True
+ cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
+ cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
+ cr.execute(('UPDATE "%s" SET "%s"=temp_
+ cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
+ cr.commit()
Revision history for this message
|
#4 |
Nothing happens when I apply this patch. But it's weird coz when I create a database with demo data, It works right, the price_unit of purchase order doesn't round off to 2 decimal places. but when I use my own database. its not working? whats the problem?
Revision history for this message
|
#5 |
Hello,
Did you update your database completely after applying the patch?
Because as i know when you was created your existing database at that time database side the accuracy is 2 digits only and after that if change the price accuracy you need to update your complete database by using following command :
./tinyerp-server.py -u all -d <dbname>.
Hope this will help you.
Thanks.
Revision history for this message
|
#6 |
Yes I already did that.
I just noticed from the patch you've given me, from this lines below they are the same, I have to remove those who have (-) sign and replace it with (+) sign if I'm not mistaken but they are the same.
- ok = True
- cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
- cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
- cr.execute(('UPDATE "%s" SET "%s"=temp_
- cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
- cr.commit()
+ ok = True
+ cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
+ cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
+ cr.execute(('UPDATE "%s" SET "%s"=temp_
+ cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
+ cr.commit()
Revision history for this message
|
#7 |
Hello,
Please update the latest revision of server with the following revision:
Now on revision 1871.
Thanks.
Revision history for this message
|
#8 |
still doesn't work..
I try to drop the tables purchase_order and purchase_order_line and then update all the module then it works. but my all my purchase_order will be deleted. I try to use the export function so that I can easily import my purchase orders once I'm done with the upgrade but it is so complicated. some of the fields I exported are not read when I import the *.csv file.
Do you have anything in mind that would help me with this one.
Thanks,
Revision history for this message
|
#9 |
Hello Joel,
Make sure you are running under the latest code from Launchpad.
The change in the size of the field can be achieved when you update your module.
If you want to increase the price_accuracy value, run your server with the price_accuracy parameter with updation of the DB.
You neither need to create a new DB nor delete the tables.
Check in the database that the field size has been modified or not.
Thank you.
Revision history for this message
|
#10 |
Thanks Jay (Open ERP), that solved my question.
Revision history for this message
|
#11 |
Hello,
Please can someone send me the new patched file "orm.py"
Thanks
Revision history for this message
|
#12 |
Hello,
You the above related patch is already committed in stable server with following path:
https:/
So Can you tell me that which patch you did talking about above?
Thanks.
Revision history for this message
|
#13 |
Hello,
Thanks for your interest,
But i have the problem of whenever i click on the compute button in purchase order my price_unit then rounded to 2 decimal places. Well i try to make the patch as described here but i see that my openerp-server.py wil not be launched and i get a lot of warning.
What i can do tp resolve this problems.
Thanks a lot
Revision history for this message
|
#14 |
Hello,
You need to update you database by following way:(IN Ubuntu.)
./tinyerp-server.py -u all -d <dbname>.
and If you want to increase the price_accuracy value, run your server with the price_accuracy parameter with updation of the DB.
Thanks.
Revision history for this message
|
#15 |
hello,
i have used this command but i have this :
districap@
Traceback (most recent call last):
File "./openerp-
import netsvc
File "/usr/lib/
import tools
File "/usr/lib/
from convert import *
File "/usr/lib/
import osv
File "/usr/lib/
import osv
File "/usr/lib/
import orm
File "/usr/lib/
field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1]
IndentationError: unindent does not match any outer indentation level
districap@
The patch that i have done on orm.py are
Old code: on line 1770 to 1781
for c in casts:
The new code :
for c in casts:
field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1]
if field_size != f_pg_size:
logger.
I am sincerely sorry if I took too much of your time.
Revision history for this message
|
#16 |
mohamed wrote:
> Question #89821 on OpenObject Addons changed:
> https:/
>
> mohamed posted a new comment:
> hello,
> i have used this command but i have this :
> districap@
> Traceback (most recent call last):
> File "./openerp-
> import netsvc
> File "/usr/lib/
> import tools
> File "/usr/lib/
> from convert import *
> File "/usr/lib/
> import osv
> File "/usr/lib/
> import osv
> File "/usr/lib/
> import orm
> File "/usr/lib/
> field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1]
> ^
> IndentationError: unindent does not match any outer indentation level
> districap@
>
>
> The patch that i have done on orm.py are
>
> Old code: on line 1770 to 1781
> for c in casts:
> if (f_pg_type==c[0]) and (f._type==c[1]):
> logger.
> ok = True
> cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
> cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
> cr.execute(('UPDATE "%s" SET "%s"=temp_
> cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
> cr.commit()
>
> if f_pg_type != f_obj_type:
> if not ok:
>
> The new code :
>
> for c in casts:
> if (f_pg_type==c[0]) and (f._type==c[1]):
> if f.digits:
> field_size = (65535 * f.digits[0]) + f.digits[0] + f.digits[1]
> if field_size != f_pg_size:
> logger.
>
> if f_pg_type != f_obj_type:
> logger.
> ok = True
> cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
> cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
> cr.execute(('UPDATE "%s" SET "%s"=temp_
> cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
> cr.commit()
> break
> if f_pg_type != f_obj_type:
>
>
>
> I am sincerely sorry if I took too much of your time.
>
>
Hello,
Please check the attached file of stable server and compare with your
orm.py file.
Thanks.
Revision history for this message
|
#17 |
Hello,
Please compare the orm.py file which i mailed you.
Notify me when you will receive.
Thanks.
Revision history for this message
|
#18 |
hello,
I m sorry for the delay my connection was down all this time now it work again now i have opned my email but i havn't seen the attached file if you can email it again
thanks
Revision history for this message
|
#19 |
Hello,
Please check the attached file, as you told me so i am sending you again.
Thanks.
Revision history for this message
|
#20 |
Hello,
Thanks i have seen the attached file and i i have correct my file and i have done the commandes:
1) openerp-server -u all -d districap_DB
2) openerp-server -r districap -w districap --price_accuracy 6
then the price unit is now rounded to 6
But in the supplier invoice and in the client invoice the system before calculating price= unit_price*quantity he makes the round(unit_price,2) and after calculating the price= unit_price*quantity he make the round(price, 2).
Have you any idea about that and if possible how to fix that?
Tnahks