Odoo Help

5

How do I make a button to move to next record? [Closed]

By
AJ Schrafel Paper Corp
on 6/12/13, 12:39 AM 2,808 views

The Question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
on 06/13/2013 16:38:10

I want to create a button on my custom module that will mark the current record finished, then move to the next record, as if I hit the arrows in the upper right corner to move between records.

def action_button_verify_bad(self, cr, uid, ids, context=None):
    res = self.write(cr, uid, ids, {'fail_check': True}, context=context)
    return {'type':'ir.actions.act_window_close'}

What do I have to return to move the the next record?

9

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11031
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

Top 10 Odoo contributor On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 6/12/13, 4:17 AM

Add the following code in you py file:

def action_button_verify_bad(self, cr, uid, ids, context=None):
    range = self.search(cr, uid, [], context=context)
    if len(range) > 0:
        range.sort()
        range = range[-1:]
        range = range and range[0]
    else:
        return {}
    next_id = ids and ids[0]
    while True:
        if range == next_id:
            next_id = 1
        next_id += 1
        res_id = self.search(cr,uid,[('id', '=', next_id)], context=context)
        if res_id:
            self.write(cr, uid, ids, {'fail_check': True}, context=context)
            return {
                'name': _("Your Object Name"),
                'res_id': res_id[0],
                'view_type': 'form',
                'res_model': 'sale.order',
                'view_mode': 'form,tree',
                'nodestroy': True,
                'target': 'current',
                'context': context,
                'type': 'ir.actions.act_window',
            }

This will work for sure.

this worked 95%, i had to add in my view search parameters and the view_id, but your answer got me there.

AJ Schrafel Paper Corp
on 6/13/13, 12:46 PM

It's good to hear that it worked.

Sudhir Arya (ERP Harbor Consulting Services)
on 6/13/13, 4:37 PM

So useful!! Thanks a lot!

Michael O. Lambert
on 3/27/14, 10:45 AM
6

ClueLogics Technologies Pvt. Ltd.

--ClueLogics Technologies Pvt. Ltd.--
6133
| 6 5 8
Delhi NCR, India
--ClueLogics Technologies Pvt. Ltd.--

 ClueLogics Technologies Pvt Ltd is a Software product and services provider. We are positioned to deliver robust, rapid and reliable Information Technology solutions that work. What we succeed upon is Technology and Technical Expertise. The industry review of ClueLogics has been commendable for the past years as most of its business comes from repeat orders by highly satisfied clients.

ClueLogics Technologies Pvt. Ltd.
On 6/12/13, 3:22 AM

Hi

for that case you do one thing

          def action_button_verify_bad(self, cr, uid, ids, context=None):
                       for id in ids:
                              next=id+1
                              yes=self.search(cr,uid,[('id','=',next)])
                              if yes:
                                     return {
                                            'name':_("My module name"), 
                                        'view_mode': 'form',
                                        'view_id': False,
                                        'view_type': 'form',
                                        'res_model': 'my.module',
                                        'res_id': yes[0],
                                        'type': 'ir.actions.act_window',
                                        'nodestroy': True,
                                        'target': 'current',
                                        'domain': '[]',
                                            'context': context
                                            }
                              else:
                                    return {'type':'ir.actions.act_window_close'}

Thanks
Sandeep

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.

Register

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

0 follower(s)

Stats

Asked: 6/12/13, 12:39 AM
Seen: 2808 times
Last updated: 3/16/15, 8:10 AM