Ejemplo n.º 1
0
    def select_config(self, tablename):
        """ Get data from table 'config' and fill widgets according to the name of the columns """

        sql = "SELECT * FROM " + self.schema_name + "." + tablename
        row = self.dao.get_row(sql)
        if not row:
            self.controller.show_warning("Any data found in table " + tablename)
            return None
        
        # Iterate over all columns and populate its corresponding widget
        columns = []
        for i in range(0, len(row)):

            column_name = self.dao.get_column_name(i)
            widget_type = utils_giswater.getWidgetType(column_name)
            if widget_type is QCheckBox:
                utils_giswater.setChecked(column_name, row[column_name])
            elif widget_type is QDateEdit:
                utils_giswater.setCalendarDate(column_name, datetime.strptime(row[column_name], '%Y-%m-%d'))
            elif widget_type is QTimeEdit:
                timeparts = str(row[column_name]).split(':')
                if len(timeparts) < 3:
                    timeparts.append("0")
                days = int(timeparts[0]) / 24
                hours = int(timeparts[0]) % 24
                minuts = int(timeparts[1])
                seconds = int(timeparts[2])
                time = QTime(hours, minuts, seconds)
                utils_giswater.setTimeEdit(column_name, time)
                utils_giswater.setText(column_name + "_day", days)
            else:
                utils_giswater.setWidgetText(column_name, row[column_name])
            columns.append(column_name)

        return columns
Ejemplo n.º 2
0
    def master_config_master(self):
        """ Button 99: Open a dialog showing data from table 'config_param_system' """

        # Create the dialog and signals
        self.dlg = ConfigMaster()
        utils_giswater.setDialog(self.dlg)
        self.load_settings(self.dlg)
        self.dlg.btn_accept.pressed.connect(self.master_config_master_accept)
        self.dlg.btn_cancel.pressed.connect(partial(self.close_dialog, self.dlg))
        self.dlg.rejected.connect(partial(self.save_settings, self.dlg))
        # Get records from tables 'config' and 'config_param_system' and fill corresponding widgets
        self.select_config("config")
        self.select_config_param_system("config_param_system") 

        self.dlg.om_path_url.clicked.connect(partial(self.open_web_browser, "om_visit_absolute_path"))
        self.dlg.om_path_doc.clicked.connect(partial(self.get_folder_dialog, "om_visit_absolute_path"))
        self.dlg.doc_path_url.clicked.connect(partial(self.open_web_browser, "doc_absolute_path"))
        self.dlg.doc_path_doc.clicked.connect(partial(self.get_folder_dialog, "doc_absolute_path"))

        if self.project_type == 'ws':
            self.dlg.tab_topology.removeTab(1)

        sql = "SELECT name FROM" + self.schema_name + ".plan_psector ORDER BY name"
        rows = self.dao.get_rows(sql)
        utils_giswater.fillComboBox("psector_vdefault", rows)

        sql = "SELECT parameter, value FROM " + self.schema_name + ".config_param_user"
        sql += " WHERE parameter = 'psector_vdefault'"
        row = self.dao.get_row(sql)
        if row:
            utils_giswater.setChecked("chk_psector_enabled", True)
            utils_giswater.setWidgetText(str(row[0]), str(row[1]))
            
        self.dlg.exec_()
