unit factor is applied twice in account valuation

Bug #1006494 reported by Javier Guerra
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP R&D Addons Team 2

Bug Description

lets say you have a product:
  - a product with base UoM 'Units'
  - default purchase unit: dozen
  - no UoS defined
  - cost method: 'average'
  - standard cost: 300
  - real time valuation

now, do a purchase of one dozen. the price unit field shows $3,600, quantity: 1

checking the 'stock.move' record:
  - product_qty: 1.00
  - product_uom: dozen
  - product_uos_qty: 1.00
  - product_uos: dozen
  - price_unit: 3600.00 (price of one dozen)

when the movement is processed, the account journal entry amount is $43,200 !!!

looking in the 'stock.move' _get_reference_accounting_values_for_valuation() method, there's this code:

        default_uom = move.product_id.uom_id.id
        qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)

        # if product is set to average price and a specific value was entered in the picking wizard,
        # we use it
        if move.product_id.cost_method == 'average' and move.price_unit:
            reference_amount = qty * move.price_unit
            reference_currency_id = move.price_currency_id.id or reference_currency_id

so, it calculates the quantity by calling _compute_qty(), which transforms the "one dozen" specification into "12 units"; so far so good. but then it multiplies that quantity (12) by the price_unit field which holds 3600.00 (price of one dozen). finally it returns an amount of 43200.00

i think there are two possible fixes:

option A: _get_reference_accounting_values_for_valuation() shouldn't call _compute_qty(), since the movement price_unit is already expressed in the movement unit (dozens in this case)

or

option B: the purchase code should store the base unit price in the stock.move price_unit field.

Option A sounds better, but want to check other people's opinion.

Related branches

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Javier Guerra (a-1avier-n) wrote :

I'm attaching the core of my current fix. in a new module I inherit from stock.move and just override _get_reference_accounting_values_for_valuation() to recalculate the amount in that specific case.

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Saurang Suthar(OpenERP) (ssu-openerp) wrote :

Hello Javier,

We have fixed the problem in lp:~openerp-dev/openobject-addons/trunk-bug-1006494-ssu branch, It will be merged soon in lp:openobject-addons.

Revision No: 6894
Revision ID: <email address hidden>

Thanks
Saurang Suthar

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Saurang Suthar(OpenERP) (ssu-openerp) wrote :

Hello Javier,

Thanks for your contribution ... Sorry I forgot to put an author name on branch.

Thanks
Saurang Suthar

Revision history for this message
Hardik Sanchawat (OpenERP) (hsa-openerp) wrote :

Hello,

Can't reproduce in latest trunk with following revision no:
server (4513)
addons (7880)
web (3324)

Thanks,
- HSA

Revision history for this message
Hardik Sanchawat (OpenERP) (hsa-openerp) wrote :

oops,

i forgot one step then apply that step and reproduce it.

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Hardik,

Kindly inform you that would you please try the following steps which will helps you to produce this bug, but on latest trunk It will give the traceback , So first you have to fix that trace back then you will get the actual bug.

Steps are as follow. (You have to install account_anglo_sexon module)
1. Create one product (product A) Maketo stock > Buy , Set cost method: 'average', cost: 300.
2. Go to Accounting tab, Set real time valuation valuation on inventory valuation field.
3. Product form view default UoM is Unit and Purchase UoM is Dozen.
4. Assign the input stock account and o/p stock a./c
5. Create a PO for same product with 1 qty (Dozen). Confirm it.
6. Done the reception.
At this time you will get the traceback
c['period_id'] = vals['period_id']
KeyError: 'period_id'

First fix this then after you will get the actual bug.

Hope this will help.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.