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

Minimum Lot Charge For Sales Order Line Items

v7
By
Alex Gallien
on 1/5/15, 6:14 PM 1,258 views

I am setting up a system for a manufacturing company that has a minimum charge for any job, and am trying to program that in to OpenERP. For example, if the minimum charge for processing Part A is $150, and they are $10 each, an order of 10 (15 or less, really) would cost $150, but an order of 20 would cost $200. I don't see this feature anywhere in the default OpenERP loadout, so I figure I will have to make it myself.

So as far as I can tell, the price is being calculated in sale.py using the _amount_line() method, but I can't quite tell how that method works. Here is the code:

    def _amount_line(self, cr, uid, ids, field_name, arg, context=None):

        tax_obj = self.pool.get('account.tax')

        cur_obj = self.pool.get('res.currency')

        res = {}

        if context is None:

            context = {}

        for line in self.browse(cr, uid, ids, context=context):

            price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)

            taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)

            cur = line.order_id.pricelist_id.currency_id

            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])

        return res

It seems to be calculating the total using the compute_all() method, but I can't seem to find where that is defined. My general plan is to create a new method that goes through every line item and checks to see if the subtotal is >= the minimum price, and sets it to that price if not. I figure it should then be called in the action_button_confirm method. Any advice on how I could implement this? Thanks!

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: 1/5/15, 6:14 PM
Seen: 1258 times
Last updated: 3/16/15, 8:10 AM