def _change_city_select(self, xfer, list_postalcode, obj_city): obj_country = xfer.get_components('country') city_current = obj_city.value city_list = {} obj_country.value = "" for item_postalcode in list_postalcode: city_list[item_postalcode.city] = item_postalcode.city if item_postalcode.city == city_current: obj_country.value = item_postalcode.country if obj_country.value == "": obj_country.value = list_postalcode[0].country city_current = list_postalcode[0].city xfer.remove_component('city') xfer.tab = obj_city.tab city_select = XferCompSelect('city') city_select.set_value(city_current) city_select.set_select(city_list) city_select.set_location(obj_city.col, obj_city.row, obj_city.colspan, obj_city.rowspan) city_select.description = obj_city.description city_select.set_size(obj_city.vmin, obj_city.hmin) city_select.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(city_select)
def edit_account_for_line(self, xfer, column, row, debit_rest, credit_rest): num_cpt_txt = xfer.getparam('num_cpt_txt', '') num_cpt = xfer.getparam('num_cpt', 0) lbl = XferCompLabelForm('numCptlbl') lbl.set_location(column, row, 3) lbl.set_value_as_headername(_('account')) xfer.add_component(lbl) edt = XferCompEdit('num_cpt_txt') edt.set_location(column, row + 1, 2) edt.set_value(num_cpt_txt) edt.set_size(20, 25) edt.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) xfer.add_component(edt) sel_val = [] current_account = None if num_cpt_txt != '': year = FiscalYear.get_current(xfer.getparam('year')) sel_val, current_account = year.get_account_list(num_cpt_txt, num_cpt) sel = XferCompSelect('num_cpt') sel.set_location(column + 2, row + 1, 1) sel.set_select(sel_val) sel.set_size(20, 150) sel.set_action(xfer.request, xfer.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) if current_account is not None: sel.set_value(current_account.id) self.item.account = current_account self.item.set_montant( float(xfer.getparam('debit_val', 0.0)), float(xfer.getparam('credit_val', 0.0))) if abs(self.item.amount) < 0.0001: self.item.set_montant(debit_rest, credit_rest) xfer.add_component(sel) return lbl, edt
def fillresponse_search_select(self): selector, script_ref = self.fields_desc.get_select_and_script() script_ref += """ var name=current.getValue(); var type=findFields[name]; parent.get('searchValueFloat').setVisible(type=='float'); parent.get('searchValueStr').setVisible(type=='str'); parent.get('searchValueBool').setVisible(type=='bool'); parent.get('searchValueDate').setVisible(type=='date' || type=='datetime'); parent.get('searchValueTime').setVisible(type=='time' || type=='datetime'); parent.get('searchValueList').setVisible(type=='list' || type=='listmult'); """ script_ref += get_script_for_operator() script_ref += """ if (type=='float') { var prec=findLists[name].split(';'); parent.get('searchValueFloat').setValue('<FLOAT min=\"'+prec[0]+'\" max=\"'+prec[1]+'\" prec=\"'+prec[2]+'\"></FLOAT>'); } if (type=='str') { parent.get('searchValueStr').setValue('<STR></STR>'); } if (type=='bool') { parent.get('searchValueBool').setValue('<BOOL>n</BOOL>'); } if (type=='date' || type=='datetime') { parent.get('searchValueDate').setValue('<DATE>1900/01/01</DATE>'); } if (type=='time' || type=='datetime') { parent.get('searchValueTime').setValue('<DATE>00:00:00</DATE>'); } if ((type=='list') || (type=='listmult')) { var list=findLists[name].split(';'); var list_txt=''; for(i=0;i<list.length;i++) { var val=list[i].split('||'); if (val.length>1) { list_txt+='<CASE id=\"'+val[0]+'\">'+val[1]+'</CASE>'; } } parent.get('searchValueList').setValue('<SELECT>'+list_txt+'</SELECT>'); } """ label = XferCompLabelForm('labelsearchSelector') label.set_value("{[bold]Nouveau critere{[/bold]") label.set_location(0, 10, 1, 7) self.add_component(label) comp = XferCompSelect("searchSelector") comp.set_select(selector) comp.set_value("") comp.set_location(1, 10, 1, 7) comp.set_size(20, 200) comp.java_script = script_ref self.add_component(comp) comp = XferCompSelect("searchOperator") comp.set_select({}) comp.set_value("") comp.set_size(20, 200) comp.set_location(2, 10, 1, 7) self.add_component(comp)
def fillresponse_search_select(self): selector, script_ref = self.fields_desc.get_select_and_script() script_ref += """ var name=current.getValue(); var type=findFields[name]; parent.get('searchValueFloat').setVisible(type=='float'); parent.get('searchValueStr').setVisible(type=='str'); parent.get('searchValueBool').setVisible(type=='bool'); parent.get('searchValueDate').setVisible(type=='date' || type=='datetime'); parent.get('searchValueTime').setVisible(type=='time' || type=='datetime'); parent.get('searchValueList').setVisible(type=='list' || type=='listmult'); """ script_ref += get_script_for_operator() script_ref += """ if (type=='float') { var prec=findLists[name]; parent.get('searchValueFloat').setValue({min:prec[0],max:prec[1],prec:prec[2],value:0}); } if (type=='str') { parent.get('searchValueStr').setValue({value:''}); } if (type=='bool') { parent.get('searchValueBool').setValue({value:false}); } if (type=='date' || type=='datetime') { parent.get('searchValueDate').setValue({value:'2000-01-01'}); } if (type=='time' || type=='datetime') { parent.get('searchValueTime').setValue({value:'00:00'}); } if ((type=='list') || (type=='listmult')) { var select_case=findLists[name]; parent.get('searchValueList').setValue({case:select_case,value:0}); } """ label = XferCompLabelForm('labelsearchSelector') label.set_value("{[bold]Nouveau critere{[/bold]") label.set_location(0, 10, 1, 7) self.add_component(label) comp = XferCompSelect("searchSelector") comp.set_select(selector) comp.set_value("") comp.set_location(1, 10, 1, 7) comp.set_size(20, 200) comp.java_script = script_ref self.add_component(comp) comp = XferCompSelect("searchOperator") comp.set_select({}) comp.set_value("") comp.set_size(20, 200) comp.set_location(2, 10, 1, 7) self.add_component(comp)
def edit(self, xfer): obj_model = xfer.get_components('modelname') obj_kind = xfer.get_components('kind') xfer.tab = obj_model.tab sel_models = self._get_basic_model(xfer).get_select_contact_type() model_current = obj_model.value xfer.remove_component('modelname') model_select = XferCompSelect('modelname') model_select.description = obj_model.description model_select.set_value(model_current) model_select.set_select(sel_models) model_select.set_location(obj_model.col, obj_model.row, obj_model.colspan, obj_model.rowspan) model_select.set_size(obj_model.vmin, obj_model.hmin) xfer.add_component(model_select) if len(sel_models) == 1: xfer.params['modelname'] = sel_models[0][0] model_select.set_value(xfer.params['modelname']) xfer.change_to_readonly('modelname') self._edit_add_args(xfer, obj_kind) obj_kind.java_script = """
def _filter_by_nature(self): select_filter = self.getparam('filter', 1) lbl = XferCompLabelForm("filterLbl") lbl.set_location(0, 3) lbl.set_value_as_name(_("Filter")) self.add_component(lbl) sel = XferCompSelect("filter") sel.set_select({0: _('All'), 1: _('In progress'), 2: _('Valid'), 3: _('Lettered'), 4: _('Not lettered')}) sel.set_value(select_filter) sel.set_location(1, 3) sel.set_size(20, 200) sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(sel) if select_filter == 1: self.filter &= Q(close=False) elif select_filter == 2: self.filter &= Q(close=True) elif select_filter == 3: self.filter &= Q(link__id__gt=0) elif select_filter == 4: self.filter &= Q(link=None)