# -*- coding: utf-8 -*-
from ppms.migration.packet import *
 
class MissingListboxInMV(ChangeDTPPacket):
    '''Add a missing listbox to the MV "Requests" in module 0099F5
    
    When you change to the module variant "Requests" in the module 0099F5 the Listbox
    on the field 057969 was missing, even though the other MVs do in fact have
    a listbox on this field. This packet will restore the listbox to that MV.
    '''
    version = 1
    done_after_success = True
    run_on_startup = True
    category = PacketCategory.CATEGORY_MANDATORY
    wi_number = 8012

    def fix(self, runner):
        new_value = 'DI001992=13'
        old_value = 'DI000221=o;DI001992=13'

        self.log('Changing MV Requests of MOD0099F5: change DF057969 to listbox')

        record = self.get_record(503, ['0110J6', '040882', 728013], [28074])
        if not record:
            return self.fail()

        if not self.change_value(record, 'settings', old_value, new_value):
            return self.fail()

        return self.success()