def fill_header(self): self.item = FiscalYear.get_current(self.getparam("year")) new_begin = convert_date(self.getparam("begin"), self.item.begin) new_end = convert_date(self.getparam("end"), self.item.end) if (new_begin >= self.item.begin) and (new_end <= self.item.end): self.item.begin = new_begin self.item.end = new_end img = XferCompImage('img') img.set_value(self.current_image()) if not img.value.startswith('/static/'): img.type = 'jpg' img.set_location(0, 0, 1, 5) self.add_component(img) if self.item.last_fiscalyear is not None: lbl = XferCompLabelForm('year_1') lbl.set_location(1, 0, 3) lbl.description = _('year N-1') lbl.set_value(six.text_type(self.item.last_fiscalyear)) self.add_component(lbl) select_year = XferCompSelect(self.field_id) select_year.set_location(1, 1, 3) select_year.set_select_query(FiscalYear.objects.all()) select_year.description = _('year N') select_year.set_value(self.item.id) select_year.set_needed(True) select_year.set_action(self.request, self.__class__.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(select_year) self.filter = Q(entry__year=self.item) self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
def fillresponse(self, ventilate=False): msg = self.item.check_close() if msg is not None: if self.getparam('CLOSE') is None: dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('info') lbl.set_value(_('This class load has a difference of %s between those call of funds and those expenses.') % msg) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompCheck('ventilate') lbl.set_value(ventilate) lbl.set_location(1, 2) lbl.description = 'Do you want to ventilate this amount for each owner?' dlg.add_component(lbl) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CLOSE': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: if self.item.type_load == 0: self.item.close_current(ventilate) else: self.item.close_exceptional(ventilate) elif self.confirme(_('Do you want to close this class load?')): if self.item.type_load == 0: self.item.close_current() else: self.item.close_exceptional()
def conf_wizard_accounting(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("accounting_params", 21)) wizard_ident.append(("accounting_fiscalyear", 22)) wizard_ident.append(("accounting_journal", 23)) elif (xfer is not None) and (wizard_ident == "accounting_params"): xfer.add_title(_("Diacamma accounting"), _('Parameters'), _('Configuration of accounting parameters')) select_account_system(xfer) fill_params(xfer, True) elif (xfer is not None) and (wizard_ident == "accounting_fiscalyear"): xfer.add_title(_("Diacamma accounting"), _('Fiscal year list'), _('Configuration of fiscal years')) xfer.fill_grid(5, FiscalYear, 'fiscalyear', FiscalYear.objects.all()) try: current_year = FiscalYear.get_current() nb_account = len(ChartsAccount.objects.filter(year=current_year)) lbl = XferCompLabelForm('nb_account') lbl.set_value(_("Total of charts of accounts in current fiscal year: %d") % nb_account) lbl.set_location(0, 10) xfer.add_component(lbl) if nb_account == 0: xfer.item = ChartsAccount() xfer.item.year = current_year btn = XferCompButton('initialfiscalyear') btn.set_location(1, 10) btn.set_action(xfer.request, ActionsManage.get_action_url(ChartsAccount.get_long_name(), 'AccountInitial', xfer), close=CLOSE_NO) xfer.add_component(btn) except LucteriosException as lerr: lbl = XferCompLabelForm('nb_account') lbl.set_value(six.text_type(lerr)) lbl.set_location(0, 10, 2) xfer.add_component(lbl) elif (xfer is not None) and (wizard_ident == "accounting_journal"): xfer.add_title(_("Diacamma accounting"), _('Journals'), _('Configuration of journals')) xfer.fill_grid(5, Journal, 'journal', Journal.objects.all())
def fillresponse(self, year=0): current_year = FiscalYear.objects.get(id=year) if self.getparam("CONFIRME") is None: nb_entry_noclose = current_year.check_to_close() text_confirm = six.text_type(_('close-fiscal-year-confirme')) if nb_entry_noclose > 0: if nb_entry_noclose == 1: text_confirm += six.text_type(_('warning, entry no validated')) else: text_confirm += six.text_type(_('warning, %d entries no validated') % nb_entry_noclose) dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0) dlg.add_component(lbl) lab = XferCompLabelForm('info') lab.set_value(text_confirm) lab.set_location(0, 1, 4) dlg.add_component(lab) signal_and_lock.Signal.call_signal("finalize_year", dlg) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: signal_and_lock.Signal.call_signal("finalize_year", self) current_year.closed()
def get_read_comp(self): param_cmp = XferCompLabelForm(self.name) if self.type == 5: # password param_cmp.set_value(''.ljust(len(self.value), '*')) else: param_cmp.set_value(self.get_read_text()) return param_cmp
def _create_custom_for_profit(self, year, custom, val_profit): from lucterios.framework.xfercomponents import XferCompImage, XferCompLabelForm, XferCompSelect from diacamma.accounting.models import format_devise if val_profit > 0.0001: type_profit = 'bénéfice' else: type_profit = 'déficite' img = XferCompImage("img") img.set_location(0, 0) img.set_value(get_icon_path("diacamma.accounting/images/account.png")) custom.add_component(img) lbl = XferCompLabelForm("title") lbl.set_value_as_headername("Bénéfices et Pertes") lbl.set_location(1, 0) custom.add_component(lbl) text = "{[i]}Vous avez un %s de %s.{[br/]}Vous devez definir sur quel compte l'affecter.{[br/]}{[/i]}" % ( type_profit, format_devise(val_profit, 4)) text += "{[br/]}En validant, vous commencerez '%s'{[br/]}{[br/]}{[i]}{[u]}Attention:{[/u]} Votre report à nouveau doit être totalement fait.{[/i]}" % six.text_type( year) lbl = XferCompLabelForm("info") lbl.set_value(text) lbl.set_location(0, 1, 2) custom.add_component(lbl) sel_cmpt = [] for account in year.chartsaccount_set.all().filter(code__startswith='10').order_by('code'): sel_cmpt.append((account.id, six.text_type(account))) sel = XferCompSelect("profit_account") sel.set_select(sel_cmpt) sel.set_location(1, 2) custom.add_component(sel) return custom
def summary_dummy(xfer): if not hasattr(xfer, 'add_component'): return True else: row = xfer.get_max_row() + 1 lab = XferCompLabelForm('dummytitle') lab.set_value_as_infocenter("Dummy") lab.set_location(0, row, 4) xfer.add_component(lab) lbl = XferCompLabelForm('dummy_time') lbl.set_color('blue') lbl.set_location(0, row + 1, 4) lbl.set_centered() lbl.set_value(datetime.now().ctime()) xfer.add_component(lbl) btn = XferCompButton('btnscheduler') btn.set_action(xfer.request, AddSchedulerTask.get_action('Task', '')) btn.set_location(0, row + 2, 4) xfer.add_component(btn) lbl = XferCompLabelForm('dummy-value') lbl.set_location(0, row + 3, 4) lbl.set_value(Params.getvalue('dummy-value')) xfer.add_component(lbl) return True
def _get_from_custom(self, request, *args, **kwargs): dlg = XferContainerCustom() dlg.request = self.request dlg.is_view_right = self.is_view_right dlg.caption = self.caption dlg.extension = self.extension dlg.action = self.action img_title = XferCompImage('img_title') img_title.set_location(0, 0, 1, 2) img_title.set_value(self.traitment_data[0]) dlg.add_component(img_title) lbl = XferCompLabelForm("info") lbl.set_location(1, 0) dlg.add_component(lbl) if self.getparam("RELOAD") is not None: lbl.set_value(six.text_type(self.traitment_data[2])) dlg.add_action(WrapAction(_("Close"), "images/close.png")) else: lbl.set_value_center("{[br/]}" + six.text_type(self.traitment_data[1])) btn = XferCompButton("Next") btn.set_location(1, 1) btn.set_size(50, 300) btn.set_action(self.request, self.return_action(_('Traitment...'), ""), params={"RELOAD": "YES"}) btn.java_script = "parent.refresh()" dlg.params["RELOAD"] = "YES" dlg.add_component(btn) dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png")) return dlg.get_post(request, *args, **kwargs)
def show_third(self, xfer, right=""): xfer.params["supporting"] = self.item.id third = xfer.get_components("third") third.colspan -= 2 if WrapAction.is_permission(xfer.request, right): btn = XferCompButton("change_third") btn.set_location(third.col + third.colspan, third.row) btn.set_action( xfer.request, ActionsManage.get_action_url("payoff.Supporting", "Third", xfer), modal=FORMTYPE_MODAL, close=CLOSE_NO, params={"code_mask": self.item.get_third_mask()}, ) xfer.add_component(btn) if self.item.third is not None: btn = XferCompButton("show_third") btn.set_is_mini(True) btn.set_location(third.col + third.colspan + 1, third.row) btn.set_action( xfer.request, ActionsManage.get_action_url("accounting.Third", "Show", xfer), modal=FORMTYPE_MODAL, close=CLOSE_NO, params={"third": self.item.third.id}, ) xfer.add_component(btn) lbl = XferCompLabelForm("info") lbl.set_color("red") lbl.set_location(1, xfer.get_max_row() + 1, 4) lbl.set_value(self.item.get_info_state()) xfer.add_component(lbl)
def fillresponse_body(self): self.get_components("title").colspan = 2 row_id = self.get_max_row() + 1 lbl = XferCompLabelForm('title_exp') lbl.set_value_as_headername(_("Expense")) lbl.set_location(0, row_id, 2) self.add_component(lbl) lbl = XferCompLabelForm('title_rev') lbl.set_value_as_headername(_("Revenue")) lbl.set_location(2, row_id, 2) self.add_component(lbl) row_id = self.get_max_row() self.fill_grid(row_id, self.model, 'budget_revenue', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_revenue_mask()))) self.move_components('budget_revenue', 2, 0) self.fill_grid(row_id, self.model, 'budget_expense', self.model.objects.filter(self.filter & Q(code__regex=current_system_account().get_expence_mask()))) self.remove_component('nb_budget_expense') self.remove_component('nb_budget_revenue') resultat_budget = Budget.get_total(self.getparam('year'), self.getparam('cost_accounting')) if abs(resultat_budget) > 0.0001: row_id = self.get_max_row() + 1 lbl = XferCompLabelForm('title_result') if resultat_budget > 0: lbl.set_value_as_name(_('result (profit)')) else: lbl.set_value_as_name(_('result (deficit)')) lbl.set_location(0, row_id) self.add_component(lbl) lbl = XferCompLabelForm('result') lbl.set_value(format_devise(resultat_budget, 5)) lbl.set_location(1, row_id) self.add_component(lbl)
def change_to_readonly(self, cmp_name): old_obj = self.get_components(cmp_name) value = old_obj.value if isinstance(old_obj, XferCompSelect): if isinstance(old_obj.select_list, dict) and (value in old_obj.select_list.keys()): value = old_obj.select_list[value] if isinstance(old_obj.select_list, list): for key, sel_val in old_obj.select_list: if value == key: value = sel_val break elif isinstance(old_obj, XferCompDate): value = formats.date_format(value, "DATE_FORMAT") elif isinstance(old_obj, XferCompDateTime): value = formats.date_format(value, "DATETIME_FORMAT") elif isinstance(old_obj, XferCompTime): value = formats.date_format(value, "TIME_FORMAT") elif isinstance(old_obj, XferCompFloat) and (value is not None): value = ("%%.%df" % old_obj.prec) % value if value is None: value = "---" self.remove_component(cmp_name) self.tab = old_obj.tab new_lbl = XferCompLabelForm(cmp_name) new_lbl.set_value(value) new_lbl.col = old_obj.col new_lbl.row = old_obj.row new_lbl.vmin = old_obj.vmin new_lbl.hmin = old_obj.hmin new_lbl.colspan = old_obj.colspan new_lbl.rowspan = old_obj.rowspan self.add_component(new_lbl)
def fillresponse_show_criteria(self): criteria_text_list = self.get_text_search() label = XferCompLabelForm('labelsearchDescTitle') if len(criteria_text_list) > 0: label.set_value_as_info("Your criteria of search") label.set_location(0, 17, 2, 4) else: label.set_value_as_infocenter("No criteria of search") label.set_location(0, 17, 4) self.add_component(label) row = 17 for criteria_id, criteria_text in criteria_text_list.items(): label = XferCompLabelForm('labelSearchText_' + criteria_id) label.set_value(criteria_text) label.set_location(2, row, 2) self.add_component(label) comp = XferCompButton("searchButtonDel_" + criteria_id) comp.set_is_mini(True) comp.set_location(4, row) comp.set_action(self.request, self.get_action("", "images/delete.png"), modal=FORMTYPE_REFRESH, close=CLOSE_NO, params={'ACT': criteria_id}) self.add_component(comp) row += 1
def show(self, xfer): xfer.move_components('lbl_body', 0, 2) xfer.move_components('body', 0, 2) obj_recipients = xfer.get_components('recipients') new_recipients = XferCompGrid('recipient_list') new_recipients.set_location(obj_recipients.col, obj_recipients.row, obj_recipients.colspan) new_recipients.add_header("model", _('model')) new_recipients.add_header("filter", _('filter')) compid = 0 for model_title, filter_desc in self.item.recipients_description: new_recipients.set_value(compid, "model", model_title) new_recipients.set_value(compid, "filter", filter_desc) compid += 1 if compid > 0: nb_contact = len(self.item.get_contacts()) contact_nb = XferCompLabelForm('contact_nb') contact_nb.set_location(obj_recipients.col, obj_recipients.row + 1, obj_recipients.colspan) contact_nb.set_value(_("Message defined for %d contacts") % nb_contact) xfer.add_component(contact_nb) lbl = XferCompLabelForm('sep_body') lbl.set_location(obj_recipients.col - 1, obj_recipients.row + 2, 4) lbl.set_value("{[hr/]}") xfer.add_component(lbl) xfer.remove_component('recipients') new_recipients.add_action_notified(xfer, 'recipient_list') xfer.add_component(new_recipients) return LucteriosEditor.show(self, xfer)
def get_read_comp(self): param_cmp = XferCompLabelForm(self.name) if self.type == 5: # password param_cmp.set_value(''.ljust(len(self.value), '*')) else: param_cmp.set_value(self.get_read_text()) return param_cmp
def conf_wizard_document(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("document_params", 55)) elif (xfer is not None) and (wizard_ident == "document_params"): xfer.add_title(_("Lucterios documents"), _("Parameters")) lbl = XferCompLabelForm("nb_folder") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value( TEXT_TOTAL_NUMBER % { 'name': Folder._meta.verbose_name_plural, 'count': len(Folder.objects.all()) }) xfer.add_component(lbl) lbl = XferCompLabelForm("nb_doc") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value( TEXT_TOTAL_NUMBER % { 'name': Document._meta.verbose_name_plural, 'count': len(Document.objects.all()) }) xfer.add_component(lbl) btn = XferCompButton("btnconf") btn.set_location(4, xfer.get_max_row() - 1, 1, 2) btn.set_action(xfer.request, FolderList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def fillresponse(self, item_name='', subject='', message='', model=0, withpayment=False): if item_name != '': self.item = Supporting.objects.get(id=self.getparam(item_name, 0)) self.item = self.item.get_final_child() if self.getparam("OK") is None: dlg = self.create_custom() icon = XferCompImage('img') icon.set_location(0, 0, 1, 6) icon.set_value(self.icon_path()) dlg.add_component(icon) lbl = XferCompLabelForm('lb_subject') lbl.set_value_as_name(_('subject')) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompEdit('subject') lbl.set_value(six.text_type(self.item)) lbl.set_location(2, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('lb_message') lbl.set_value_as_name(_('message')) lbl.set_location(1, 2) dlg.add_component(lbl) contact = self.item.third.contact.get_final_child() lbl = XferCompMemo('message') lbl.set_value(Params.getvalue('payoff-email-message') % { 'name': contact.get_presentation(), 'doc': self.item.get_docname()}) lbl.with_hypertext = True lbl.set_size(130, 450) lbl.set_location(2, 2) dlg.add_component(lbl) selectors = PrintModel.get_print_selector( 2, self.item.__class__)[0] lbl = XferCompLabelForm('lb_model') lbl.set_value_as_name(selectors[1]) lbl.set_location(1, 3) dlg.add_component(lbl) sel = XferCompSelect('model') sel.set_select(selectors[2]) sel.set_location(2, 3) dlg.add_component(sel) if self.item.payoff_have_payment() and (len(PaymentMethod.objects.all()) > 0): lbl = XferCompLabelForm('lb_withpayment') lbl.set_value_as_name(_('add payment methods in email')) lbl.set_location(1, 4) dlg.add_component(lbl) sel = XferCompCheck('withpayment') sel.set_value(True) sel.set_location(2, 4) dlg.add_component(sel) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"OK": "YES"}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: html_message = "<html>" html_message += message.replace('{[newline]}', '<br/>\n').replace('{[', '<').replace(']}', '>') if self.item.payoff_have_payment() and withpayment: html_message += get_html_payment(self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language, self.item) html_message += "</html>" self.item.send_email(subject, html_message, model)
def conf_wizard_condominium(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("condominium_params", 35)) wizard_ident.append(("condominium_owner", 45)) wizard_ident.append(("condominium_lot", 46)) wizard_ident.append(("condominium_classload", 47)) elif (xfer is not None) and (wizard_ident == "condominium_params"): xfer.add_title(_("Diacamma condominium"), _("Condominium configuration")) fill_params(xfer, True) elif (xfer is not None) and (wizard_ident == "condominium_owner"): xfer.add_title(_("Diacamma condominium"), _("Owners"), _('Add owners of your condominium.')) xfer.fill_grid(xfer.get_max_row(), Owner, 'owner', Owner.objects.all()) elif (xfer is not None) and (wizard_ident == "condominium_lot"): xfer.add_title(_("Diacamma condominium"), _("Property lots"), _('Define the lots for each owners.')) xfer.fill_grid(xfer.get_max_row(), PropertyLot, 'propertylot', PropertyLot.objects.all()) lbl = XferCompLabelForm("total_lot") lbl.set_location(0, xfer.get_max_row() + 1) lbl.set_value( _("Total of lot parts: %d") % PropertyLot.get_total_part()) xfer.add_component(lbl) elif (xfer is not None) and (wizard_ident == "condominium_classload"): xfer.add_title(_("Diacamma condominium"), _("Class loads"), _('Define the class loads of your condominium.')) xfer.fill_grid(xfer.get_max_row(), Set, 'set', Set.objects.all())
def finalizeyear_condo(xfer): year = FiscalYear.get_current(xfer.getparam('year')) if year is not None: ventilate = xfer.getparam("ventilate", 0) if xfer.observer_name == "core.custom": if year.check_to_close() > 0: raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!")) result = year.total_revenue - year.total_expense if abs(result) > 0.001: row = xfer.get_max_row() + 1 lbl = XferCompLabelForm('title_condo') lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5)) lbl.set_location(0, row, 2) xfer.add_component(lbl) lbl = XferCompLabelForm('question_condo') lbl.set_value(_('Where do you want to ventilate this amount?')) lbl.set_location(0, row + 1) xfer.add_component(lbl) sel_cmpt = [('0', _("For each owner"))] for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'): sel_cmpt.append((account.id, six.text_type(account))) sel = XferCompSelect("ventilate") sel.set_select(sel_cmpt) sel.set_value(ventilate) sel.set_location(1, row + 1) xfer.add_component(sel) elif xfer.observer_name == "core.acknowledge": for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0): if ventilate == 0: set_cost.set.ventilate_costaccounting(set_cost.cost_accounting, 1, Params.getvalue("condominium-current-revenue-account")) set_cost.cost_accounting.close() ventilate_result(year, ventilate)
def fillresponse(self): self.fields_desc.initial(self.item) self.read_criteria_from_params() self.fillresponse_add_title() self.fillresponse_search_select() self.fillresponse_search_values() self.fillresponse_show_criteria() row = self.get_max_row() if isinstance(self.filter, Q) and (len(self.filter.children) > 0): self.items = self.model.objects.filter( self.filter) else: self.items = self.model.objects.all() grid = XferCompGrid(self.field_id) grid.set_model(self.items, self.fieldnames, self) grid.add_actions(self, action_list=self.action_grid) grid.set_location(0, row + 4, 4) grid.set_size(200, 500) self.add_component(grid) lbl = XferCompLabelForm("nb") lbl.set_location(0, row + 5, 4) lbl.set_value(_("Total number of %(name)s: %(count)d") % { 'name': self.model._meta.verbose_name_plural, 'count': grid.nb_lines}) self.add_component(lbl) for act_type, title, icon in self.action_list: self.add_action(ActionsManage.get_act_changed( self.model.__name__, act_type, title, icon), {'close': CLOSE_NO}) self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
def finalizeyear_condo(xfer): year = FiscalYear.get_current(xfer.getparam('year')) if year is not None: ventilate = xfer.getparam("ventilate", 0) if xfer.observer_name == "core.custom": if year.check_to_close() > 0: raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!")) result = year.total_revenue - year.total_expense if abs(result) > 0.001: row = xfer.get_max_row() + 1 lbl = XferCompLabelForm('title_condo') lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5)) lbl.set_location(0, row, 2) xfer.add_component(lbl) lbl = XferCompLabelForm('question_condo') lbl.set_value(_('Where do you want to ventilate this amount?')) lbl.set_location(0, row + 1) xfer.add_component(lbl) sel_cmpt = [('0', _("For each owner"))] for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'): sel_cmpt.append((account.id, six.text_type(account))) sel = XferCompSelect("ventilate") sel.set_select(sel_cmpt) sel.set_value(ventilate) sel.set_location(1, row + 1) xfer.add_component(sel) elif xfer.observer_name == "core.acknowledge": for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0): if ventilate == 0: current_system_condo().ventilate_costaccounting(set_cost.set, set_cost.cost_accounting, 1, Params.getvalue("condominium-current-revenue-account")) set_cost.cost_accounting.close() current_system_condo().ventilate_result(year, ventilate)
def _add_season_comp(self, xfer, row): season = self.item.season if self.item.subscriptiontype.duration == 0: # annually lbl = XferCompLabelForm("seasondates") lbl.set_location(1, row) lbl.set_value( "%s => %s" % (formats.date_format(season.begin_date, "SHORT_DATE_FORMAT"), formats.date_format(season.end_date, "SHORT_DATE_FORMAT"))) lbl.description = _('annually') xfer.add_component(lbl) elif self.item.subscriptiontype.duration == 1: # periodic sel = XferCompSelect('period') sel.set_needed(True) sel.set_select_query(season.period_set.all()) sel.set_location(1, row) sel.description = _('period') xfer.add_component(sel) elif self.item.subscriptiontype.duration == 2: # monthly sel = XferCompSelect('month') sel.set_needed(True) sel.set_select(season.get_months()) sel.set_location(1, row) sel.description = _('month') xfer.add_component(sel) elif self.item.subscriptiontype.duration == 3: # calendar begindate = XferCompDate('begin_date') begindate.set_needed(True) begindate.set_value(season.date_ref) begindate.set_location(1, row) begindate.description = _('begin date') xfer.add_component(begindate)
def summary_dummy(xfer): if not hasattr(xfer, 'add_component'): return True else: row = xfer.get_max_row() + 1 lab = XferCompLabelForm('dummytitle') lab.set_value_as_infocenter("Dummy") lab.set_location(0, row, 4) xfer.add_component(lab) lbl = XferCompLabelForm('dummy_time') lbl.set_color('blue') lbl.set_location(0, row + 1, 4) lbl.set_centered() lbl.set_value(datetime.now()) lbl.set_format('H') xfer.add_component(lbl) btn = XferCompButton('btnscheduler') btn.set_action(xfer.request, AddSchedulerTask.get_action('Task', '')) btn.set_location(0, row + 2, 4) xfer.add_component(btn) lbl = XferCompLabelForm('dummy-value') lbl.set_location(0, row + 3, 4) lbl.set_value(Params.getvalue('dummy-value')) xfer.add_component(lbl) return True
def _entryline_editor(self, xfer, serial_vals, debit_rest, credit_rest): last_row = xfer.get_max_row() + 5 lbl = XferCompLabelForm('sep1') lbl.set_location(0, last_row, 6) lbl.set_value("{[center]}{[hr/]}{[/center]}") xfer.add_component(lbl) lbl = XferCompLabelForm('sep2') lbl.set_location(1, last_row + 1, 5) lbl.set_value_center(_("Add a entry line")) xfer.add_component(lbl) entry_line = EntryLineAccount() entry_line.editor.edit_line(xfer, 0, last_row + 2, debit_rest, credit_rest) if entry_line.has_account: btn = XferCompButton('entrybtn') btn.set_location(3, last_row + 5) btn.set_action(xfer.request, ActionsManage.get_action_url( 'accounting.EntryLineAccount', 'Add', xfer), close=CLOSE_YES) xfer.add_component(btn) self.item.editor.show(xfer) grid_lines = xfer.get_components('entrylineaccount') xfer.remove_component('entrylineaccount') new_grid_lines = XferCompGrid('entrylineaccount_serial') new_grid_lines.set_model(self.item.get_entrylineaccounts(serial_vals), None, xfer) new_grid_lines.set_location(grid_lines.col, grid_lines.row, grid_lines.colspan + 2, grid_lines.rowspan) new_grid_lines.add_action_notified(xfer, EntryLineAccount) xfer.add_component(new_grid_lines) nb_lines = len(new_grid_lines.record_ids) return nb_lines
def add_document(self): old_item = self.item self.model = DocumentContainer self.item = DocumentContainer() last_row = self.get_max_row() + 5 lbl = XferCompLabelForm('sep1') lbl.set_location(0, last_row, 6) lbl.set_value("{[center]}{[hr/]}{[/center]}") self.add_component(lbl) lbl = XferCompLabelForm('sep2') lbl.set_location(0, last_row + 1, 2) lbl.set_value_as_infocenter(_("Add document")) self.add_component(lbl) self.fill_from_model(0, last_row + 3, False) self.remove_component('parent') btn_doc = XferCompButton('adddoc') btn_doc.set_location(1, last_row + 4) btn_doc.set_action(self.request, DocumentAddModify.get_action( TITLE_ADD, 'images/add.png'), params={ 'parent': self.current_folder, 'SAVE': 'YES' }, close=CLOSE_NO) self.add_component(btn_doc) self.model = AbstractContainer self.item = old_item
def _get_from_custom(self, request, *args, **kwargs): dlg = XferContainerCustom() dlg.request = self.request dlg.is_view_right = self.is_view_right dlg.caption = self.caption dlg.extension = self.extension dlg.action = self.action img_title = XferCompImage('img_title') img_title.set_location(0, 0, 1, 2) img_title.set_value(self.traitment_data[0]) dlg.add_component(img_title) lbl = XferCompLabelForm("info") lbl.set_location(1, 0) dlg.add_component(lbl) if self.getparam("RELOAD") is not None: lbl.set_value( "{[br/]}{[center]}" + six.text_type(self.traitment_data[2]) + "{[/center]}") dlg.add_action(WrapAction(_("Close"), "images/close.png"), {}) else: lbl.set_value( "{[br/]}{[center]}" + six.text_type(self.traitment_data[1]) + "{[/center]}") btn = XferCompButton("Next") btn.set_location(1, 1) btn.set_size(50, 300) btn.set_action(self.request, self.get_action( _('Traitment...'), ""), {'params': {"RELOAD": "YES"}}) btn.java_script = "parent.refresh()" dlg.params["RELOAD"] = "YES" dlg.add_component(btn) dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"), {}) return dlg.get(request, *args, **kwargs)
def conf_wizard_contacts(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("contacts_current", 5)) wizard_ident.append(("contacts_params", 40)) wizard_ident.append(("contacts_responsable", 41)) elif (xfer is not None) and (wizard_ident == "contacts_current"): xfer.add_title(_("Lucterios contacts"), _("Our details"), _('configure our details')) xfer.model = LegalEntity xfer.item = LegalEntity.objects.get(id=1) xfer.fill_from_model(1, xfer.get_max_row() + 1, True, desc_fields=LegalEntity.get_show_fields()[_('001@Identity')]) xfer.remove_component('structure_type') btn = XferCompButton("btnconf") btn.set_location(2, xfer.get_max_row() + 1) btn.set_is_mini(True) btn.set_action(xfer.request, CurrentStructureAddModify.get_action('', "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn) elif (xfer is not None) and (wizard_ident == "contacts_params"): xfer.add_title(_("Lucterios contacts"), _("Contacts configuration"), _('configure your contacts')) param_lists = ['contacts-mailtoconfig', 'contacts-createaccount'] Params.fill(xfer, param_lists, 1, xfer.get_max_row() + 1) btn = XferCompButton('editparam') btn.set_location(4, xfer.get_max_row()) btn.set_is_mini(True) btn.set_action(xfer.request, ParamEdit.get_action(TITLE_MODIFY, 'images/edit.png'), close=CLOSE_NO, params={'params': param_lists}) xfer.add_component(btn) lbl = XferCompLabelForm("nb_function") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': Function._meta.verbose_name_plural, 'count': len(Function.objects.all())}) xfer.add_component(lbl) lbl = XferCompLabelForm("nb_structuretype") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': StructureType._meta.verbose_name_plural, 'count': len(StructureType.objects.all())}) xfer.add_component(lbl) lbl = XferCompLabelForm("nb_customfield") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': CustomField._meta.verbose_name_plural, 'count': len(CustomField.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btnconf") btn.set_location(4, xfer.get_max_row() - 2, 1, 3) btn.set_action(xfer.request, Configuration.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn) lbl = XferCompLabelForm("nb_legalentity") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LegalEntity._meta.verbose_name_plural, 'count': len(LegalEntity.objects.all())}) xfer.add_component(lbl) lbl = XferCompLabelForm("nb_individual") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': Individual._meta.verbose_name_plural, 'count': len(Individual.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btnimport") btn.set_location(4, xfer.get_max_row() - 1, 1, 2) btn.set_action(xfer.request, ContactImport.get_action(_("Contact import"), "images/add.png"), close=CLOSE_NO, params={'step': 0}) xfer.add_component(btn) elif (xfer is not None) and (wizard_ident == "contacts_responsable"): xfer.add_title(_("Lucterios contacts"), _('associates'), _('configure your association')) xfer.params['legal_entity'] = 1 xfer.fill_grid(5, Responsability, "responsability", Responsability.objects.filter(legal_entity_id=1))
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(self): XferListEditor.fillresponse(self) self.new_tab(_("Property lots")) self.fill_grid(self.get_max_row(), PropertyLot, 'propertylot', PropertyLot.objects.all()) lbl_nb = self.get_components('nb_propertylot') lbl_nb.colspan = 1 lbl = XferCompLabelForm("total_lot") lbl.set_location(lbl_nb.col + 1, lbl_nb.row) lbl.set_value(_("Total of lot parts: %d") % PropertyLot.get_total_part()) self.add_component(lbl)
def fillresponse(self): if self.getparam("CONVERT") is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0) dlg.add_component(lbl) year_list = [ "{[i]} - %s{[/i]}" % year for year in FiscalYear.objects.filter( status__in=(FiscalYear.STATUS_BUILDING, FiscalYear.STATUS_RUNNING)) ] lab = XferCompLabelForm('info') lab.set_value( _("This conversion tool will change your account to respect French law about condominium.{[br/]}For the no-closed fiscal years:{[newline]}%s{[newline]}It will do:{[newline]} - To change accounting code for each owners.{[newline]} - To de-validate all your entity.{[br/]} - To delete all entity link to call of funds or expenses.{[br/]} - To de-archive call of funds or expenses.{[br/]} - To generate correct account for call of funds or expenses.{[br/]}{[center]}{[u]}{[b]}Warning: This action is definitive.{[/b]}{[/u]}{[center]}" ) % '{[br/]}'.join(year_list)) lab.set_location(0, 1, 4) dlg.add_component(lab) dlg.new_tab(_("Third accounts")) self.fill_third_convert(dlg) dlg.new_tab(_("Parameters")) fill_params(dlg, True, True) dlg.add_action(self.return_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CONVERT': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: Parameter.change_value('condominium-old-accounting', False) Params.clear() try: thirds_convert = self.get_thirds_convert() for set_cost in SetCost.objects.filter( year__status=2, cost_accounting__status=0): set_cost.cost_accounting.is_protected = True set_cost.cost_accounting.save() if (set_cost.year.status == FiscalYear.STATUS_FINISHED ) and (set_cost.cost_accounting.status == CostAccounting.STATUS_OPENED): set_cost.cost_accounting.close() for owner in Owner.objects.all(): owner.check_account() for year in FiscalYear.objects.filter( status__in=(FiscalYear.STATUS_BUILDING, FiscalYear.STATUS_RUNNING)): convert_accounting(year, thirds_convert) except BaseException: Params.clear() raise self.message(_("Data converted"))
def summary_condo(xfer): if not hasattr(xfer, 'add_component'): return WrapAction.is_permission(xfer, 'condominium.change_set') else: if WrapAction.is_permission(xfer.request, 'condominium.change_set'): row = xfer.get_max_row() + 1 lab = XferCompLabelForm('condotitle') lab.set_value_as_infocenter(_('Condominium')) lab.set_location(0, row, 4) xfer.add_component(lab) nb_set = len(Set.objects.filter(is_active=True)) nb_owner = len(Owner.objects.all()) lab = XferCompLabelForm('condoinfo') lab.set_value_as_header( _("There are %(set)d classes of loads for %(owner)d owners") % { 'set': nb_set, 'owner': nb_owner }) lab.set_location(0, row + 1, 4) xfer.add_component(lab) if Params.getvalue("condominium-old-accounting"): lab = XferCompLabelForm('condoconvinfo') lab.set_value_as_header( _("Your condominium account is not in respect of French law{[newline]}An conversion is necessary." )) lab.set_color('red') lab.set_location(0, row + 2, 4) xfer.add_component(lab) btn = XferCompButton('condoconv') btn.set_location(0, row + 3, 4) btn.set_action(xfer.request, CondominiumConvert.get_action( _('Convertion ...'), ""), close=CLOSE_NO) xfer.add_component(btn) if hasattr(settings, "DIACAMMA_MAXOWNER"): lbl = XferCompLabelForm("limit_owner") lbl.set_value( _('limitation: %d owners allowed') % getattr(settings, "DIACAMMA_MAXOWNER")) lbl.set_italic() lbl.set_location(0, row + 4, 4) xfer.add_component(lbl) row = xfer.get_max_row() + 1 lab = XferCompLabelForm('condosep') lab.set_value_as_infocenter("{[hr/]}") lab.set_location(0, row, 4) xfer.add_component(lab) return True else: return False
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 summary_dummy(xfer): row = xfer.get_max_row() + 1 lab = XferCompLabelForm('dummytitle') lab.set_value_as_infocenter("Dummy") lab.set_location(0, row, 4) xfer.add_component(lab) lbl = XferCompLabelForm('dummy_time') lbl.set_color('blue') lbl.set_location(0, row + 1, 4) lbl.set_centered() lbl.set_value(datetime.now().ctime()) xfer.add_component(lbl) return True
def create_dlg(self, username, legalentity): dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) dlg.fill_from_model(1, 0, False, ['genre', 'lastname', 'firstname', 'email']) dlg.get_components( 'email' ).mask = '^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$' row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("username_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_('username')) dlg.add_component(lbl) edt = XferCompEdit("username") edt.set_location(2, row) edt.set_needed(True) edt.set_value(username) dlg.add_component(edt) if Params.getvalue("contacts-createaccount") == 2: row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("legalentity_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_("your structure name")) dlg.add_component(lbl) edt = XferCompEdit("legalentity") edt.set_location(2, row) edt.set_needed(True) edt.set_value(legalentity) dlg.add_component(edt) row = dlg.get_max_row() + 1 lbl = XferCompLabelForm("captcha_lbl") lbl.set_location(1, row) lbl.set_value_as_name(_("captcha")) dlg.add_component(lbl) edt = XferCompCaptcha("captcha") edt.set_location(2, row) dlg.add_component(edt) lbl = XferCompLabelForm("error_lbl") lbl.set_location(2, row + 1) lbl.set_color('red') lbl.set_value(self.getparam('error', '')) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
def fillresponse(self): img_title = XferCompImage('img') img_title.set_location(0, 0, 1, 10) img_title.set_value(self.icon_path()) self.add_component(img_title) lab = XferCompLabelForm('title') lab.set_location(1, 0, 3) lab.set_value( '{[br/]}{[center]}{[b]}{[u]}%s{[/u]}{[/b]}{[/center]}' % _("Software configuration")) self.add_component(lab) self.params['params'] = [] signal_and_lock.Signal.call_signal("config", self) self.add_action( ParamEdit.get_action(_('Modify'), 'images/edit.png'), {'close': 0}) self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
def conf_wizard_core(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("core_home", 0)) wizard_ident.append(("core_users", 100)) elif (xfer is not None) and (wizard_ident == "core_home"): initial_wizard = Params.getvalue("CORE-Wizard") param_wizard = xfer.getparam("CORE-Wizard", initial_wizard) if initial_wizard != param_wizard: Parameter.change_value("CORE-Wizard", param_wizard) Params.clear() lbl = XferCompLabelForm('title') lbl.set_centered() lbl.set_value_as_info(six.text_type(settings.APPLIS_NAME)) lbl.set_location(0, 3, 6) xfer.add_component(lbl) lbl = XferCompImage('img') lbl.type = 'jpg' lbl.set_value(settings.APPLIS_LOGO) lbl.set_location(2, 4, 2) xfer.add_component(lbl) lbl = XferCompLabelForm('home') lbl.set_value(_('This wizard will help you to configure this software.')) lbl.set_location(0, 5, 6) xfer.add_component(lbl) Params.fill(xfer, ['CORE-Wizard'], 1, 6, False) check = xfer.get_components("CORE-Wizard") check.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) lbl = XferCompLabelForm('lbl_wizard') lbl.set_value_as_name(check.description) lbl.set_location(2, 6) xfer.add_component(lbl) check.description = "" elif (xfer is not None) and (wizard_ident == "core_users"): xfer.add_title(six.text_type(settings.APPLIS_NAME), _("Groups and users")) param_lists = ['CORE-connectmode', 'CORE-Wizard'] Params.fill(xfer, param_lists, 1, xfer.get_max_row() + 1) btn = XferCompButton('editparam') btn.set_location(4, xfer.get_max_row()) btn.set_is_mini(True) btn.set_action(xfer.request, ParamEdit.get_action(TITLE_MODIFY, 'images/edit.png'), close=CLOSE_NO, params={'params': param_lists}) xfer.add_component(btn) lbl = XferCompLabelForm("nb_user") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosUser._meta.verbose_name_plural, 'count': len(LucteriosUser.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btnusers") btn.set_location(4, xfer.get_max_row()) btn.set_action(xfer.request, UsersList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn) lbl = XferCompLabelForm("nb_group") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': LucteriosGroup._meta.verbose_name_plural, 'count': len(LucteriosGroup.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btngroups") btn.set_location(4, xfer.get_max_row()) btn.set_action(xfer.request, GroupsList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def conf_wizard_mailing(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("mailing_params", 52)) elif (xfer is not None) and (wizard_ident == "mailing_params"): xfer.add_title(_("Lucterios mailing"), _("Mailing parameters")) lbl = XferCompLabelForm("nb_mail_send") lbl.set_location(1, xfer.get_max_row() + 1) xfer.add_component(lbl) if will_mail_send(): lbl.set_value(_('email properly configured')) else: lbl.set_value(_('email not configured')) btn = XferCompButton("btnconf") btn.set_location(3, xfer.get_max_row()) btn.set_action(xfer.request, Configuration.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def fill_grid(self, row, model, field_id, items): grid = XferCompGrid(field_id) if self.multi_page: xfer = self else: xfer = None grid.set_model(items, self.fieldnames, xfer) grid.add_actions(self, action_list=self.action_grid, model=model) grid.set_location(0, row + 1, 2) grid.set_size(200, 500) self.add_component(grid) lbl = XferCompLabelForm("nb_" + field_id) lbl.set_location(0, row + 2, 2) lbl.set_value(_("Total number of %(name)s: %(count)d") % { 'name': model._meta.verbose_name_plural, 'count': grid.nb_lines}) self.add_component(lbl)
def fillresponse(self): XferListEditor.fillresponse(self) lbl = XferCompLabelForm("result") lbl.set_value_center(self.item.year.total_result_text) lbl.set_location(0, 10, 2) self.add_component(lbl) accompt_returned = [] all_codes = list(self.item.year.chartsaccount_set.all().values_list('code', flat=True)) all_codes.append('') Signal.call_signal("compte_no_found", all_codes, accompt_returned) lbl = XferCompLabelForm("CompteNoFound") if len(accompt_returned) > 0: lbl.set_value("{[u]}{[b]}%s{[/b]}{[/u]}{[br]}%s" % (_("Using codes unknows in this account chart:"), "{[br/]}".join(accompt_returned))) lbl.set_location(0, 11, 2) self.add_component(lbl)
def conf_wizard_mailing(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("mailing_params", 52)) elif (xfer is not None) and (wizard_ident == "mailing_params"): xfer.add_title(_("Lucterios mailing"), _("Mailing parameters")) lbl = XferCompLabelForm("nb_mail_send") lbl.set_location(1, xfer.get_max_row() + 1) xfer.add_component(lbl) if will_mail_send(): lbl.set_value(_('email properly configured')) else: lbl.set_value(_('email not configured')) btn = XferCompButton("btnconf") btn.set_location(3, xfer.get_max_row()) btn.set_action(xfer.request, Configuration.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def add_title(self, title, subtitle, helptext=''): lbl = XferCompLabelForm('title') lbl.set_centered() lbl.set_value_as_info(title) lbl.set_location(0, 3, 6) self.add_component(lbl) lbl = XferCompLabelForm('subtitle') lbl.set_centered() lbl.set_value_as_name(subtitle) lbl.set_location(0, 4, 6) self.add_component(lbl) lbl = XferCompLabelForm('help') lbl.set_italic() lbl.set_value(helptext + "{[br/]}") lbl.set_location(0, 5, 6) self.add_component(lbl)
def fill_dlg(self): self.item.can_be_valid() dlg = self.create_custom() dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) dlg.fill_from_model(1, 1, True, ['activity', 'date']) dlg.get_components('activity').colspan = 3 dlg.get_components('date').colspan = 3 lbl = XferCompLabelForm('sep') lbl.set_value("{[hr/]}") lbl.set_location(0, 4, 7) dlg.add_component(lbl) row_id = 5 for participant in self.item.participant_set.all(): lbl = XferCompLabelForm('name_%d' % participant.id) lbl.set_value_as_name(six.text_type(participant)) lbl.set_location(0, row_id) dlg.add_component(lbl) lbl = XferCompLabelForm('current_%d' % participant.id) lbl.set_value(participant.current_degree) lbl.set_location(1, row_id) dlg.add_component(lbl) sel = XferCompSelect('degree_%d' % participant.id) sel.set_select_query(participant.allow_degree()) sel.set_location(2, row_id) dlg.add_component(sel) if Params.getvalue("event-subdegree-enable") == 1: sel = XferCompSelect('subdegree_%d' % participant.id) sel.set_select_query(participant.allow_subdegree()) sel.set_location(3, row_id) dlg.add_component(sel) edt = XferCompMemo('comment_%d' % participant.id) edt.set_value(participant.comment) edt.set_location(4, row_id) dlg.add_component(edt) row_id += 1 dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
def fillresponse(self): if self.getparam("CONFIRME") is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_record') lbl.set_value_as_name(_('record')) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('record') lbl.set_value(six.text_type(self.item)) lbl.set_location(2, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_current') lbl.set_value_as_name(_('current model')) lbl.set_location(1, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('current') lbl.set_value(self.item.__class__._meta.verbose_name) lbl.set_location(2, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_newmodel') lbl.set_value_as_name(_('new model')) lbl.set_location(1, 3) dlg.add_component(lbl) lbl = XferCompSelect('newmodel') lbl.set_select(self.item.__class__.get_select_contact_type(False)) lbl.set_location(2, 3) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), {'close': CLOSE_YES, 'modal': FORMTYPE_MODAL, 'params': {'CONFIRME': 'YES'}}) dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"), {}) else: new_model = apps.get_model(self.getparam('newmodel')) field_id_name = "%s_ptr_id" % self.model.__name__.lower() new_object = new_model(**{field_id_name: self.item.pk}) new_object.save() new_object.__dict__.update(self.item.__dict__) new_object.save() self.redirect_action( ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {})
def fillresponse(self): XferListEditor.fillresponse(self) if hasattr(settings, "DIACAMMA_MAXOWNER"): grid = self.get_components("owner") if getattr(settings, "DIACAMMA_MAXOWNER") <= grid.nb_lines: grid.delete_action("diacamma.condominium/ownerAdd") lbl = XferCompLabelForm("limit_activity") lbl.set_color('red') lbl.set_value_as_headername(_('You have the maximum of owners!')) lbl.set_location(grid.col, self.get_max_row() + 1) self.add_component(lbl) self.new_tab(_("Property lots")) self.fill_grid(self.get_max_row(), PropertyLot, 'propertylot', PropertyLot.objects.all()) lbl = XferCompLabelForm("total_lot") lbl.set_location(1, 5) lbl.set_value(_("Total of lot parts: %d") % PropertyLot.get_total_part()) self.add_component(lbl)
def conf_wizard_document(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("document_params", 55)) elif (xfer is not None) and (wizard_ident == "document_params"): xfer.add_title(_("Lucterios documents"), _("Parameters")) lbl = XferCompLabelForm("nb_folder") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': Folder._meta.verbose_name_plural, 'count': len(Folder.objects.all())}) xfer.add_component(lbl) lbl = XferCompLabelForm("nb_doc") lbl.set_location(1, xfer.get_max_row() + 1) lbl.set_value(TEXT_TOTAL_NUMBER % {'name': Document._meta.verbose_name_plural, 'count': len(Document.objects.all())}) xfer.add_component(lbl) btn = XferCompButton("btnconf") btn.set_location(4, xfer.get_max_row() - 1, 1, 2) btn.set_action(xfer.request, FolderList.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO) xfer.add_component(btn)
def summary_condo(xfer): is_right = WrapAction.is_permission(xfer.request, 'condominium.change_set') owners = get_owners(xfer.request) if is_right or (len(owners) == 1): row = xfer.get_max_row() + 1 lab = XferCompLabelForm('condotitle') lab.set_value_as_infocenter(_('Condominium')) lab.set_location(0, row, 4) xfer.add_component(lab) if len(owners) == 1: lab = XferCompLabelForm('condoowner') lab.set_value(_('You are a owner')) lab.set_location(0, row + 1, 2) xfer.add_component(lab) grid = XferCompGrid("part") grid.set_model(owners[0].partition_set.filter(set__is_active=True), ["set", "value", (_("ratio"), 'ratio')]) grid.set_location(0, row + 2, 4) grid.set_size(200, 500) xfer.add_component(grid) if is_right: row = xfer.get_max_row() + 1 nb_set = len(Set.objects.filter(is_active=True)) nb_owner = len(Owner.objects.all()) lab = XferCompLabelForm('condoinfo') lab.set_value_as_header(_("There are %(set)d classes of loads for %(owner)d owners") % {'set': nb_set, 'owner': nb_owner}) lab.set_location(0, row + 1, 4) xfer.add_component(lab) if Params.getvalue("condominium-old-accounting"): lab = XferCompLabelForm('condoconvinfo') lab.set_value_as_header(_("Your condominium account is not in respect of French law{[newline]}An conversion is necessary.")) lab.set_color('red') lab.set_location(0, row + 2, 4) xfer.add_component(lab) btn = XferCompButton('condoconv') btn.set_location(0, row + 3, 4) btn.set_action(xfer.request, CondominiumConvert.get_action(_('Convertion ...'), ""), close=CLOSE_NO) xfer.add_component(btn) if is_right or (len(owners) == 1): row = xfer.get_max_row() + 1 lab = XferCompLabelForm('condosep') lab.set_value_as_infocenter("{[hr/]}") lab.set_location(0, row, 4) xfer.add_component(lab) return True else: return False
def fillresponse_search_values(self): comp = XferCompButton("searchButtonAdd") comp.is_default = True comp.set_is_mini(True) comp.set_location(4, 10, 1, 7) comp.set_action(self.request, self.get_action("", "images/add.png"), modal=FORMTYPE_REFRESH, close=CLOSE_NO, params={'ACT': 'ADD'}) self.add_component(comp) comp = XferCompDate("searchValueDate") comp.set_needed(True) comp.set_location(3, 11) comp.set_size(20, 200) self.add_component(comp) comp = XferCompFloat("searchValueFloat") comp.set_needed(True) comp.set_location(3, 12) comp.set_size(20, 200) self.add_component(comp) comp = XferCompEdit("searchValueStr") comp.set_location(3, 13) comp.set_size(20, 200) self.add_component(comp) comp = XferCompCheckList("searchValueList") comp.set_location(3, 14) comp.set_size(80, 200) self.add_component(comp) comp = XferCompCheck("searchValueBool") comp.set_location(3, 15) comp.set_size(20, 200) self.add_component(comp) comp = XferCompTime("searchValueTime") comp.set_needed(True) comp.set_location(3, 16) comp.set_size(20, 200) self.add_component(comp) label = XferCompLabelForm('labelsearchSep') label.set_value("") label.set_size(1, 200) label.set_location(3, 17) self.add_component(label)
def fillresponse(self): if self.getparam("CONFIRME") is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_record') lbl.set_value_as_name(_('record')) lbl.set_location(1, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('record') lbl.set_value(six.text_type(self.item)) lbl.set_location(2, 1) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_current') lbl.set_value_as_name(_('current model')) lbl.set_location(1, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('current') lbl.set_value(self.item.__class__._meta.verbose_name) lbl.set_location(2, 2) dlg.add_component(lbl) lbl = XferCompLabelForm('lbl_newmodel') lbl.set_value_as_name(_('new model')) lbl.set_location(1, 3) dlg.add_component(lbl) lbl = XferCompSelect('newmodel') lbl.set_select(self.item.__class__.get_select_contact_type(False)) lbl.set_location(2, 3) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png")) else: new_model = apps.get_model(self.getparam('newmodel')) field_id_name = "%s_ptr_id" % self.model.__name__.lower() new_object = new_model(**{field_id_name: self.item.pk}) new_object.save() new_object.__dict__.update(self.item.__dict__) new_object.save() self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self))
def fill_header(self): CondominiumReport.fill_header(self) self.next_year = self.item.next_fiscalyear.first() if self.next_year is not None: lbl = XferCompLabelForm('yearn1') lbl.set_location(1, 2, 3) lbl.set_value(six.text_type(self.next_year)) lbl.description = _('year N+1') self.add_component(lbl) self.next_year_again = self.next_year.next_fiscalyear.first() if self.next_year_again is not None: lbl = XferCompLabelForm('yearn2') lbl.set_location(1, 3, 3) lbl.description = _('year N+2') lbl.set_value(six.text_type(self.next_year_again)) self.add_component(lbl) else: self.next_year_again = None
def _show_initial_csv(self): tbl = XferCompGrid('CSV') for fieldname in self.spamreader.fieldnames: if fieldname != '': tbl.add_header(fieldname, fieldname) row_idx = 1 for row in self.spamreader: if row[self.spamreader.fieldnames[0]] is not None: for fieldname in self.spamreader.fieldnames: if fieldname != '': tbl.set_value(row_idx, fieldname, row[fieldname]) row_idx += 1 tbl.set_location(1, 1, 2) self.add_component(tbl) lbl = XferCompLabelForm('nb_line') lbl.set_value(_("Total number of items: %d") % (row_idx - 1)) lbl.set_location(1, 2, 2) self.add_component(lbl)
def fill_third_convert(self, dlg): lbl = XferCompLabelForm('tle_third') lbl.set_value(_('How do want to convert owner third account?')) lbl.set_location(0, 0, 2) dlg.add_component(lbl) select_account = [('', None)] for num_account in range(1, 6): owner_account = correct_accounting_code(Params.getvalue('condominium-default-owner-account%d' % num_account)) select_account.append((owner_account, owner_account)) row = 1 for code_item in AccountThird.objects.filter(code__regex=r"^45[0-9a-zA-Z]*$", third__status=0).values_list('code').distinct(): sel = XferCompSelect('code_' + code_item[0]) sel.set_location(0, row) sel.description = code_item[0] sel.set_value(dlg.getparam('code_' + code_item[0], "")) sel.set_select(select_account) dlg.add_component(sel) row += 1
def fill_current_folder(self, new_col, new_row): lbl = XferCompLabelForm('title_folder') if self.current_folder > 0: folder_obj = FolderContainer.objects.get(id=self.current_folder) lbl.set_value(folder_obj.get_title()) folder_description = folder_obj.description else: folder_obj = None lbl.set_value('>') folder_description = "" lbl.set_location(new_col, new_row) lbl.description = _("current folder:") self.add_component(lbl) lbl = XferCompLabelForm('desc_folder') lbl.set_value_as_header(folder_description) lbl.set_location(new_col, new_row + 1) self.add_component(lbl) if self.current_folder > 0: btn_return = XferCompButton('return') btn_return.set_location(new_col + 1, new_row) btn_return.set_is_mini(True) btn_return.set_action(self.request, self.get_action('', 'images/left.png'), params={ 'current_folder': self.item.parent_id if self.item.parent_id is not None else 0 }, modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(btn_return) btn_edit = XferCompButton('edit') btn_edit.set_location(new_col + 1, new_row + 1) btn_edit.set_is_mini(True) btn_edit.set_action(self.request, FolderAddModify.get_action( '', 'images/edit.png'), params={'folder': self.current_folder}, close=CLOSE_NO) self.add_component(btn_edit) return folder_obj
def fillresponse(self, journal=0): if self.getparam('SAVE') is None: dlg = self.create_custom() image = XferCompImage('image') image.set_value(self.icon_path()) image.set_location(0, 0, 1, 6) dlg.add_component(image) lbl = XferCompLabelForm('lblmodel') lbl.set_value(_('model name')) lbl.set_location(1, 0) dlg.add_component(lbl) if journal > 0: mod_query = ModelEntry.objects.filter(journal=journal) else: mod_query = ModelEntry.objects.all() sel = XferCompSelect('model') sel.set_location(2, 0) sel.set_needed(True) sel.set_select_query(mod_query) dlg.add_component(sel) lbl = XferCompLabelForm('lblfactor') lbl.set_value(_('factor')) lbl.set_location(1, 1) dlg.add_component(lbl) fact = XferCompFloat('factor', 0.00, 1000000.0, 2) fact.set_value(1.0) fact.set_location(2, 1) dlg.add_component(fact) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: factor = self.getparam('factor', 1.0) model = ModelEntry.objects.get(id=self.getparam('model', 0)) for old_key in ['SAVE', 'model', 'factor']: if old_key in self.params.keys(): del self.params[old_key] year = FiscalYear.get_current(self.getparam('year')) serial_entry = model.get_serial_entry(factor, year) date_value = date.today().isoformat() entry = EntryAccount.objects.create(year=year, date_value=date_value, designation=model.designation, journal=model.journal, costaccounting=model.costaccounting) entry.editor.before_save(self) self.params["entryaccount"] = entry.id self.redirect_action(EntryAccountEdit.get_action(), params={"serial_entry": serial_entry})
def fill_dlg(self): self.item.can_be_valid() dlg = self.create_custom() dlg.item = self.item img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) dlg.add_component(lbl) dlg.fill_from_model(1, 1, True, ['activity', 'date']) lbl = XferCompLabelForm('sep') lbl.set_value("{[hr/]}") lbl.set_location(0, 4, 7) dlg.add_component(lbl) row_id = 5 for participant in self.item.participant_set.all(): lbl = XferCompLabelForm('name_%d' % participant.id) lbl.set_value_as_name(six.text_type(participant)) lbl.set_location(0, row_id) dlg.add_component(lbl) lbl = XferCompLabelForm('current_%d' % participant.id) lbl.set_value(participant.current_degree) lbl.set_location(1, row_id) dlg.add_component(lbl) sel = XferCompSelect('degree_%d' % participant.id) sel.set_select_query(participant.allow_degree()) sel.set_location(2, row_id) dlg.add_component(sel) if Params.getvalue("event-subdegree-enable") == 1: sel = XferCompSelect('subdegree_%d' % participant.id) sel.set_select_query(participant.allow_subdegree()) sel.set_location(3, row_id) dlg.add_component(sel) edt = XferCompMemo('comment_%d' % participant.id) edt.set_value(participant.comment) edt.set_location(4, row_id) dlg.add_component(edt) row_id += 1 dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
def fillresponse(self): if self.getparam("CONVERT") is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) dlg.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0) dlg.add_component(lbl) year_list = ["{[i]} - %s{[/i]}" % year for year in FiscalYear.objects.filter(status__lt=2)] lab = XferCompLabelForm('info') lab.set_value( _("This conversion tool will change your account to respect French law about condominium.{[br/]}For the no-closed fiscal years:{[newline]}%s{[newline]}It will do:{[newline]} - To change accounting code for each owners.{[newline]} - To de-validate all your entity.{[br/]} - To delete all entity link to call of funds or expenses.{[br/]} - To de-archive call of funds or expenses.{[br/]} - To generate correct account for call of funds or expenses.{[br/]}{[center]}{[u]}{[b]}Warning: This action is definitive.{[/b]}{[/u]}{[center]}") % '{[br/]}'.join(year_list)) lab.set_location(0, 1, 4) dlg.add_component(lab) dlg.new_tab(_("Third accounts")) self.fill_third_convert(dlg) dlg.new_tab(_("Parameters")) fill_params(dlg, True, True) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={'CONVERT': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: Parameter.change_value('condominium-old-accounting', False) Params.clear() try: thirds_convert = self.get_thirds_convert() for set_cost in SetCost.objects.filter(year__status=2, cost_accounting__status=0): set_cost.cost_accounting.is_protected = True set_cost.cost_accounting.save() if (set_cost.year.status == 2) and (set_cost.cost_accounting.status == 0): set_cost.cost_accounting.close() for owner in Owner.objects.all(): for num_account in range(1, 5): AccountThird.objects.create(third=owner.third, code=correct_accounting_code(Params.getvalue("condominium-default-owner-account%d" % num_account))) for year in FiscalYear.objects.filter(status__lt=2): convert_accounting(year, thirds_convert) except: Params.clear() raise self.message(_("Data converted"))
def fillresponse(self): editor = self.item.get_doc_editors() if self.getparam('SAVE', '') == 'YES': editor.save_content() elif self.getparam('CLOSE', '') == 'YES': editor.close() else: editor.send_content() dlg = self.create_custom(self.model) dlg.item = self.item dlg.fill_from_model(0, 0, True, [('parent', 'name')]) frame = XferCompLabelForm('frame') frame.set_value(editor.get_iframe()) frame.set_location(0, 2, 2, 0) dlg.add_component(frame) dlg.add_action(self.get_action(TITLE_SAVE, 'images/save.png'), close=CLOSE_NO, params={'SAVE': 'YES'}) dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png')) dlg.set_close_action(self.get_action(), params={'CLOSE': 'YES'})
def fill_header(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) lbl = XferCompLabelForm('lblname') lbl.set_value_as_name( self.model._meta.verbose_name) lbl.set_location(1, 2) self.add_component(lbl) lbl = XferCompLabelForm('name') lbl.set_value(self.item) lbl.set_location(2, 2, 4) self.add_component(lbl) self.filltab_from_model(1, 6, True, [( (_('total revenue'), 'total_revenue'), (_('total expense'), 'total_expense'))]) self.filter = Q(entry__costaccounting=self.item) self.fill_filterCode() self.fill_filterheader() self.define_gridheader()
def fillresponse_search_values(self): comp = XferCompButton("searchButtonAdd") comp.set_is_mini(True) comp.set_location(4, 10, 1, 7) comp.set_action(self.request, self.get_action("", "images/add.png"), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO, 'params': {'ACT': 'ADD'}}) self.add_component(comp) comp = XferCompDate("searchValueDate") comp.set_needed(True) comp.set_location(3, 11) comp.set_size(20, 200) self.add_component(comp) comp = XferCompFloat("searchValueFloat") comp.set_needed(True) comp.set_location(3, 12) comp.set_size(20, 200) self.add_component(comp) comp = XferCompEdit("searchValueStr") comp.set_location(3, 13) comp.set_size(20, 200) self.add_component(comp) comp = XferCompCheckList("searchValueList") comp.set_location(3, 14) comp.set_size(80, 200) self.add_component(comp) comp = XferCompCheck("searchValueBool") comp.set_location(3, 15) comp.set_size(20, 200) self.add_component(comp) comp = XferCompTime("searchValueTime") comp.set_needed(True) comp.set_location(3, 16) comp.set_size(20, 200) self.add_component(comp) label = XferCompLabelForm('labelsearchSep') label.set_value("") label.set_size(1, 200) label.set_location(3, 17) self.add_component(label)
def change_select_to_label(self, cmp_name): old_obj = self.get_components(cmp_name) if isinstance(old_obj, XferCompSelect): value = old_obj.value if isinstance(old_obj.select_list, list): for key, sel_val in old_obj.select_list: if six.text_type(value) == six.text_type(key): value = sel_val break self.remove_component(cmp_name) self.tab = old_obj.tab new_lbl = XferCompLabelForm(cmp_name) new_lbl.set_value(value) new_lbl.col = old_obj.col new_lbl.row = old_obj.row new_lbl.vmin = old_obj.vmin new_lbl.hmin = old_obj.hmin new_lbl.colspan = old_obj.colspan new_lbl.rowspan = old_obj.rowspan new_lbl.description = old_obj.description self.add_component(new_lbl)
def fill_third_convert(self, dlg): lbl = XferCompLabelForm('tle_third') lbl.set_value(_('How do want to convert owner third account?')) lbl.set_location(0, 0, 2) dlg.add_component(lbl) select_account = [('', None)] for num_account in range(1, 5): owner_account = correct_accounting_code(Params.getvalue('condominium-default-owner-account%d' % num_account)) select_account.append((owner_account, owner_account)) row = 1 for code_item in AccountThird.objects.filter(code__regex=r"^45[0-9a-zA-Z]*$", third__status=0).values_list('code').distinct(): lbl = XferCompLabelForm('lbl_code_' + code_item[0]) lbl.set_value_as_name(code_item[0]) lbl.set_location(0, row) dlg.add_component(lbl) sel = XferCompSelect('code_' + code_item[0]) sel.set_location(1, row) sel.set_value(dlg.getparam('code_' + code_item[0], "")) sel.set_select(select_account) dlg.add_component(sel) row += 1
def fill_current_folder(self, new_col, new_row): lbl = XferCompLabelForm('lblcat') lbl.set_value_as_name(_("current folder:")) lbl.set_location(new_col, new_row) self.add_component(lbl) lbl = XferCompLabelForm('lbltitlecat') if self.current_folder > 0: folder_obj = Folder.objects.get(id=self.current_folder) lbl.set_value(folder_obj.get_title()) folder_description = folder_obj.description else: folder_obj = None lbl.set_value('>') folder_description = "" lbl.set_location(new_col + 1, new_row) self.add_component(lbl) lbl = XferCompLabelForm('lbldesc') lbl.set_value_as_header(folder_description) lbl.set_location(new_col + 2, new_row, 2) self.add_component(lbl) return folder_obj