Odoo Help

0

How to pass value from one view to another?

By
Ken Tong
on 9/19/14, 1:18 PM 1,284 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.

https://dl.dropboxusercontent.com/u/42025188/01Request.png

https://dl.dropboxusercontent.com/u/42025188/02Order.png

 

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']

    STATE_SELECTION = [
        ('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)]}),
    }

 

0

Med Said BARA

--Med Said BARA--
2714
| 5 5 7
Algeria
--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
0

Ben Bernard

--Ben Bernard--
1083
| 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.

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

2 follower(s)

Stats

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