Odoo Help


ODOO8: Untaxed and total amount in order lines not calculating

Mohammed Kamar-eddine
on 6/24/16, 1:42 PM 355 views
I add multiple PRODUCTS in the order lines of the REPAIR-ORDER, the price of each product shows up - but the untaxed sub total and total display (0) instead of the total of all products.

[![TOTAL AMOUNT][1]][1]


I've attached some of the code of the MRP REPAIR (.py) file :

    def _amount_all_wrapper_repair(self, cr, uid, ids, field_name, arg, context=None):
        """ Wrapper because of direct method passing as parameter for function fields """
        return self._amount_all_repair(cr, uid, ids, field_name, arg, context=context)
    def _amount_all_repair(self, cr, uid, ids, field_name, arg, context=None):
        cur_obj = self.pool.get('res.currency')
        res = {}
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id] = {
                'amount_untaxed': 0.0,
                'amount_tax': 0.0,
                'amount_total': 0.0,
            val = val1 = 0.0
            cur = order.sale_id.pricelist_id.currency_id
            for line in order.order_line_ids:
                val1 += line.price_subtotal
                val += self._amount_line_tax_repair(cr, uid, line, context=context)
            res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
            res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
            res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
        return res

The code for the mrp_repair.xml:

	<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
                                <field name="amount_untaxed" widget='monetary' options="{'currency_field': 'currency_id'}"/>
                                <field name="amount_tax" widget='monetary' options="{'currency_field': 'currency_id'}"/>
                                <div class="oe_subtotal_footer_separator oe_inline">
                                    <label for="amount_total" />
                                    <button name="button_dummy"
                                        states="draft,sent" string="(update)" type="object" class="oe_edit_only oe_link"/>
                                <field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
                                <div class="oe_inline" groups="garage.group_display_margin">
                                	<label for="margin" style="font-weight:bold;"/>
                                	<field name="margin" nolabel="1" style="font-weight:bold;" groups="garage.group_display_margin"/>



I found that without the code below (this code causes MRP_REPAIR to add order lines both to the REPAIR ORDER and SALES ORDER), adding a product with a price doesnt get calculated in total field, and shows zero (0)

elif this.repair_sale_order_line_id:
                sale_obj = self.pool.get('sale.order')
                so_vals = {
                    'partner_id' : this.repair_sale_order_line_id.partner_id.id,
                    'fleet_id': this.repair_sale_order_line_id.fleet_id.id,
                    'responsable_id': uid,
                created_so_id = so_obj.create(cr, uid, so_vals, context=context)
                sol_vals = {'order_id': created_so_id,
                           'price_unit': this.price_unit,
                           'product_uom_qty': this.product_uom_qty,
                           'price_subtotal': this.price_subtotal,
                           'discount': this.discount,
                           'product_id': this.product_id.id,
                           'tax_id': [(6, 0, [x.id for x
                                                     in this.tax_id])],
                           'name': this.name,
                self.pool.get('mrp.repair').write(cr, uid, this.repair_sale_order_line_id.id, {'sale_id':created_so_id},context=context)
                sol_id = sol_obj.create_sol(cr, uid, sol_vals, context)
                super(repair_sale_order_line, self).write(cr, uid, [res],{'sale_order_line_id':sol_id})

it seems that the Sale Order lines are used instead of the internal Repair Sale Order lines. The question is: how can i make the mrp not depend on the SO or its ORDER LINES.?

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 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: 6/24/16, 1:42 PM
Seen: 355 times
Last updated: 6/27/16, 7:07 AM