How to extend an osv.osv_memory class?

Asked by Olivier (brain-tec)

We are usign OpenERP Version 6.0.3.

The Problem:
We tried to extend from the class 'stock.move.memory.out' to set the decimal precision on the field "cost". This field appears in the wizard when you accept the delivery.

How to get to this wizard:
- create purchase order and proceed to the end of it
- then open "Receptions" for this purchase order
- open the reception
- in the receptions press "Process"
- now you get a wizard where you can see the field "cost"

Here we would like to have a decimal precision of 4 digits. So we tried to overwrite the class as follow:

class stock_partial_move_memory_in_extended(osv.osv_memory):
    _inherit = 'stock.move.memory.in'
    _columns = {
        'cost' : fields.float("Cost", help="Unit Cost for this product line", digits_compute=dp.get_precision('Purchase Price')),
    }

stock_partial_move_memory_in_extended()

But this does not work, we still have a float with decimal precision of 2.

Could you please fix this bug and tell us what the changes are? How can you overwrite a field in an osv.osv_memory class?
Thanks.

Best regards,
Olivier Jossen

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier (brain-tec)
Solved:
Last query:
Last reply:

This question was originally filed as bug #942647.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) said :
#1

Hello,

It should work just as expected, and from what you describe it seems you're doing the right thing. Perhaps there is something else missing, such as your module not being really loaded as you imagine it is. Did you double-check that it was properly installed and loaded with the correct version of the code?

Anyhow, this does not seem to be a bug, so I'll convert it to a question on Launchpad answers[1]. You could also ask on IRC [2], where other community members may help you debug your module. Providing your whole module would be very useful too in order to test it directly.

By the way, our bug fixing policy requires to report bugs for past stable versions via the OpenERP Enterprise channel rather than Launchpad, unless they are reproducible also on the latest trunk version too. This is explained in [3].
Do not hesitate to double-check this test case on OpenERP 6.1 or on the latest trunk version, it should also work just as expected.

[1] https://answers.launchpad.net/openobject-server
[2] http://www.openerp.com/irc
[3] http://bit.ly/openerp-bug-policy

Revision history for this message
Cristian Salamea (ovnicraft) said :
#2

If you check how this detail for os_memory is created, check the method in do_partial.
That is created dynamically.

Regards,

Revision history for this message
Olivier (brain-tec) (olivier-jossen) said :
#3

Graeme Gellatly (gdgellatly) wrote 22 minutes ago: Re: [Bug 942647] Re: How to extend an osv.osv_memory class? #4

I posted this bug a long long time ago. Honestly thought it was fixed, but
the workaround I used was easy enough. Just use digits(16,5) or whatever
instead of the decimal precision function. If you want to get especially
anal about it, use get precision outside the field definition to return the
precision and set the digits tuple as a constant and use digits=PRECISION
for example. I can confirm that this workaround works absolutely fine.
On Wed, Feb 29, 2012 at 2:51 PM, hbto [Vauxoo] http://www.vauxoo.com <
<email address hidden>> wrote:

This solved my problem!
Thanks

Revision history for this message
Tak Yiu Lai (laigo999) said :
#4

Hi all,

I am new to OpenERP, I tried to increase the decimal precision to the cost as well. Is there any module available ? I have tried copying the Stock Move module and modify like this:

import decimal_precision as dp
from osv import fields, osv

class stock_move(osv.osv_memory):
    _inherit = "stock.move.memory.in"
    _columns = {
        'cost': fields.float('Cost', digits = (16,5), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
    }

stock_move()

It installed OK, but the cost on the wizard still shows 2 decimal only. Any comment ?
Thanks