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 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 fillresponse(self): img_title = XferCompImage('img') img_title.set_location(0, 0, 1, 6) img_title.set_value(self.icon_path()) self.add_component(img_title) lab = XferCompLabelForm('title') lab.set_location(1, 0, 2) lab.set_value_as_title(_("Print models")) self.add_component(lab) self.fill_from_model(1, 1, False, ['name']) self.fill_from_model(1, 2, True, ['kind']) self.item.mode = int(self.item.mode) if self.item.kind == 1: self.fill_from_model(1, 3, False, ['mode']) self.get_components('mode').set_action( self.request, self.get_action('', ''), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO}) if (self.item.mode == 1) and (self.item.value[:6] != '<model'): self.item.value = "<model>\n<body>\n<text>%s</text></body>\n</model>" % self.item.value if self.item.kind == 0: self._fill_listing_editor() elif (self.item.kind == 1) and (self.item.mode == 0): self._fill_label_editor() elif (self.item.kind == 2) or ((self.item.kind == 1) and (self.item.mode == 1)): self._fill_report_editor() self.add_action( PrintModelSave.get_action(_("ok"), "images/ok.png"), {}) self.add_action(WrapAction(_('cancel'), 'images/cancel.png'), {})
def fillresponse(self, limit_date=''): if limit_date == '': dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) lbl = XferCompLabelForm('lb_limit_date') lbl.set_value_as_name(_('limit date')) lbl.set_location(1, 1, 1) dlg.add_component(lbl) limite_date = XferCompDate('limit_date') limite_date.set_needed(True) limite_date.set_value((date.today() - timedelta(weeks=25))) limite_date.set_location(1, 2, 1) dlg.add_component(limite_date) dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: third_ids = [val_third['third'] for val_third in EntryLineAccount.objects.filter( entry__date_value__gt=limit_date, third__gt=0).values('third')] for third in Third.objects.filter(status=0): if third.id not in third_ids: third.status = 1 third.save()
def edit(self, xfer): if xfer.item.id is None: third = xfer.get_components('third') xfer.remove_component('third') xfer.remove_component('lbl_third') lbl = XferCompLabelForm('lbl_third') lbl.set_location(third.col - 1, third.row) lbl.set_value_as_name(_('third')) xfer.add_component(lbl) sel = XferCompSelect('third') sel.needed = True sel.set_location(third.col, third.row) owner_third_ids = [] for owner in Owner.objects.all(): owner_third_ids.append(owner.third_id) items = Third.objects.all().exclude(id__in=owner_third_ids).distinct() items = sorted(items, key=lambda t: six.text_type(t)) sel.set_select_query(items) xfer.add_component(sel) btn = XferCompButton('add_third') btn.set_location(3, 0) btn.set_is_mini(True) btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Add', xfer), close=CLOSE_NO, modal=FORMTYPE_MODAL, params={'new_account': Params.getvalue('condominium-default-owner-account')}) xfer.add_component(btn) else: xfer.change_to_readonly('third')
def edit(self, xfer): xfer.change_to_readonly('type_of_account') code_ed = xfer.get_components('code') code_ed.mask = current_system_account().get_general_mask() code_ed.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) descript, typeaccount = current_system_account().new_charts_account(self.item.code) error_msg = '' if typeaccount < 0: if typeaccount == -2: error_msg = _("Invalid code") if self.item.code != '': code_ed.set_value(self.item.code + '!') if self.item.id is None: xfer.get_components('type_of_account').set_value('---') elif self.item.id is None: field_type = self.item.get_field_by_name('type_of_account') xfer.get_components('type_of_account').set_value( get_value_if_choices(typeaccount, field_type)) xfer.get_components('name').set_value(descript) xfer.params['type_of_account'] = typeaccount elif typeaccount != self.item.type_of_account: error_msg = _("Changment not allowed!") code_ed.set_value(self.item.code + '!') lbl = XferCompLabelForm('error_code') lbl.set_location(1, xfer.get_max_row() + 1, 2) lbl.set_value_center("{[font color='red']}%s{[/font]}" % error_msg) xfer.add_component(lbl) return
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 show(self, xfer): if xfer.item.cost_accounting is None: xfer.remove_component("cost_accounting") xfer.remove_component("lbl_cost_accounting") xfer.params['new_account'] = Params.getvalue('invoice-account-third') xfer.move(0, 0, 1) lbl = XferCompLabelForm('title') lbl.set_location(1, 0, 4) lbl.set_value_as_title(get_value_if_choices( self.item.bill_type, self.item.get_field_by_name('bill_type'))) xfer.add_component(lbl) details = xfer.get_components('detail') if Params.getvalue("invoice-vat-mode") != 0: if Params.getvalue("invoice-vat-mode") == 1: details.headers[2] = XferCompHeader(details.headers[2].name, _( 'price excl. taxes'), details.headers[2].type, details.headers[2].orderable) details.headers[6] = XferCompHeader(details.headers[6].name, _( 'total excl. taxes'), details.headers[6].type, details.headers[6].orderable) elif Params.getvalue("invoice-vat-mode") == 2: details.headers[2] = XferCompHeader(details.headers[2].name, _( 'price incl. taxes'), details.headers[2].type, details.headers[2].orderable) details.headers[6] = XferCompHeader(details.headers[6].name, _( 'total incl. taxes'), details.headers[6].type, details.headers[6].orderable) xfer.get_components('lbl_total_excltax').set_value_as_name( _('total excl. taxes')) xfer.filltab_from_model(1, xfer.get_max_row() + 1, True, [((_('VTA sum'), 'vta_sum'), (_('total incl. taxes'), 'total_incltax'))]) if self.item.status == 0: SupportingEditor.show_third(self, xfer, 'invoice.add_bill') else: SupportingEditor.show_third_ex(self, xfer) details.actions = [] if self.item.bill_type != 0: SupportingEditor.show(self, xfer) return
def fillresponse_header(self): self.new_tab(_('Fiscal year list')) lbl = XferCompLabelForm('lbl_account_system') lbl.set_value_as_name(_('accounting system')) lbl.set_location(0, 1) self.add_component(lbl) select_account_system(self)
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 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_header(self): status_filter = self.getparam('status_filter', 0) self.params['status_filter'] = status_filter date_filter = self.getparam('date_filter', 0) self.fieldnames = Expense.get_default_fields(status_filter) lbl = XferCompLabelForm('lbl_status_filter') lbl.set_value_as_name(_('Filter by type')) lbl.set_location(0, 3) self.add_component(lbl) dep_field = self.item.get_field_by_name('status') sel_list = list(dep_field.choices) edt = XferCompSelect("status_filter") edt.set_select(sel_list) edt.set_value(status_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) lbl = XferCompLabelForm('lbl_date_filter') lbl.set_value_as_name(_('Filter by date')) lbl.set_location(0, 4) self.add_component(lbl) edt = XferCompSelect("date_filter") edt.set_select([(0, _('only current fiscal year')), (1, _('all expenses'))]) edt.set_value(date_filter) edt.set_location(1, 4) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) self.filter = Q(status=status_filter) if date_filter == 0: current_year = FiscalYear.get_current() self.filter &= Q(date__gte=current_year.begin) & Q(date__lte=current_year.end)
def thirdaddon_accounting(item, xfer): if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'): try: entry_lines_filter = Q(entrylineaccount__third=item) lines_filter = xfer.getparam('lines_filter', 0) if lines_filter == 0: entry_lines_filter &= Q(year=FiscalYear.get_current()) elif lines_filter == 1: entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False) xfer.new_tab(_('entry of account')) lbl = XferCompLabelForm('lbl_lines_filter') lbl.set_value_as_name(_('Accounts filter')) lbl.set_location(0, 1) xfer.add_component(lbl) edt = XferCompSelect("lines_filter") edt.set_select([(0, _('All entries of current fiscal year')), (1, _( 'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))]) edt.set_value(lines_filter) edt.set_location(1, 1) edt.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) xfer.add_component(edt) entries = EntryAccount.objects.filter(entry_lines_filter) link_grid_lines = XferCompGrid('entryaccount') link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer) link_grid_lines.set_location(0, 2, 2) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer), modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer), modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO) link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer), modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO) xfer.add_component(link_grid_lines) except LucteriosException: pass
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: 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_header(self): contact_filter = self.getparam('filter', '') show_filter = self.getparam('show_filter', 0) lbl = XferCompLabelForm('lbl_filtre') lbl.set_value_as_name(_('Filtrer by contact')) lbl.set_location(0, 2) self.add_component(lbl) comp = XferCompEdit('filter') comp.set_value(contact_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 2) self.add_component(comp) lbl = XferCompLabelForm('lbl_showing') lbl.set_value_as_name(_('Accounts displayed')) lbl.set_location(0, 3) self.add_component(lbl) edt = XferCompSelect("show_filter") edt.set_select([(0, _('Hide the account total of thirds')), (1, _('Show the account total of thirds')), (2, _('Filter any thirds unbalanced'))]) edt.set_value(show_filter) edt.set_location(1, 3) edt.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(edt) if show_filter != 0: self.fieldnames = Third.get_other_fields() self.filter = Q(status=0) if contact_filter != "": q_legalentity = Q(contact__legalentity__name__icontains=contact_filter) q_individual = (Q(contact__individual__firstname__icontains=contact_filter) | Q(contact__individual__lastname__icontains=contact_filter)) self.filter &= (q_legalentity | q_individual)
def fillresponse(self): self.action_list = [] if self.final_class is not None: self.add_action(self.final_class.get_action(TITLE_OK, "images/ok.png")) model_current = self.getparam('modelname') if model_current is None: self.model = self.inital_model else: self.model = apps.get_model(model_current) self.field_id = self.model.__name__.lower() if self.field_id == 'legalentity': self.field_id = 'legal_entity' self.item = self.model() XferSearchEditor.fillresponse(self) self.remove_component('title') lbl = XferCompLabelForm('modelname_lbl') lbl.set_value_as_title(_('model')) lbl.set_location(1, 0) self.add_component(lbl) selected_model = XferCompSelect('modelname') selected_model.set_value(model_current) selected_model.set_select(self.inital_model.get_select_contact_type()) selected_model.set_location(2, 0, 3) selected_model.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(selected_model) if self.select_class is not None: grid = self.get_components(self.field_id) grid.add_action(self.request, self.select_class.get_action(_("Select"), "images/ok.png"), close=CLOSE_YES, unique=self.mode_select, params={'pkname': self.field_id}, pos_act=0)
def fillresponse(self): img = XferCompImage('img') img.set_value(get_icon_path('lucterios.contacts/images/account.png')) img.set_location(0, 0, 1, 2) self.add_component(img) lab = XferCompLabelForm("title") lab.set_value_as_title(_('View my account.')) lab.set_location(1, 0, 2) self.add_component(lab) try: self.item = Individual.objects.get(user=self.request.user) self.item = self.item.get_final_child() self.model = Individual self.field_id = 'individual' self.params['individual'] = six.text_type(self.item.id) self.add_action(AccountAddModify.get_action(_("Edit"), "images/edit.png"), close=CLOSE_NO) is_individual = True except ObjectDoesNotExist: self.item = LucteriosUser.objects.get(id=self.request.user.id) self.add_action(UsersEdit.get_action(_("Edit"), "images/edit.png"), close=CLOSE_NO, params={'user_actif': six.text_type(self.request.user.id)}) is_individual = False self.fill_from_model(1, 1, True) if is_individual: legal_entities = LegalEntity.objects.filter(responsability__individual=self.item).exclude(id=1) if len(legal_entities) == 1: self.add_legalentity(legal_entities[0]) elif len(legal_entities) > 1: self.add_legalentities(legal_entities) signal_and_lock.Signal.call_signal("add_account", self.item, self) self.add_action(WrapAction(_("Close"), "images/close.png"))
def fillresponse_add_title(self): XferSearchEditor.fillresponse_add_title(self) modelname = self.model.get_long_name() saved_list = SavedCriteria.objects.filter(modelname=modelname) new_row = self.get_max_row() lbl = XferCompLabelForm('lbl_saved_criteria') lbl.set_location(1, new_row + 1) lbl.set_value_as_name(_("saved criteria")) self.add_component(lbl) sel = XferCompSelect('saved_criteria') sel.set_location(2, new_row + 1, 2) sel.set_needed(False) sel.set_select_query(saved_list) sel.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(sel) if len(self.criteria_list) > 0: from lucterios.CORE.views import SavedCriteriaAddModify btn = XferCompButton('btn_saved_criteria') btn.set_location(4, new_row + 1, 2) btn.set_is_mini(True) btn.set_action(self.request, SavedCriteriaAddModify.get_action("+", ""), close=CLOSE_NO, params={'modelname': modelname, 'criteria': self.getparam('CRITERIA', '')}) self.add_component(btn) if self.getparam('saved_criteria', 0) != 0: saved_item = SavedCriteria.objects.get( id=self.getparam('saved_criteria', 0)) self.params['CRITERIA'] = saved_item.criteria self.read_criteria_from_params()
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 fillresponse(self): if self.getparam('SAVE') is None: 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, False, desc_fields=['parent']) parent = dlg.get_components('parent') parent.colspan = 3 self.add_components(dlg) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: if self.getparam("parent", 0) != 0: self.item = Folder.objects.get(id=self.getparam("parent", 0)) else: self.item = Folder() self.run_archive()
def fillresponse(self, costaccounting=0): if self.getparam("SAVE") 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_costaccounting') lbl.set_value_as_name(CostAccounting._meta.verbose_name) lbl.set_location(1, 1) dlg.add_component(lbl) sel = XferCompSelect('costaccounting') sel.set_select_query(CostAccounting.objects.filter(status=0)) if self.item is not None: sel.set_value(self.item.costaccounting_id) sel.set_location(1, 2) dlg.add_component(sel) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png')) else: if costaccounting == 0: new_cost = None else: new_cost = CostAccounting.objects.get(id=costaccounting) for item in self.items: if (item.costaccounting is None) or (item.costaccounting.status == 0): item.costaccounting = new_cost item.save()
def fillresponse(self, begin_date, end_date): self.item.set_dates(begin_date, end_date) lbl = XferCompLabelForm('lbl_begin_date') lbl.set_value_as_name(_('initial date')) lbl.set_location(1, 0) self.add_component(lbl) date_init = XferCompDate("begin_date") date_init.set_needed(True) date_init.set_value(self.item.date_begin) date_init.set_location(2, 0) date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(date_init) lbl = XferCompLabelForm('lbl_end_date') lbl.set_value_as_name(_('current date')) lbl.set_location(3, 0) self.add_component(lbl) date_end = XferCompDate("end_date") date_end.set_needed(True) date_end.set_value(self.item.date_end) date_end.set_location(4, 0) date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH) self.add_component(date_end) XferShowEditor.fillresponse(self) self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Show', self), close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0) self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Email', self), close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
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_add_title(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0) self.add_component(lbl)
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 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(self, params=(), nb_col=1): img_title = XferCompImage('img') img_title.set_location(0, 0) img_title.set_value(self.icon_path()) self.add_component(img_title) lab = XferCompLabelForm('title') lab.set_location(1, 0, 2 * nb_col) lab.set_value_as_title(_("Edition of parameters")) self.add_component(lab) Params.fill(self, params, 1, 1, False, nb_col) self.add_action(ParamSave.get_action(_('Ok'), 'images/ok.png'), {}) self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'), {})
def show_contact_invoice(contact, xfer): if WrapAction.is_permission(xfer.request, 'invoice.change_bill'): third = Third.objects.filter(contact_id=contact.id) if len(third) == 1: third = third[0] xfer.new_tab(_("Financial")) nb_build = len(Bill.objects.filter(third=third, status=0)) nb_valid = len(Bill.objects.filter(third=third, status=1)) lab = XferCompLabelForm('invoiceinfo') lab.set_value_as_header(_("There are %(build)d bills in building and %(valid)d validated") % {'build': nb_build, 'valid': nb_valid}) lab.set_location(0, 5, 2) xfer.add_component(lab)
def edit(self, xfer): lbl = XferCompLabelForm('lbl_begin_date') lbl.set_value_as_name(_('begin date')) lbl.set_location(1, 0) xfer.add_component(lbl) date = XferCompDate('begin_date') date.set_location(2, 0) date.set_needed(True) val = Period.objects.all().aggregate(Max('end_date')) if ('end_date__max' in val.keys()) and (val['end_date__max'] is not None): date.set_value(val['end_date__max'] + timedelta(days=1)) xfer.add_component(date)
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 conf_wizard_member(wizard_ident, xfer): if isinstance(wizard_ident, list) and (xfer is None): wizard_ident.append(("member_season", 11)) wizard_ident.append(("member_subscriptiontype", 12)) wizard_ident.append(("member_category", 13)) wizard_ident.append(("member_params", 14)) elif (xfer is not None) and (wizard_ident == "member_season"): xfer.add_title(_("Diacamma member"), _('Season'), _('Configuration of season')) xfer.fill_grid(5, Season, "season", Season.objects.all()) elif (xfer is not None) and (wizard_ident == "member_subscriptiontype"): xfer.add_title(_("Diacamma member"), _('Subscriptions'), _('Configuration of subscription')) xfer.fill_grid(15, SubscriptionType, "subscriptiontype", SubscriptionType.objects.all()) xfer.get_components("subscriptiontype").colspan = 6 fill_params(xfer, [ "member-subscription-mode", "member-connection", "member-family-type", "member-tax-receipt", "member-subscription-message" ], True) elif (xfer is not None) and (wizard_ident == "member_category"): xfer.add_title(_("Diacamma member"), _("Categories"), _('Configuration of categories')) xfer.new_tab(_('Parameters')) fill_params(xfer, [ "member-team-enable", "member-team-text", "member-activite-enable", "member-activite-text", "member-age-enable" ], True) if Params.getvalue("member-age-enable") == 1: xfer.new_tab(_('Age')) xfer.fill_grid(1, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: xfer.new_tab(Params.getvalue("member-team-text")) xfer.fill_grid(1, Team, "team", Team.objects.all()) if Params.getvalue("member-activite-enable") == 1: xfer.new_tab(Params.getvalue("member-activite-text")) xfer.fill_grid(1, Activity, "activity", Activity.objects.all()) grid = xfer.get_components("activity") if hasattr(settings, "DIACAMMA_MAXACTIVITY") and (getattr( settings, "DIACAMMA_MAXACTIVITY") <= grid.nb_lines): lbl = XferCompLabelForm("limit_activity") lbl.set_color('red') lbl.set_value_as_headername( _('You have the maximum of activities!')) lbl.set_location(grid.col, xfer.get_max_row() + 1) xfer.add_component(lbl) grid.delete_action("diacamma.member/activityAddModify", True) elif (xfer is not None) and (wizard_ident == "member_params"): xfer.add_title(_("Diacamma member"), _('Parameters'), _('Configuration of main parameters')) fill_params(xfer, [ "member-licence-enabled", "member-filter-genre", "member-numero", "member-birth", "member-fields" ], True)
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 _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 fillresponse(self, model='', objid=0): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) self.add_component(img) self.model = apps.get_model(model) if objid != 0: self.item = self.model.objects.get(id=objid) fieldnames = [] for fieldname in self.model.get_default_fields(): if isinstance(fieldname, tuple): fieldnames.append(fieldname[1]) else: fieldnames.append(fieldname) self.fill_from_model(1, 0, True, desc_fields=fieldnames) log_items = LucteriosLogEntry.objects.get_for_object(self.item) else: content_type = ContentType.objects.get_for_model(self.model) lbl = XferCompLabelForm('ModelName') lbl.set_value_as_header(six.text_type(content_type)) lbl.description = _("content type") lbl.set_location(1, 0, 2) self.add_component(lbl) log_items = LucteriosLogEntry.objects.get_for_model(self.model) grid = XferCompGrid(self.field_id) grid.set_model(log_items, None, self) grid.set_location(1, self.get_max_row() + 1, 2) grid.set_size(200, 500) self.add_component(grid)
def __init__(self, comp, owner): PrintItem.__init__(self, comp, owner) try: if not isinstance(self.comp, XferCompLabelForm): self.comp = XferCompLabelForm.convert_to_label(self.comp) self.value = self.comp.get_print_value() except Exception: getLogger("lucterios.core.print").exception('PrintLabel') self.value = six.text_type(self.comp.value) self.init_label()
def _fill_functions(self): self.new_tab(_("Functions and responsabilities")) img = XferCompImage('imgFunction') img.set_value(get_icon_path('lucterios.contacts/images/function.png')) img.set_location(0, 0) self.add_component(img) img = XferCompLabelForm('titleFunction') img.set_value_as_title(_("Functions list")) img.set_location(1, 0) self.add_component(img) self.fill_grid(0, Function, "function", Function.objects.all())
def _fill_customfield(self): self.new_tab(_("Custom field")) img = XferCompImage('imgField') img.set_value(get_icon_path('lucterios.contacts/images/fields.png')) img.set_location(0, 0) self.add_component(img) img = XferCompLabelForm('titleField') img.set_value_as_title(_('custom field list')) img.set_location(1, 0) self.add_component(img) self.fill_grid(0, CustomField, "custom_field", CustomField.get_filter(AbstractContact))
def _fill_structuretype(self): self.new_tab(_("Structure type")) img = XferCompImage('imgType') img.set_value(get_icon_path('lucterios.contacts/images/category.png')) img.set_location(0, 0) self.add_component(img) img = XferCompLabelForm('titleType') img.set_value_as_title(_('Structure types list')) img.set_location(1, 0) self.add_component(img) self.fill_grid(0, StructureType, "structure_type", StructureType.objects.all())
def fillresponse(self): if not will_mail_send(): raise LucteriosException(IMPORTANT, _('Bad email parameter!')) legal = LegalEntity.objects.get(id=1) if self.getparam('CONFIRME') is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('lbl_title') lbl.set_location(1, 0, 2) lbl.set_value_as_header(self.caption) dlg.add_component(lbl) email = XferCompEdit('recipient') email.set_location(1, 1) email.set_value(legal.email) email.mask = r"[^@]+@[^@]+\.[^@]+" email.description = _("email") dlg.add_component(email) 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')) else: address = [] address.append("") address.append("") address.append(six.text_type(legal)) address.append(legal.address) address.append("%s %s" % (legal.postal_code, legal.city)) message = _('EMail sent to check configuration') message += "{[br/]}".join(address).replace('{[newline]}', "{[br/]}").replace("\n", '{[br/]}') bad_sended = send_email(self.getparam('recipient'), _("EMail try"), "<html><body>%s</body></html>" % message.replace('{[', '<').replace(']}', '>')) if len(bad_sended) != 0: raise EmailException(bad_sended) self.message(_("EMail send, check it."))
def fillresponse(self, show_only_failed=False): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) self.add_component(img) begin = XferCompLabelForm('title') begin.set_location(1, 0, 2) begin.set_value_as_title(_('Transmission report')) self.add_component(begin) self.filltab_from_model(1, 1, True, [((_('date begin of send'), 'date_begin'), (_('date end of send'), 'date_end')), ('emailsent_set', )]) if not show_only_failed: grid = self.get_components('emailsent') grid.delete_header('error') check = XferCompCheck('show_only_failed') check.set_value(show_only_failed) check.description = _('Show only failed') check.set_location(1, 3, 2) check.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(check) show_only_failed self.add_action(WrapAction(_('Close'), 'images/close.png'))
def fillresponse(self): legal = LegalEntity.objects.get(id=1) if self.getparam('CONFIRME') is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('lbl_title') lbl.set_location(1, 0, 2) lbl.set_value_as_header(self.caption) dlg.add_component(lbl) email = XferCompEdit('recipient') email.set_location(1, 1) email.set_value(legal.email) email.mask = r"[^@]+@[^@]+\.[^@]+" email.description = _("email") dlg.add_component(email) 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')) else: abs_url = self.request.META.get( 'HTTP_REFERER', self.request.build_absolute_uri()).split('/') self.item.http_root_address = '/'.join(abs_url[:-2]) send_email([self.getparam('recipient')], self.item.subject, self.item.email_content, files=self.item.attach_files) self.message(_("EMail send, check it."))
def fillresponse(self): img_title = XferCompImage('img') img_title.set_location(0, 0, 1, 6) img_title.set_value(self.icon_path()) self.add_component(img_title) lab = XferCompLabelForm('title') lab.set_location(1, 0, 2) lab.set_value_as_title(_("Print models")) self.add_component(lab) self.fill_from_model(2, 1, False, ['name']) self.fill_from_model(2, 2, True, ['kind']) self.item.mode = int(self.item.mode) if self.item.kind == 1: self.fill_from_model(2, 3, False, ['mode']) self.get_components('mode').set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO) if (self.item.mode == 1) and (self.item.value[:6] != '<model'): self.item.value = "<model>\n<body>\n<text>%s</text></body>\n</model>" % self.item.value if self.item.kind == 0: self._fill_listing_editor() elif (self.item.kind == 1) and (self.item.mode == 0): self._fill_label_editor() elif (self.item.kind == 2) or ((self.item.kind == 1) and (self.item.mode == 1)): self._fill_report_editor() for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_EDIT, self, key=action_list_sorted): self.add_action(act, **opt) self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
def fillresponse(self, field_id): if field_id is not None: self.field_id = field_id if hasattr(self.item, 'abstractcontact_ptr_id'): XferShowEditor.fillresponse(self) else: img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title( _('this contact is inconstitant, you must to be promote it !')) lbl.set_location(1, 0) self.add_component(lbl) btn = XferCompButton('btn_promote') btn.set_location(1, 1) btn.set_action(self.request, ObjectPromote.get_action(_('Promote'), "images/config.png"), modal=FORMTYPE_MODAL, close=CLOSE_YES, params={ 'modelname': self.model.get_long_name(), 'field_id': self.field_id }) self.add_component(btn)
def fillresponse(self): if self.getparam('SAVE') is None: 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, False, desc_fields=['parent']) parent = dlg.get_components('parent') parent.colspan = 3 self.add_components(dlg) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), { 'close': CLOSE_YES, 'params': { 'SAVE': 'YES' } }) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'), {}) else: if self.getparam("parent", 0) != 0: self.item = Folder.objects.get(id=self.getparam("parent", 0)) else: self.item = Folder() self.run_archive()
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 fillresponse(self): current_year = FiscalYear.get_current() if self.item.type_load == 0: for year_item in FiscalYear.objects.filter( begin__gte=current_year.begin): costs = self.item.setcost_set.filter(year=year_item) if len(costs) == 0: self.item.create_new_cost(year=year_item.id) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.item.name) lbl.set_location(1, 0) self.add_component(lbl) self.fill_grid( 0, CostAccounting, 'costaccounting', CostAccounting.objects.filter( setcost__set=self.item).order_by('-setcost__year__begin')) grid = self.get_components('costaccounting') grid.delete_header("is_default") new_actions = [] grid = self.get_components('costaccounting') for grid_action in grid.actions: if grid_action[0].icon_path.endswith('images/print.png'): new_actions.append(grid_action) grid.actions = new_actions grid.add_action(self.request, ClassCategoryBudget.get_action(), close=CLOSE_NO, unique=SELECT_SINGLE) self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
def fillresponse_header(self): modelname = self.getparam('modelname', "") lab = XferCompLabelForm('lblmodelname') lab.set_location(0, 1) lab.set_value_as_name(_('model')) self.add_component(lab) model_list = {} for print_model in PrintModel.objects.all(): if print_model.modelname not in model_list.keys(): try: model_list[print_model.modelname] = print_model.model_associated_title() if modelname == '': modelname = print_model.modelname except LookupError: pass model_list = list(model_list.items()) model_list.sort(key=lambda item: item[1]) model_sel = XferCompSelect('modelname') model_sel.set_location(1, 1) model_sel.set_select(model_list) model_sel.set_value(modelname) model_sel.set_action(self.request, self.get_action("", ""), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(model_sel) self.filter = Q(modelname=modelname) self.fieldnames = ['name', 'kind', 'is_default'] return
def fillresponse_body(self): if Params.getvalue("member-age-enable") == 1: self.new_tab(_('Age')) self.fill_grid(0, Age, "age", Age.objects.all()) if Params.getvalue("member-team-enable") == 1: show_only_enabled_team = self.getparam('show_only_enabled_team', True) self.new_tab(Params.getvalue("member-team-text")) if show_only_enabled_team: team_list = Team.objects.filter(unactive=False) else: team_list = Team.objects.all() self.fill_grid(0, Team, "team", team_list) if show_only_enabled_team: grid = self.get_components('team') grid.delete_header('unactive') check = XferCompCheck('show_only_enabled_team') check.set_location(0, 2) check.set_value(show_only_enabled_team) check.description = _('show only enabled team') check.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) self.add_component(check) if Params.getvalue("member-activite-enable") == 1: self.new_tab(Params.getvalue("member-activite-text")) self.fill_grid(0, Activity, "activity", Activity.objects.all()) grid = self.get_components("activity") if WrapAction.is_permission(self.request, 'CORE.add_parameter'): grid.add_action(self.request, ObjectMerge.get_action(_("Merge"), "images/clone.png"), close=CLOSE_NO, unique=SELECT_MULTI, params={ 'modelname': 'member.Activity', 'field_id': 'activity' }) if hasattr(settings, "DIACAMMA_MAXACTIVITY") and (getattr( settings, "DIACAMMA_MAXACTIVITY") <= grid.nb_lines): lbl = XferCompLabelForm("limit_activity") lbl.set_color('red') lbl.set_value_as_headername( _('You have the maximum of activities!')) lbl.set_location(grid.col, self.get_max_row() + 1) self.add_component(lbl) grid.delete_action("diacamma.member/activityAddModify", True)
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 fillresponse_add_title(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 5) self.add_component(lbl)
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_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 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 = r'^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$' row = dlg.get_max_row() + 1 edt = XferCompEdit("username") edt.set_location(1, row) edt.set_needed(True) edt.set_value(username) edt.description = _('username') dlg.add_component(edt) if Params.getvalue("contacts-createaccount") == 2: row = dlg.get_max_row() + 1 edt = XferCompEdit("legalentity") edt.set_location(1, row) edt.set_needed(True) edt.set_value(legalentity) edt.description = _("your structure name") dlg.add_component(edt) row = dlg.get_max_row() + 1 edt = XferCompCaptcha("captcha") edt.set_location(1, row) edt.description = _("captcha") dlg.add_component(edt) lbl = XferCompLabelForm("error_lbl") lbl.set_location(1, row + 1, 2) 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 get_reading_comp(self, field_name, prefix=''): sub_value = self.item for fieldname in field_name.split('.'): if sub_value is not None: try: sub_value = getattr(sub_value, fieldname) except ObjectDoesNotExist: getLogger("lucterios.core").exception( "fieldname '%s' not found", fieldname) sub_value = None value = adapt_value(sub_value) dep_field = self.item.get_field_by_name(field_name) if isinstance(dep_field, EmailField): comp = XferCompLinkLabel(prefix + field_name) comp.set_link('mailto:' + value) else: comp = XferCompLabelForm(prefix + field_name) comp.set_value(value) comp.set_format(get_format_from_field(dep_field)) return comp
def get_reading_comp(self, field_name): sub_value = self.item for fieldname in field_name.split('.'): if sub_value is not None: try: sub_value = getattr(sub_value, fieldname) except ObjectDoesNotExist: getLogger("lucterios.core").exception( "fieldname '%s' not found", fieldname) sub_value = None value = get_value_converted(sub_value, True) dep_field = self.item.get_field_by_name(field_name) if isinstance(dep_field, EmailField): comp = XferCompLinkLabel(field_name) comp.set_link('mailto:' + value) else: comp = XferCompLabelForm(field_name) value = get_value_if_choices(value, dep_field) comp.set_value(value) return comp
def fillresponse(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0) self.add_component(lbl) self.fillresponse_header() self.fillresponse_body() add_auditlogs_button(self, self.model, 0, self.get_max_row() + 20) if self.model is not None: for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_LIST, self, key=action_list_sorted): self.add_action(act, **opt) self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
def fillresponse(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) lbl = XferCompLabelForm('title') lbl.set_value_as_title(self.caption) lbl.set_location(1, 0, 6) self.add_component(lbl) zipdown = XferCompDownLoad('filename') zipdown.compress = False zipdown.http_file = True zipdown.maxsize = 0 zipdown.set_value("%s.mdl" % self.item.name) zipdown.set_download(self.item.extract_file()) zipdown.set_location(1, 15, 2) self.add_component(zipdown)
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)