Ejemplo n.º 3
0
    def go2epa_options_get_data(self, tablename, dialog):
        """ Get data from selected table """
        
        sql = "SELECT * FROM " + self.schema_name + "." + tablename
        row = self.controller.get_row(sql)
        if not row:
            message = "Any data found in table"
            self.controller.show_warning(message, parameter=tablename)
            return None

        # Iterate over all columns and populate its corresponding widget
        columns = []
        for i in range(0, len(row)):
            column_name = self.dao.get_column_name(i)
            widget = dialog.findChild(QWidget, column_name)
            widget_type = utils_giswater.getWidgetType(dialog, widget)
            if row[column_name] is not None:
                if widget_type is QCheckBox:
                    utils_giswater.setChecked(dialog, widget, row[column_name])
                elif widget_type is QComboBox:
                    utils_giswater.set_combo_itemData(widget, row[column_name], 0)
                elif widget_type is QDateEdit:
                    dateaux = row[column_name].replace('/', '-')
                    date = QDate.fromString(dateaux, 'dd-MM-yyyy')
                    utils_giswater.setCalendarDate(dialog, widget, date)
                elif widget_type is QTimeEdit:
                    timeparts = str(row[column_name]).split(':')
                    if len(timeparts) < 3:
                        timeparts.append("0")
                    days = int(timeparts[0]) / 24
                    hours = int(timeparts[0]) % 24
                    minuts = int(timeparts[1])
                    seconds = int(timeparts[2])
                    time = QTime(hours, minuts, seconds)
                    utils_giswater.setTimeEdit(dialog, widget, time)
                    utils_giswater.setText(dialog, column_name + "_day", days)
                else:
                    utils_giswater.setWidgetText(dialog, widget, str(row[column_name]))

            columns.append(column_name)
            
        return columns
    def open_dlg_rapports(self, previous_dialog):

        default_file_name = utils_giswater.getWidgetText(previous_dialog.name)

        self.dlg_psector_rapport = Psector_rapport()
        utils_giswater.setDialog(self.dlg_psector_rapport)
        self.load_settings(self.dlg_psector_rapport)

        utils_giswater.setWidgetText('txt_composer_path', default_file_name + " comp.pdf")
        utils_giswater.setWidgetText('txt_csv_detail_path', default_file_name + " detail.csv")
        utils_giswater.setWidgetText('txt_csv_path', default_file_name + ".csv")

        self.dlg_psector_rapport.btn_cancel.pressed.connect(partial(self.set_prev_dialog, self.dlg_psector_rapport, previous_dialog))
        self.dlg_psector_rapport.btn_ok.pressed.connect(partial(self.generate_rapports, previous_dialog, self.dlg_psector_rapport))
        self.dlg_psector_rapport.btn_path.pressed.connect(partial(self.get_folder_dialog, self.dlg_psector_rapport.txt_path))

        utils_giswater.setWidgetText(self.dlg_psector_rapport.txt_path, 
            self.controller.plugin_settings_value('psector_rapport_path'))
        utils_giswater.setChecked(self.dlg_psector_rapport.chk_composer, 
            bool(self.controller.plugin_settings_value('psector_rapport_chk_composer')))
        utils_giswater.setChecked(self.dlg_psector_rapport.chk_csv_detail, 
            self.controller.plugin_settings_value('psector_rapport_chk_csv_detail'))
        utils_giswater.setChecked(self.dlg_psector_rapport.chk_csv, 
            self.controller.plugin_settings_value('psector_rapport_chk_csv'))
        if utils_giswater.getWidgetText(self.dlg_psector_rapport.txt_path) == 'null':
            if 'nt' in sys.builtin_module_names:
                plugin_dir = os.path.expanduser("~\Documents")
            else:
                plugin_dir = os.path.expanduser("~")
            utils_giswater.setWidgetText(self.dlg_psector_rapport.txt_path, plugin_dir)

        # Open dialog
        self.open_dialog(self.dlg_psector_rapport, maximize_button=False)     
Ejemplo n.º 5
0
 def mg_config_get_data(self, tablename):                
     ''' Get data from selected table '''
     
     sql = "SELECT *"
     sql+= " FROM "+self.schema_name+"."+tablename
     row = self.dao.get_row(sql)
     if not row:
         self.controller.show_warning("Any data found in table "+tablename)
         return None
     
     # Iterate over all columns and populate its corresponding widget
     columns = []
     for i in range(0, len(row)):
         column_name = self.dao.get_column_name(i)
         widget_type = utils_giswater.getWidgetType(column_name)
         if widget_type is QCheckBox:
             utils_giswater.setChecked(column_name, row[column_name])                        
         else:
             utils_giswater.setWidgetText(column_name, row[column_name])
         columns.append(column_name) 
         
     return columns           
