Odoo Help

Welcome!

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

0

Sale_margin module work only with a product_id

By
Thomas Fossoul
on 12/23/13, 10:16 AM 1,034 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
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.

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.

0

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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