Odoo Help


[8.0]How to confirm an element's state from: action_confirm (MRP_REPAIR)

Mohammed Kamar-eddine
on 6/27/16, 7:25 AM 780 views

Currently my mrp_repair file has the button action_repair_done set so that once it's clicked, it converts the state of another document to termine // completed

# action_repair_done block

    def action_repair_done(self, cr, uid, ids, context=None):
        print "action_repair_done-------------------",ids, context
        res = {}
        move_obj = self.pool.get('stock.move')
        repair_line_obj = self.pool.get('mrp.repair.line')
        reception_obj = self.pool.get('garage.reception')
        for repair in self.browse(cr, uid, ids, context=context):
            move_ids = []
            for move in repair.operations:
                repair_line_obj.write(cr, uid,
                                      [move.id], {'state': 'done'},
            self.write(cr, uid, [repair.id], {'state': 'done'},
            # CODE BLOCK making the reception done once the repair is finished.
            if repair.reception_id:
                print "repair.reception_id-----------",repair.reception_id
                reception_obj.write(cr, uid, [repair.reception_id.id],
                                    {'state': 'termine'}, context=context)
            if repair:
                this = repair
                reception_id = this.reception_id or None
                vals = {
                    'name': None,
                    'partner_id': this.partner_id and this.partner_id.id or
                    'reception_id': reception_id.id,
                    'partner_recived_from': reception_id and
                                            or None,
					'responsable_id': reception_id and
					reception_id.responsable_id and
					reception_id.responsable_id.id or None,
                    'fleet_id': this.fleet_id and this.fleet_id.id or None,
                    'kilometrage': reception_id.kilometrage,
                    'state': 'en_cours',
                    'datetime_livraison': time.strftime('%Y-%m-%d %H:%M:%S'),
                if this.service_requested_ids:
                    vals.update({'service_done_ids' : [(6, 0, [service_id.id for service_id in this.service_requested_ids])] })
                livraison_id = self.pool.get('garage.livraison').\
                    create(cr, uid, vals, context=context)
                self.write(cr, uid, [this.id],
                           {'livraison_id': livraison_id}, context=context)
                # ********************************
        return True

as you can see the block helping this to work is:

        reception_obj = self.pool.get('garage.reception')
        for repair in self.browse(cr, uid, ids, context=context):


            if repair.reception_id:
                print "repair.reception_id-----------",repair.reception_id
                reception_obj.write(cr, uid, [repair.reception_id.id],
                                    {'state': 'termine'}, context=context)

Everything works fine / but i actually want this action to take place not in the action_repair_done function, BUT in the function listed below (action_confirm):

    def action_confirm(self, cr, uid, ids, *args):
        """ Repair order state is set to 'To be invoiced' when invoice method
        is 'Before repair' else state becomes 'Confirmed'.
        @param *arg: Arguments
        @return: True
        print "\n\naction_confirm-------------------",ids,args 
        mrp_line_obj = self.pool.get('mrp.repair.line')
        for o in self.browse(cr, uid, ids):
            if (o.invoice_method == 'b4repair'):
                self.write(cr, uid, [o.id], {'state': '2binvoiced'})
                self.write(cr, uid, [o.id], {'state': 'confirmed'})
                print "o.operations---------",o.operations
                for line in o.operations:
                    if line.product_id.track_production:
                        raise osv.except_osv(_('Warning!'),
                                             _("Serial number is required"
                                               "for operation line with"
                                               "product '%s'") % (
                mrp_line_obj.write(cr, uid, [l.id for l in o.operations],
                                   {'state': 'confirmed'})
        move_obj = self.pool.get('stock.move')
        repair_line_obj = self.pool.get('mrp.repair.line')
        for repair in self.browse(cr, uid, ids):
            move_ids = []
            for move in repair.operations:
                if move.product_id.type != 'service':
                    move_id = move_obj.create(cr, uid, {
                        'name': move.name,
                        'product_id': move.product_id.id,
                        'repair_id': repair.id,
                        'restrict_lot_id': move.lot_id.id,
                        'product_uom_qty': move.product_uom_qty,
                        'product_uom': move.product_uom.id,
                        'partner_id': repair.address_id and
                                      repair.address_id.id or False,
                        'location_id': move.location_id.id,
                        'location_dest_id': move.location_dest_id.id,
                        'state': 'assigned',
                    print "move_id------",move_id
                    repair_line_obj.write(cr, uid, [move.id],
                                          {'move_id': move_id})
        mrp_id = self.browse(cr, uid, ids)
        if mrp_id.sale_id:
             test = self.pool.get('sale.order').action_button_confirm(cr, uid, [mrp_id.sale_id.id], context=None)
        self.action_ship_create(cr, uid, ids, context={})
        return True

Where exactly could i include the code to make the action take place. Thanks

Mohammed Kamar-eddine
On 6/29/16, 12:53 PM

Can we have a resolution please for this issue?

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/27/16, 7:25 AM
Seen: 780 times
Last updated: 6/29/16, 12:53 PM