Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6914 Lượt xem

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

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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?

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 21
3135
4
thg 4 16
4188
0
thg 3 15
3563
3
thg 12 23
49492
2
thg 3 17
19926