Odoo Help


Performan action wizard from create method

on 4/17/16, 12:10 PM 1,350 views

Hello cummunity,

How it'is possible to perform an action wizard from create method.

I try this :

class ResPartner(models.Model):    
    _inherit = 'res.partner'
    def create(self, vals):
        partner_ids = self.search([('name', 'like', vals['name'])])
        if partner_ids:
            return self.button_partner_list(partner_ids)
        return super(ResPartner, self).create(vals)

    def button_partner_list(self, partner_ids):
        return {
            'type': 'ir.actions.act_window',
            'res_model': 'wizard.res.partner',
            'view_type': 'form',
            'view_mode': 'form',
            'target': 'new',
            'context': {
                'default_partner_ids': [(6, 0, partner_ids.ids)]

class WizardResPartner(models.TransientModel):
    _name = 'wizard.res.partner'
    partner_ids = fields.Many2many('res.partner', string='Partners')
I got this error when I run this code:

Odoo Server Error
Traceback (most recent call last):
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 680, in dispatch
    result = self._call_function(**self.params)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 316, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\service\model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 309, in checked_call
    result = self.endpoint(*a, **kw)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 959, in __call__
    return self.method(*args, **kw)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\http.py", line 509, in response_wrap
    response = f(*args, **kw)
  File "C:\Users\iPod\PycharmProjects\crf\server\addons\web\controllers\main.py", line 892, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\addons\web\controllers\main.py", line 884, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\api.py", line 355, in old_api
    return downgrade(recs, result, *args, **kwargs)
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\api.py", line 273, in <lambda>
    return lambda self, *args, **kwargs: downgrade(args[0])
  File "C:\Users\iPod\PycharmProjects\crf\server\openerp\models.py", line 4106, in <lambda>
    @api.returns('self', lambda value: value.id)
AttributeError: 'dict' object has no attribute 'id'

I know that create method expects res_partner object in return but how can I return an action dict ?
Any Idea !!


Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 4/18/16, 12:33 AM

You cannot do that in the create. Just put a button for that

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: 4/17/16, 12:10 PM
Seen: 1350 times
Last updated: 4/18/16, 12:33 AM