Ejemplo n.º 6
0
    def edit_config_edit(self):
        """ Button 98: Open a dialog showing data from table 'config_param_user' """

        # Create the dialog and signals
        self.dlg = ConfigEdit()
        utils_giswater.setDialog(self.dlg)
        self.load_settings(self.dlg)
        self.dlg.btn_accept.pressed.connect(self.edit_config_edit_accept)
        self.dlg.btn_cancel.pressed.connect(partial(self.close_dialog, self.dlg))
        self.dlg.rejected.connect(partial(self.save_settings, self.dlg))
        
        # Set values from widgets of type QComboBox and dates
        sql = "SELECT DISTINCT(name) FROM " + self.schema_name + ".value_state ORDER BY name"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("state_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".cat_work ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("workcat_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".value_verified ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("verified_vdefault", rows)

        sql = 'SELECT value FROM ' + self.schema_name + '.config_param_user'
        sql += ' WHERE "cur_user" = current_user AND parameter = ' + "'builtdate_vdefault'"
        row = self.controller.get_row(sql)
        if row is not None:
            date_value = datetime.strptime(row[0], '%Y-%m-%d')
        else:
            date_value = QDate.currentDate()
        utils_giswater.setCalendarDate("builtdate_vdefault", date_value)

        sql = 'SELECT value FROM ' + self.schema_name + '.config_param_user'
        sql += ' WHERE "cur_user" = current_user AND parameter = ' + "'enddate_vdefault'"
        row = self.controller.get_row(sql)
        if row is not None:
            date_value = datetime.strptime(row[0], '%Y-%m-%d')
        else:
            date_value = QDate.currentDate()
        utils_giswater.setCalendarDate("enddate_vdefault", date_value)

        sql = "SELECT id FROM " + self.schema_name + ".cat_arc ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("arccat_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".cat_node ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("nodecat_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".cat_connec ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("connecat_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".cat_element ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("elementcat_vdefault", rows)  
        sql = "SELECT DISTINCT(name) FROM " + self.schema_name + ".exploitation ORDER BY name"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("exploitation_vdefault", rows)              
        sql = "SELECT DISTINCT(name) FROM " + self.schema_name + ".ext_municipality ORDER BY name"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("municipality_vdefault", rows)
        sql = "SELECT DISTINCT(name) FROM " + self.schema_name + ".om_visit_cat ORDER BY name"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("visitcat_vdefault", rows)

        # UD
        sql = "SELECT id FROM " + self.schema_name + ".node_type ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("nodetype_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".arc_type ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("arctype_vdefault", rows)
        sql = "SELECT id FROM " + self.schema_name + ".connec_type ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("connectype_vdefault", rows)

        # Set current values
        sql = "SELECT parameter, value FROM " + self.schema_name + ".config_param_user WHERE cur_user = current_user"
        rows = self.controller.get_rows(sql)
        for row in rows:
            utils_giswater.setWidgetText(str(row[0]), str(row[1]))
            utils_giswater.setChecked("chk_" + str(row[0]), True)

        # TODO PARAMETRIZAR ESTO!!!!!
        # Manage parameters 'state_vdefault', 'exploitation_vdefault', 'municipality_vdefault', 'visitcat_vdefault'
        sql = "SELECT name FROM " + self.schema_name + ".value_state WHERE id::text = "
        sql += "(SELECT value FROM " + self.schema_name + ".config_param_user WHERE parameter = 'state_vdefault')::text"
        row = self.controller.get_row(sql)
        if row:
            utils_giswater.setWidgetText("state_vdefault", str(row[0]))

        sql = "SELECT name FROM " + self.schema_name + ".exploitation WHERE expl_id::text = "
        sql += "(SELECT value FROM " + self.schema_name + ".config_param_user WHERE parameter = 'exploitation_vdefault')::text"
        row = self.controller.get_row(sql)
        if row:
            utils_giswater.setWidgetText("exploitation_vdefault", str(row[0]))

        sql = "SELECT name FROM " + self.schema_name + ".ext_municipality WHERE muni_id::text = "
        sql += "(SELECT value FROM " + self.schema_name + ".config_param_user WHERE parameter = 'municipality_vdefault')::text"
        row = self.controller.get_row(sql)
        if row:
            utils_giswater.setWidgetText("municipality_vdefault", str(row[0]))

        sql = "SELECT name FROM " + self.schema_name + ".om_visit_cat WHERE id::text = "
        sql += "(SELECT value FROM " + self.schema_name + ".config_param_user WHERE parameter = 'visitcat_vdefault')::text"
        row = self.controller.get_row(sql)
        if row:
            utils_giswater.setWidgetText("visitcat_vdefault", str(row[0]))

        if self.project_type == 'ws':
            self.dlg.tab_config.removeTab(1)
            self.dlg.tab_config.removeTab(1)
        elif self.project_type == 'ud':
            self.dlg.tab_config.removeTab(1)

        self.dlg.exec_()
    def new_psector(self, psector_id=None, plan_om=None):
        """ Buttons 45 and 81: New psector """
        
        # Create the dialog and signals
        self.dlg = Plan_psector()
        utils_giswater.setDialog(self.dlg)
        self.load_settings(self.dlg)
        self.plan_om = str(plan_om)
        self.dlg.setWindowTitle(self.plan_om + " psector")
        
        # Capture the current layer to return it at the end of the operation
        cur_active_layer = self.iface.activeLayer()
        self.set_selectionbehavior(self.dlg)
        self.project_type = self.controller.get_project_type()

        # Get layers of every geom_type
        self.list_elemets = {}
        self.reset_lists()
        self.reset_layers()
        self.layers['arc'] = self.controller.get_group_layers('arc')
        self.layers['node'] = self.controller.get_group_layers('node')
        update = False  # if false: insert; if true: update

        # Remove all previous selections
        self.remove_selection(True)

        # Set icons
        self.set_icon(self.dlg.btn_insert, "111")
        self.set_icon(self.dlg.btn_delete, "112")
        self.set_icon(self.dlg.btn_snapping, "137")

        table_object = "psector"

        # tab General elements
        self.psector_id = self.dlg.findChild(QLineEdit, "psector_id")
        self.cmb_psector_type = self.dlg.findChild(QComboBox, "psector_type")
        self.cmb_expl_id = self.dlg.findChild(QComboBox, "expl_id")
        self.cmb_sector_id = self.dlg.findChild(QComboBox, "sector_id")
        self.cmb_result_id = self.dlg.findChild(QComboBox, "result_id")
        self.dlg.lbl_result_id.setVisible(True)
        self.cmb_result_id.setVisible(True)
        scale = self.dlg.findChild(QLineEdit, "scale")
        scale.setValidator(QDoubleValidator())
        rotation = self.dlg.findChild(QLineEdit, "rotation")
        rotation.setValidator(QDoubleValidator())
        atlas_id = self.dlg.findChild(QLineEdit, "atlas_id")
        atlas_id.setValidator(QIntValidator())

        self.populate_combos(self.dlg.psector_type, 'name', 'id', self.plan_om + '_psector_cat_type', False)
        self.populate_combos(self.cmb_expl_id, 'name', 'expl_id', 'exploitation', False)
        self.populate_combos(self.cmb_sector_id, 'name', 'sector_id', 'sector', False)

        if self.plan_om == 'om':
            self.populate_result_id(self.dlg.result_id, self.plan_om + '_result_cat')
        elif self.plan_om == 'plan':
            self.dlg.lbl_result_id.setVisible(False)
            self.cmb_result_id.setVisible(False)

        self.priority = self.dlg.findChild(QComboBox, "priority")
        sql = "SELECT DISTINCT(id) FROM " + self.schema_name + ".value_priority ORDER BY id"
        rows = self.controller.get_rows(sql)
        utils_giswater.fillComboBox("priority", rows, False)

        # tab Bugdet
        total_arc = self.dlg.findChild(QLineEdit, "total_arc")
        self.double_validator(total_arc)
        total_node = self.dlg.findChild(QLineEdit, "total_node")
        self.double_validator(total_node)
        total_other = self.dlg.findChild(QLineEdit, "total_other")
        self.double_validator(total_other)
        pem = self.dlg.findChild(QLineEdit, "pem")
        self.double_validator(pem)
        pec_pem = self.dlg.findChild(QLineEdit, "pec_pem")
        self.double_validator(pec_pem)
        pec = self.dlg.findChild(QLineEdit, "pec")
        self.double_validator(pec)
        pec_vat = self.dlg.findChild(QLineEdit, "pec_vat")
        self.double_validator(pec_vat)
        pca = self.dlg.findChild(QLineEdit, "pca")
        self.double_validator(pca)
        gexpenses = self.dlg.findChild(QLineEdit, "gexpenses")
        self.double_validator(gexpenses)
        vat = self.dlg.findChild(QLineEdit, "vat")
        self.double_validator(vat)
        other = self.dlg.findChild(QLineEdit, "other")
        self.double_validator(other)

        self.enable_tabs(False)
        self.enable_buttons(False)

        # Tables
        # tab Elements
        self.qtbl_arc = self.dlg.findChild(QTableView, "tbl_psector_x_arc")
        self.qtbl_arc.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.qtbl_node = self.dlg.findChild(QTableView, "tbl_psector_x_node")
        self.qtbl_node.setSelectionBehavior(QAbstractItemView.SelectRows)
        all_rows = self.dlg.findChild(QTableView, "all_rows")
        all_rows.setSelectionBehavior(QAbstractItemView.SelectRows)
        selected_rows = self.dlg.findChild(QTableView, "selected_rows")
        selected_rows.setSelectionBehavior(QAbstractItemView.SelectRows)

        # if a row is selected from mg_psector_mangement(button 46 or button 81)
        # Si psector_id contiene "1" o "0" python lo toma como boolean, si es True, quiere decir que no contiene valor
        # y por lo tanto es uno nuevo. Convertimos ese valor en 0 ya que ningun id va a ser 0. de esta manera si psector_id
        # tiene un valor distinto de 0, es que el sector ya existe y queremos hacer un update.
        if isinstance(psector_id, bool):
            psector_id = 0
        self.delete_psector_selector(self.plan_om + '_psector_selector')

        if psector_id != 0:
            self.enable_tabs(True)
            self.enable_buttons(True)
            self.dlg.name.setEnabled(False)
            self.fill_table(self.qtbl_arc, self.plan_om + "_psector_x_arc", set_edit_triggers=QTableView.DoubleClicked)
            self.set_table_columns(self.qtbl_arc, self.plan_om + "_psector_x_arc")
            self.fill_table(self.qtbl_node, self.plan_om + "_psector_x_node", set_edit_triggers=QTableView.DoubleClicked)
            self.set_table_columns(self.qtbl_node, self.plan_om + "_psector_x_node")
            sql = ("SELECT psector_id, name, psector_type, expl_id, sector_id, priority, descript, text1, text2,"
                   " observ, atlas_id, scale, rotation, active "
                   " FROM " + self.schema_name + "." + self.plan_om + "_psector"
                   " WHERE psector_id = " + str(psector_id))
            row = self.controller.get_row(sql)
            if not row:
                return
            
            self.psector_id.setText(str(row['psector_id']))
            utils_giswater.set_combo_itemData(self.cmb_psector_type, row['psector_type'], 0, 1)
            utils_giswater.set_combo_itemData(self.cmb_expl_id, row['expl_id'], 0, 1)
            utils_giswater.set_combo_itemData(self.cmb_sector_id, row['sector_id'], 0, 1)

            utils_giswater.setRow(row)
            utils_giswater.setChecked("active", row['active'])
            utils_giswater.fillWidget("name")
            utils_giswater.fillWidget("descript")
            index = self.priority.findText(row["priority"], Qt.MatchFixedString)
            if index >= 0:
                self.priority.setCurrentIndex(index)
            utils_giswater.fillWidget("text1")
            utils_giswater.fillWidget("text2")
            utils_giswater.fillWidget("observ")
            utils_giswater.fillWidget("atlas_id")
            utils_giswater.fillWidget("scale")
            utils_giswater.fillWidget("rotation")

            # Fill tables tbl_arc_plan, tbl_node_plan, tbl_v_plan/om_other_x_psector with selected filter
            expr = " psector_id = " + str(psector_id)
            self.qtbl_arc.model().setFilter(expr)
            self.qtbl_arc.model().select()

            expr = " psector_id = " + str(psector_id)
            self.qtbl_node.model().setFilter(expr)
            self.qtbl_node.model().select()

            self.populate_budget(psector_id)
            update = True
            if utils_giswater.getWidgetText(self.dlg.psector_id) != 'null':
                sql = ("DELETE FROM "+ self.schema_name + "."+self.plan_om + "_psector_selector "
                       " WHERE cur_user= current_user")
                self.controller.execute_sql(sql)
                self.insert_psector_selector(self.plan_om + '_psector_selector', 'psector_id', utils_giswater.getWidgetText(self.dlg.psector_id))
            if self.plan_om == 'plan':
                sql = ("DELETE FROM " + self.schema_name + ".selector_psector"
                       " WHERE cur_user = current_user AND psector_id='" +utils_giswater.getWidgetText(self.dlg.psector_id) + "'")
                self.controller.execute_sql(sql)
                self.insert_psector_selector('selector_psector', 'psector_id', utils_giswater.getWidgetText(self.dlg.psector_id))
        sql = ("SELECT state_id FROM " + self.schema_name + ".selector_state WHERE cur_user = current_user")
        rows = self.controller.get_rows(sql)
        self.all_states = rows
        self.delete_psector_selector('selector_state')
        self.insert_psector_selector('selector_state', 'state_id', '1')

        # Set signals
        self.dlg.btn_accept.pressed.connect(partial(self.insert_or_update_new_psector, update, "v_edit_" + self.plan_om + '_psector', True))
        self.dlg.tabWidget.currentChanged.connect(partial(self.check_tab_position, update))
        self.dlg.btn_cancel.pressed.connect(partial(self.close_psector, cur_active_layer))
        self.dlg.psector_type.currentIndexChanged.connect(partial(self.populate_result_id, self.dlg.result_id, self.plan_om + '_result_cat'))
        self.dlg.rejected.connect(partial(self.close_psector, cur_active_layer))

        self.lbl_descript = self.dlg.findChild(QLabel, "lbl_descript")
        self.dlg.all_rows.clicked.connect(partial(self.show_description))
        self.dlg.btn_select.clicked.connect(partial(self.update_total, self.dlg.selected_rows))
        self.dlg.btn_unselect.clicked.connect(partial(self.update_total, self.dlg.selected_rows))
        self.dlg.btn_insert.pressed.connect(partial(self.insert_feature, table_object, True))
        self.dlg.btn_delete.pressed.connect(partial(self.delete_records, table_object, True))
        self.dlg.btn_delete.setShortcut(QKeySequence(Qt.Key_Delete))
        self.dlg.btn_snapping.pressed.connect(partial(self.selection_init, table_object, True))

        self.dlg.btn_rapports.pressed.connect(partial(self.open_dlg_rapports, self.dlg))
        self.dlg.tab_feature.currentChanged.connect(partial(self.tab_feature_changed, table_object))
        self.dlg.name.textChanged.connect(partial(self.enable_relation_tab, self.plan_om + '_psector'))
        self.dlg.txt_name.textChanged.connect(partial(self.query_like_widget_text, self.dlg.txt_name, 
            self.dlg.all_rows, 'v_price_compost', 'v_edit_'+self.plan_om + '_psector_x_other', "id"))

        self.dlg.gexpenses.returnPressed.connect(partial(self.calulate_percents, self.plan_om + '_psector', psector_id, 'gexpenses'))
        self.dlg.vat.returnPressed.connect(partial(self.calulate_percents, self.plan_om + '_psector', psector_id, 'vat'))
        self.dlg.other.returnPressed.connect(partial(self.calulate_percents, self.plan_om + '_psector', psector_id, 'other'))

        sql = ("SELECT other, gexpenses, vat FROM " + self.schema_name + "." + self.plan_om + "_psector "
               " WHERE psector_id = '" + str(psector_id) + "'")
        row = self.controller.get_row(sql)
        if row:
            utils_giswater.setWidgetText(self.dlg.other, row[0])
            utils_giswater.setWidgetText(self.dlg.gexpenses, row[1])
            utils_giswater.setWidgetText(self.dlg.vat, row[2])

        # Adding auto-completion to a QLineEdit for default feature
        self.geom_type = "arc"
        viewname = "v_edit_" + self.geom_type
        self.set_completer_feature_id(self.geom_type, viewname)

        # Set default tab 'arc'
        self.dlg.tab_feature.setCurrentIndex(0)
        self.geom_type = "arc"
        self.tab_feature_changed(table_object)

        # Set QTableview columns from table config_client_forms
        # self.set_table_columns(self.qtbl_arc, self.plan_om + "_psector_x_arc")
        # self.set_table_columns(self.qtbl_node, self.plan_om + "_psector_x_node")
        
        # Open dialog
        self.open_dialog(self.dlg, maximize_button=False)