Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
6916 Ansichten

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)]}),
    }

 

Avatar
Verwerfen
Beste Antwort

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.

Avatar
Verwerfen
Beste Antwort

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"/>

Avatar
Verwerfen
Autor

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?

Verknüpfte Beiträge Antworten Ansichten Aktivität
0
März 21
3135
4
Apr. 16
4188
0
März 15
3563
3
Dez. 23
49493
2
März 17
19928