Odoo Help


Unit of Measure for purchase

on 5/11/14, 4:09 AM 2,249 views

I am having a simple with Unit Of Measure. I purchase Product A in dozen(s). In my system m using the default unit of measure That's dozen. So when i makes any purchase in dozen it should display 12 Unit(s) but in my case its showing 13 units. So can anyone tell how one more unit added from? Below is my unit of measures conversation. Unit of Measure: Dozen(s) Category: Unit(s) Ratio: 12.000000000048 Type:Bigger Than the Reference Unit of measures Rounding Precision: 1.00 I think you all overcome with this issue so please guide me through all the required steps. Thank you


Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 5/11/14, 8:32 AM


This method actually did the trick:

def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context=None):
    if context is None:
        context = {}
    if from_unit.category_id.id <> to_unit.category_id.id:
        if context.get('raise-exception', True):
            raise osv.except_osv(_('Error!'), _('Conversion from Product UoM %s to Default UoM %s is not possible as they both belong to different Category!.') % (from_unit.name,to_unit.name,))
            return qty
    amount = qty / from_unit.factor
    if to_unit:
        amount = ceiling(amount * to_unit.factor, to_unit.rounding)
    return amount

in your case the from_unit is Dozen and to_unit is Unit, So the from_unit.factor is actually 1.0/ [the value that you entered in the Ratio of the Dozen form which it is 12 So 1.0 / 12 = 0.08333333333333333 and it will be 0.083333333333 since the precision of this field is 12.

Then amount = qty/ 0.083333333333 in your case qty is 1.0 so 1.0 / 0.083333333333 = 12.000000000048 and this is the value that appears to you when in the Ration field which it is actually something like round(1.0 / (round(1.0 / your entered value,12)),12)

after that the method ceiling invoked which it is :

def ceiling(f, r):
if not r:
    return f
return math.ceil(f / r) * r

in your case to_unit.factor is 1 and to_unit.rounding is 1, So you are actually ceiling 12.000000000048 which it is 13.

So if you want to get the correct mount you've to make the field Ratio less than 12, So you can enter 11.999 and you'll get 11.998999999932 after pressing save button, Then check your product

I hope this will work for you


Ya its working. But am getting one new problem after that. I made a purchase order of Product A. Purchase Unit of Measure is Dozen as i told you earlier 1 Dozen =12 units. So i made the costing price 100INR. When am making a purchase order its total units price should me 1200 but its showing me 11.999 something like that. I know by adjusting unit of measures i can solve this problem but am not expert. So am again leaving this problem to you all guys please tell me the required steps. thank you .

on 5/11/14, 11:44 AM

Hi, try 11.999999 this will work ! :) I'm not sure is this the proper solution or there is another one !

Ahmed M.Elmubarak
on 5/11/14, 1:11 PM

ya man its working. Thank a lot. So if you don't mind then could you please give the mathematical method for this conversation? If you can then please provide.

on 5/11/14, 1:28 PM

Actually it acts as normal but you got 1200 because the precision of the product price is 2 digits , if the precision is 12 digits you'll get 1199.999899996808 .

Ahmed M.Elmubarak
on 5/11/14, 1:59 PM

Thank you man it solved my problem after all.

on 5/11/14, 2:38 PM

Can you please help on one more problem. I digging OpenERP7 its really very powerful software Hats-of-genius. Those who have developed the idea of such kind of software they really genius.

on 5/12/14, 9:14 AM

I did almost every thing for retailing market i openerp. I studied all the books that are available and there are lots left. So now i didn't find a solution for sales report of the day or in a particular date. Let me explain you properly my case first

I'm having a wine shop so I want to implement this software. I have entered all the product and dispatched properly. My accounting part is also working fine. So, I want the sales report at the end of the day. I'm getting stock report everything but no where i found the sales report.

on 5/12/14, 9:22 AM

Hi, since reports differ from one company to another OpenERP has just the standard reports. So for many cases you've to make your own reports. there are several techniques for creating reports. But I think it is better to make a new question to describe your problem, to better help the value of the community. Also if this answer solved your previous problem it is better to mark it as correct to help other find the answers... Regards

Ahmed M.Elmubarak
on 5/12/14, 10:32 AM

I need just some simple reports. which are listed below one by one 1.Sales of the day (Means how much sales i made today) 2. Total money collected on a day. 3. Stock in hand. this much reports only i need basically.

Thank you for all your quick response. Thank you all team those who have developed such beautiful product.

on 5/12/14, 11:34 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/11/14, 4:09 AM
Seen: 2249 times
Last updated: 3/16/15, 8:10 AM