Odoo Help

0

Sale_margin module work only with a product_id

By
Thomas Fossoul
on 12/23/13, 10:16 AM 1,268 views

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

0
Ray Carnes
On 12/25/13, 7:50 PM

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.

0
Thomas Fossoul
On 12/26/13, 3:26 AM

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

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?

Bista Solutions US, Ray Carnes
on 12/26/13, 5:46 PM

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

Thomas Fossoul
on 12/27/13, 3:44 AM

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.

Nadie, Diogenes Ojeda
on 5/5/14, 12:00 AM
0
Diogenes Ojeda
On 5/4/14, 11:58 PM

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.

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.

Register

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)

Stats

Asked: 12/23/13, 10:16 AM
Seen: 1268 times
Last updated: 3/16/15, 8:10 AM