İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
3379 Görünümler

Hi,

I would like to know if this is normal that the sale_margin module works only when you set a product_id on the line you add on your sale order.

def _product_margin(self, cr, uid, ids, field_name, arg, context=None): res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = 0

        if line.product_id:
            if line.purchase_price:
                res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.purchase_price*line.product_uos_qty), 2)
            else:
                res[line.id] = round((line.price_unit*line.product_uos_qty*(100.0-line.discount)/100.0) -(line.product_id.standard_price*line.product_uos_qty), 2)
    return res

Regards,

Tom

Avatar
Vazgeç
En İyi Yanıt

Yes.

If you don't enter a product (to get a product_id) then OpenERP only knows your SALES PRICE, not your COST PRICE, so cannot calculate a margin.

Avatar
Vazgeç
En İyi Yanıt

Hello everyone:

I want to calculate the margin of product sales by day, month, etc.. I installed these modules:

Margins by Products Margins in Sales Orders Historical Product Margin

But none of them seem to work, Reports, give no report everything is zero.

I could tell if these modules do not work or have to do something in the list of products and their prices so they can perform operations?

Thank you. This has me desperate.

Avatar
Vazgeç
Üretici En İyi Yanıt

Oh come on..

Just install the module and add a line on a SO, you will see you can define manually the cost price for that line OR select a product which auto complete the cost_price field on the window.

So my question was about this line on the code :

if line.product_id:

Before reading the code i was thinking its a bug but when you see this line i think this was intended.... but for what reason ??

Avatar
Vazgeç

The Cost Price is NOT cost_price, it is purchase_price. Look at the code. What else does it need and where would it get that information from if there was no product defined?

Üretici

Mmm you've got the point. The fact is i have a need where the user don't use the product.product table because he sell almost always different product between its project. So use it should be a waste of time. That's why in this way i wanted a cost price calculated even if you set it manually on each line..

Hello everyone:

I want to calculate the margin of product sales by day, month, etc.. I installed these modules:

Margins by Products Margins in Sales Orders Historical Product Margin

But none of them seem to work, Reports, give no report everything is zero.

I could tell if these modules do not work or have to do something in the list of products and their prices so they can perform operations?

Thank you. This has me desperate.

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
May 25
1439
2
Şub 25
10308
4
Tem 18
18684
2
Oca 16
9507
0
Eki 24
4310