Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
3376 Tampilan

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
Buang
Jawaban Terbai

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
Buang
Jawaban Terbai

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
Buang
Penulis Jawaban Terbai

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
Buang

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?

Penulis

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.

Post Terkait Replies Tampilan Aktivitas
1
Mei 25
1430
2
Feb 25
10300
4
Jul 18
18682
2
Jan 16
9505
0
Okt 24
4308