Odoo Help


Minimum Lot Charge For Sales Order Line Items

Alex Gallien
on 1/5/15, 6:14 PM 2,602 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!

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.


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)


Asked: 1/5/15, 6:14 PM
Seen: 2602 times
Last updated: 7/7/17, 12:14 PM