1
votes

I'm having Odoo workflow with Cancel and Reset buttons. I need that user on these buttons clicks can add a reason.

For that I found sale_cancel_reason app. Example here:enter image description here

But I need everytime to write new reason, not select from list. I tied to make many2one relation to wizzard that user everytime can write reason on popup wizzard window:

cancel_id = fields.Many2one('sale.order.cancel', string="Cancellation")

'sale.order.cancel' - wizzard object

But then I got error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/opt/odoo/openerp/service/server.py", line 245, in app
    return self.app(e, s)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 184, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/openerp/service/wsgi_server.py", line 170, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1488, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1462, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/openerp/http.py", line 1637, in dispatch
    ir_http = request.registry['ir.http']
  File "/opt/odoo/openerp/http.py", line 360, in registry
    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
  File "/opt/odoo/openerp/modules/registry.py", line 354, in get
    update_module)
  File "/opt/odoo/openerp/modules/registry.py", line 385, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/openerp/modules/loading.py", line 334, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/odoo/openerp/modules/loading.py", line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/odoo/openerp/modules/loading.py", line 137, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/opt/odoo/openerp/modules/module.py", line 293, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/opt/odoo/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 2625, in _auto_init
    self._m2o_fix_foreign_key(cr, self._table, k, dest_model, f.ondelete)
  File "/opt/odoo/openerp/api.py", line 238, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/models.py", line 2384, in _m2o_fix_foreign_key
    self._m2o_add_foreign_key_checked(source_field, dest_model, ondelete)
  File "/opt/odoo/openerp/models.py", line 2324, in _m2o_add_foreign_key_checked
    'Many2One relationships from non-transient Model to TransientModel are forbidden'
AssertionError: Many2One relationships from non-transient Model to TransientModel are forbidden

As I understand I can't use Many2one relation with wizzard object. But how else can I make popup window with writable reason field? Is there any ways to do that?

1
what is your problem exactly is the selection if is that than the first answer is what you needCharif DZ

1 Answers

1
votes

Edit sale_cancel_reason\wizard\cancel_reason_view.xml file and change:

<field name="reason_id" widget="selection"/>

To

<field name="reason_id"/>

Update:

To create a new reason each time you click cancel button use this sale_cancel_reason

changed reason_id (Many2one) to reason (Char)