Odoo Help


How to pass value from one view to another?

Ken Tong
on 9/19/14, 1:18 PM 1,196 views

I am using MRO module.

I have created Maintenance Request with some value selected from dropdown value taken from res.company . It should proceed to next form, Maintenance Order.

The value does not seems to appear in Maintenance Order. Kindly refer to the attached.  Any help is highly appreciated.




My field name is x_client. I did modify the mro.py file :-

 Maintenance Requests
    _name = 'mro.request'
    _description = 'Maintenance Request'
    _inherit = ['mail.thread', 'ir.needaction_mixin']

        ('draft', 'Draft'),
        ('claim', 'Claim'),
        ('run', 'Execution'),
        ('done', 'Done'),
        ('reject', 'Rejected'),
        ('cancel', 'Canceled')
    _track = {
        'state': {
            'mro.mt_request_sent': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'claim',
            'mro.mt_request_confirmed': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'run',
            'mro.mt_request_rejected': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'reject',
    _columns = {
        'name': fields.char('Reference', size=64),
        'state': fields.selection(STATE_SELECTION, 'Status', readonly=True,
            help="When the maintenance request is created the status is set to 'Draft'.\n\
            If the request is sent the status is set to 'Claim'.\n\
            If the request is confirmed the status is set to 'Execution'.\n\
            If the request is rejected the status is set to 'Rejected'.\n\
            When the maintenance is over, the status is set to 'Done'."),
        'asset_id': fields.many2one('asset.asset', 'Asset', required=True, readonly=True, states={'draft': [('readonly', False)]}),
        'cause': fields.char('Cause', size=64, translate=True, required=True, readonly=True, states={'draft': [('readonly', False)]}),
        'description': fields.text('Description', readonly=True, states={'draft': [('readonly', False)]}),
        'reject_reason': fields.text('Reject Reason', readonly=True),
        'requested_date': fields.datetime('Requested Date', required=True, select=1, readonly=True, states={'draft': [('readonly', False)]}, help="Date requested by the customer for maintenance."),
        'execution_date': fields.datetime('Execution Date', required=True, select=1, readonly=True, states={'draft':[('readonly',False)],'claim':[('readonly',False)]}),
        'breakdown': fields.boolean('Breakdown', readonly=True, states={'draft': [('readonly', False)]}),
        'create_uid': fields.many2one('res.users', 'Responsible'),
    'x_client': fields.many2one('res.company', 'Client', required=True, readonly=True, states={'draft': [('readonly', False)]}),



Med Said BARA

--Med Said BARA--
Med Said BARA
| 5 5 7
--Med Said BARA--
Med Said BARA
On 9/22/14, 11:29 AM

1_ If x_client is related to customer, you should use res.partner instead of res.company:

'x_client': fields.many2one('res.partner', 'name', required=True, readonly=True, states={'draft': [('readonly', False)]}),

2_ you can also add a domain filter to select only "customers from  partners": domain="[('customer', '=', True)

3_ What about the view in xml file?

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

Doing domain filter, domain="[('customer', '=', True) It display the contact Person and the company as well. What if I would like to display the contact person only without the company. Is that possible?

Ken Tong
on 10/6/14, 12:10 PM

Ben Bernard

--Ben Bernard--
Ben Bernard
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 9/20/14, 12:27 PM

The key is your "client" field in request model is independent to the order model from the database perspective. So, the question is not how to pass the value, but the data from other table (model) in database. One method you can use is to implement onchange event in "client" field in the order model which get and return the "client" from the request model.

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

2 follower(s)


Asked: 9/19/14, 1:18 PM
Seen: 1196 times
Last updated: 3/16/15, 8:10 AM