تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
6830 أدوات العرض

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

 

الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
أفضل إجابة

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?

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مارس 21
3057
4
أبريل 16
4084
0
مارس 15
3466
3
ديسمبر 23
49324
2
مارس 17
19803