Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
3377 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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 ??

Awatar
Odrzuć

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?

Autor

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.

Powiązane posty Odpowiedzi Widoki Czynność
1
maj 25
1431
2
lut 25
10301
4
lip 18
18682
2
sty 16
9506
0
paź 24
4309