Exemplo n.º 1
0
    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)
        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.description = _('Filter by type')
        edt.set_location(0, 3)
        edt.set_action(self.request,
                       self.get_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.add_component(edt)

        edt = XferCompSelect("date_filter")
        edt.set_select([(0, _('only current fiscal year')),
                        (1, _('all expenses'))])
        edt.set_value(date_filter)
        edt.set_location(0, 4)
        edt.description = _('Filter by date')
        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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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')
     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(1, 0, 4)
     selected_model.set_action(self.request,
                               self.get_action(),
                               modal=FORMTYPE_REFRESH,
                               close=CLOSE_NO)
     selected_model.description = _('model')
     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)
Exemplo n.º 4
0
 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()
     sel = XferCompSelect('saved_criteria')
     sel.description = _("saved criteria")
     sel.set_location(1, new_row + 1, 3)
     sel.set_needed(False)
     sel.set_select_query(saved_list)
     sel.set_action(self.request,
                    self.return_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()
Exemplo n.º 5
0
 def _select_csv_parameters(self):
     model_select = XferCompSelect('modelname')
     if self.model is not None:
         model_select.set_value(self.model.get_long_name())
     model_select.set_select(self.get_select_models())
     model_select.set_location(1, 0, 3)
     model_select.description = _('model')
     self.add_component(model_select)
     upld = XferCompUpLoad('csvcontent')
     upld.http_file = True
     upld.add_filter(".csv")
     upld.set_location(1, 1, 2)
     upld.description = _('CSV file')
     self.add_component(upld)
     lbl = XferCompEdit('encoding')
     lbl.set_value(self.encoding)
     lbl.set_location(1, 2)
     lbl.description = _('encoding')
     self.add_component(lbl)
     lbl = XferCompEdit('dateformat')
     lbl.set_value(self.dateformat)
     lbl.set_location(2, 2)
     lbl.description = _('date format')
     self.add_component(lbl)
     lbl = XferCompEdit('delimiter')
     lbl.set_value(self.delimiter)
     lbl.set_location(1, 3)
     lbl.description = _('delimiter')
     self.add_component(lbl)
     lbl = XferCompEdit('quotechar')
     lbl.set_value(self.quotechar)
     lbl.set_location(2, 3)
     lbl.description = _('quotechar')
     self.add_component(lbl)
     return lbl
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
 def _select_fields(self):
     select_list = [('', None)]
     for fieldname in self.spamreader.fieldnames:
         if fieldname != '':
             select_list.append((fieldname, fieldname))
     row = 0
     for fieldname in self.model.get_import_fields():
         if isinstance(fieldname, tuple):
             fieldname, title = fieldname
             is_need = False
         else:
             dep_field = self.model.get_field_by_name(fieldname)
             title = dep_field.verbose_name
             is_need = not dep_field.blank and not dep_field.null
             fieldnames = fieldname.split('.')
             if is_need and (len(fieldnames) > 1):
                 init_field = self.model.get_field_by_name(fieldnames[0])
                 if not (init_field.is_relation and init_field.many_to_many):
                     is_need = not init_field.null
         lbl = XferCompSelect('fld_' + fieldname)
         lbl.set_select(deepcopy(select_list))
         lbl.set_value("")
         lbl.set_needed(is_need)
         lbl.set_location(1, row)
         lbl.description = title
         self.add_component(lbl)
         row += 1
Exemplo n.º 8
0
    def _change_city_select(self, xfer, list_postalcode, obj_city):

        obj_country = xfer.get_components('country')
        city_current = obj_city.value
        city_list = {}
        obj_country.value = ""
        for item_postalcode in list_postalcode:
            city_list[item_postalcode.city] = item_postalcode.city
            if item_postalcode.city == city_current:
                obj_country.value = item_postalcode.country
        if obj_country.value == "":
            obj_country.value = list_postalcode[0].country
            city_current = list_postalcode[0].city
        xfer.remove_component('city')
        xfer.tab = obj_city.tab
        city_select = XferCompSelect('city')
        city_select.set_value(city_current)
        city_select.set_select(city_list)
        city_select.set_location(obj_city.col, obj_city.row, obj_city.colspan,
                                 obj_city.rowspan)
        city_select.description = obj_city.description
        city_select.set_size(obj_city.vmin, obj_city.hmin)
        city_select.set_action(xfer.request,
                               xfer.get_action(),
                               modal=FORMTYPE_REFRESH,
                               close=CLOSE_NO)
        xfer.add_component(city_select)
Exemplo n.º 9
0
 def _add_option_selectors(self, gui):
     row_idx = 3
     for name_selector, title_selector, option_selector in self.selector:
         if isinstance(option_selector, list):
             comp = XferCompSelect(name_selector)
             comp.set_select(option_selector)
             comp.set_value(gui.getparam(name_selector, 0))
         elif isinstance(option_selector, tuple):
             comp = XferCompFloat(name_selector, option_selector[0],
                                  option_selector[1], option_selector[2])
             comp.set_value(option_selector[0])
         elif isinstance(option_selector, six.binary_type):
             comp = XferCompEdit(name_selector)
             comp.set_value(option_selector.decode())
         elif isinstance(option_selector, six.text_type):
             comp = XferCompMemo(name_selector)
             comp.with_hypertext = True
             comp.set_value(option_selector)
         elif isinstance(option_selector, bool):
             comp = XferCompCheck(name_selector)
             comp.set_value(option_selector)
         else:
             comp = None
         if comp is not None:
             comp.set_location(0, row_idx, 2)
             comp.description = title_selector
             gui.add_component(comp)
             row_idx += 1
Exemplo n.º 10
0
    def edit(self, xfer):
        set_comp = xfer.get_components('set')
        set_comp.set_select_query(Set.objects.filter(is_active=True))
        xfer.get_components('price').prec = Params.getvalue(
            "accounting-devise-prec")
        old_account = xfer.get_components("expense_account")
        xfer.remove_component("expense_account")
        sel_account = XferCompSelect("expense_account")
        sel_account.description = old_account.description
        sel_account.set_location(old_account.col, old_account.row,
                                 old_account.colspan, old_account.rowspan)
        for item in FiscalYear.get_current().chartsaccount_set.all().filter(
                code__regex=current_system_account().get_expence_mask(
                )).order_by('code'):
            sel_account.select_list.append((item.code, six.text_type(item)))
        sel_account.set_value(self.item.expense_account)
        xfer.add_component(sel_account)

        self.item.year = FiscalYear.get_current()
        btn = XferCompButton('add_account')
        btn.set_location(old_account.col + 1, old_account.row)
        btn.set_is_mini(True)
        btn.set_action(xfer.request,
                       ActionsManage.get_action_url('accounting.ChartsAccount',
                                                    'AddModify', xfer),
                       close=CLOSE_NO,
                       modal=FORMTYPE_MODAL,
                       params={'year': self.item.year.id})
        xfer.add_component(btn)
        xfer.get_components("set").colspan = old_account.colspan + 1
        xfer.get_components("designation").colspan = old_account.colspan + 1
        xfer.get_components("price").colspan = old_account.colspan + 1
Exemplo n.º 11
0
def thirdaddon_expense(item, xfer):
    if WrapAction.is_permission(xfer.request, 'condominium.change_expense'):
        try:
            status_filter = xfer.getparam('status_filter',
                                          Expense.STATUS_BUILDING)
            date_filter = xfer.getparam('date_filter', 0)
            current_year = FiscalYear.get_current()
            item.get_account(current_year,
                             current_system_account().get_provider_mask())
            xfer.new_tab(_('Expenses'))
            edt = XferCompSelect("status_filter")
            edt.set_select(list(Expense.get_field_by_name('status').choices))
            edt.set_value(status_filter)
            edt.description = _('Filter by type')
            edt.set_location(0, 1)
            edt.set_action(xfer.request,
                           xfer.return_action(),
                           modal=FORMTYPE_REFRESH,
                           close=CLOSE_NO)
            xfer.add_component(edt)
            edt = XferCompSelect("date_filter")
            edt.set_select([(0, _('only current fiscal year')),
                            (1, _('all expenses'))])
            edt.set_value(date_filter)
            edt.set_location(0, 2)
            edt.description = _('Filter by date')
            edt.set_action(xfer.request,
                           xfer.return_action(),
                           modal=FORMTYPE_REFRESH,
                           close=CLOSE_NO)
            xfer.add_component(edt)
            expense_filter = Q(status=status_filter) & Q(third=item)
            if date_filter == 0:
                expense_filter &= Q(date__gte=current_year.begin) & Q(
                    date__lte=current_year.end)
            expenses = Expense.objects.filter(expense_filter).distinct()
            expense_grid = XferCompGrid('expense')
            expense_grid.set_model(expenses,
                                   Expense.get_default_fields(status_filter),
                                   xfer)
            expense_grid.add_action_notified(xfer, Expense)
            expense_grid.set_location(0, 3, 2)
            xfer.add_component(expense_grid)
        except LucteriosException:
            pass
Exemplo n.º 12
0
def editbudget_condo(xfer):
    if xfer.getparam('set') is not None:
        cost = xfer.getparam('cost_accounting')
        if cost is not None:
            set_item = Set.objects.get(id=xfer.getparam('set', 0))
            title_cost = xfer.get_components('title_cost')
            xfer.remove_component('title_year')
            year = xfer.getparam('year', 0)
            select_year = XferCompSelect('year')
            select_year.set_location(1, title_cost.row - 1)
            select_year.set_select_query(FiscalYear.objects.all())
            select_year.set_value(year)
            select_year.description = _('year')
            select_year.set_needed(set_item.type_load == Set.TYPELOAD_CURRENT)
            select_year.set_action(xfer.request,
                                   xfer.__class__.get_action(),
                                   close=CLOSE_NO,
                                   modal=FORMTYPE_REFRESH)
            xfer.add_component(select_year)
            btn = XferCompButton('confyear')
            btn.set_location(2, title_cost.row - 1)
            btn.set_action(xfer.request,
                           ActionsManage.get_action_url(
                               FiscalYear.get_long_name(), 'configuration',
                               xfer),
                           close=CLOSE_NO)
            btn.set_is_mini(True)
            xfer.add_component(btn)
            if year != 0:
                current_year = FiscalYear.get_current(year)
                xfer.params['readonly'] = str(
                    current_year.status == FiscalYear.STATUS_FINISHED)
                if set_item.type_load == 0:
                    if len(set_item.setcost_set.filter(
                            year=current_year)) == 0:
                        set_item.create_new_cost(year=current_year.id)
                    setcost_item = set_item.setcost_set.filter(
                        year=current_year)[0]
                else:
                    setcost_item = set_item.setcost_set.filter(year=None)[0]
                cost_item = setcost_item.cost_accounting
                xfer.params['cost_accounting'] = cost_item.id
                title_cost.set_value("{[b]}%s{[/b]} : %s" %
                                     (_('cost accounting'), cost_item))
            else:
                year = None
                xfer.params['readonly'] = 'True'
                cost_item = CostAccounting.objects.get(id=cost)
            if (cost_item.status
                    == CostAccounting.STATUS_OPENED) and not xfer.getparam(
                        'readonly', False):
                set_item.change_budget_product(cost_item, year)
    if xfer.getparam('type_of_account') is not None:
        xfer.params['readonly'] = 'True'
    return
Exemplo n.º 13
0
    def edit(self, xfer):
        if xfer.item.id is None:
            new_account = []
            if Params.getvalue("condominium-old-accounting"):
                new_account.append(
                    Params.getvalue("condominium-default-owner-account"))
            else:
                for num_account in LIST_DEFAULT_ACCOUNTS:
                    new_account.append(
                        Params.getvalue("condominium-default-owner-account%d" %
                                        num_account))
            sel = XferCompSelect('third')
            sel.needed = True
            sel.description = _('third')
            sel.set_location(1, 0)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.filter(
                accountthird__code__regex=current_system_account(
                ).get_societary_mask()).exclude(
                    id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: str(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': ';'.join(new_account)})
            xfer.add_component(btn)
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
        else:
            old_item = xfer.item
            xfer.item = old_item.third.contact.get_final_child()
            xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item.third.get_final_child()
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
Exemplo n.º 14
0
    def fillresponse_header(self):
        status_filter = self.getparam('status_filter',
                                      Expense.STATUS_BUILDING_WAITING)
        self.params['status_filter'] = status_filter
        date_filter = self.getparam('date_filter', 0)
        self.fieldnames = Expense.get_default_fields(status_filter)
        edt = XferCompSelect("status_filter")
        edt.set_select(Expense.SELECTION_STATUS)
        edt.set_value(status_filter)
        edt.description = _('Filter by type')
        edt.set_location(0, 3)
        edt.set_action(self.request,
                       self.return_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.add_component(edt)

        edt = XferCompSelect("date_filter")
        edt.set_select([(0, _('only current fiscal year')),
                        (1, _('all expenses'))])
        edt.set_value(date_filter)
        edt.set_location(0, 4)
        edt.description = _('Filter by date')
        edt.set_action(self.request,
                       self.return_action(),
                       modal=FORMTYPE_REFRESH,
                       close=CLOSE_NO)
        self.add_component(edt)

        if status_filter == Expense.STATUS_BUILDING_WAITING:
            self.filter = Q(status=Expense.STATUS_BUILDING) | Q(
                status=Expense.STATUS_WAITING)
        elif status_filter != Expense.STATUS_ALL:
            self.filter = Q(status=status_filter)
        else:
            self.filter = Q()
        if date_filter == 0:
            current_year = FiscalYear.get_current()
            self.filter &= Q(date__gte=current_year.begin) & Q(
                date__lte=current_year.end)
Exemplo n.º 15
0
 def fillresponse_header(self):
     status_filter = self.getparam('status_filter', CallFunds.STATUS_BUILDING)
     self.params['status_filter'] = status_filter
     dep_field = self.item.get_field_by_name('status')
     sel_list = list(dep_field.choices)
     edt = XferCompSelect("status_filter")
     edt.description = _('Filter by type')
     edt.set_select(sel_list)
     edt.set_value(status_filter)
     edt.set_location(0, 3)
     edt.set_action(self.request, self.return_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q(status=status_filter)
Exemplo n.º 16
0
    def _get_from_selector(self):
        if not isinstance(self.selector, list) and (self.selector is not None):
            raise LucteriosException(GRAVE, "Error of print selector!")
        gui = XferContainerCustom()
        gui.model = self.model
        gui._initialize(self.request)
        gui.is_view_right = self.is_view_right
        gui.caption = self.caption
        gui.extension = self.extension
        gui.action = self.action
        gui.params = self.params
        pdfreport = self.get_persistent_pdfreport()
        if (pdfreport is not None) and (not isinstance(pdfreport, list)
                                        or len(pdfreport) == len(self.items)):
            presitent_report = XferCompCheck('PRINT_PERSITENT')
            presitent_report.set_value(True)
            presitent_report.set_location(0, 0, 2)
            presitent_report.description = _('Get saved report')
            presitent_report.java_script = """
var is_persitent=current.getValue();
parent.get('PRINT_MODE').setEnabled(!is_persitent);
parent.get('print_sep').setEnabled(!is_persitent);
"""
            if self.selector is not None:
                for name_selector, _selector, _selector in self.selector:
                    presitent_report.java_script += "parent.get('%s').setEnabled(!is_persitent);\n" % name_selector
            gui.add_component(presitent_report)
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_REGENERATE_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)
        elif (pdfreport is not None):
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_WARNING_SAVING_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)

        print_mode = XferCompSelect('PRINT_MODE')
        print_mode.set_select(self.print_selector)
        print_mode.set_value(PRINT_PDF_FILE)
        print_mode.set_location(0, 2, 2)
        print_mode.description = _('Kind of report')
        gui.add_component(print_mode)
        if self.selector is not None:
            self._add_option_selectors(gui)
        gui.add_action(self.return_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
Exemplo n.º 17
0
    def edit(self, xfer):
        if xfer.item.id is None:
            sel = XferCompSelect('third')
            sel.needed = True
            sel.description = _('third')
            sel.set_location(1, 0)
            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)
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
        else:
            old_item = xfer.item
            xfer.item = old_item.third.contact.get_final_child()
            xfer.filltab_from_model(1, 0, False, xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item.third.get_final_child()
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    xfer.item.get_edit_fields())
            CustomField.edit_fields(xfer, 1)

            xfer.item = old_item
            xfer.filltab_from_model(1,
                                    xfer.get_max_row() + 1, False,
                                    ["information"])
Exemplo n.º 18
0
 def fillresponse_header(self):
     self.new_tab(_("Log entries"))
     row = self.get_max_row() + 1
     type_selected = self.getparam('type_selected', '')
     sel = XferCompSelect('type_selected')
     sel.set_select(LucteriosLogEntry.get_typeselection())
     sel.set_needed(True)
     sel.set_value(type_selected)
     sel.set_location(1, row)
     sel.description = _("content type")
     sel._check_case()
     sel.set_action(self.request,
                    self.get_action(),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     self.filter = Q(modelname=sel.value)
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
    def fillresponse(self, current_folder=0, docext=""):
        if current_folder == 0:
            self.item.parent_id = None
        else:
            self.item.parent_id = current_folder
        if self.getparam('CONFIRME', '') == 'YES':
            self.params = {}
            filename_spited = self.item.name.split('.')
            if len(filename_spited) > 1:
                filename_spited = filename_spited[:-1]
            self.item.name = "%s.%s" % (".".join(filename_spited), docext)
            self.item.editor.before_save(self)
            self.item.save()
            self.item.content = ""
            self.redirect_action(DocumentEditor.get_action(),
                                 modal=FORMTYPE_NOMODAL,
                                 close=CLOSE_YES,
                                 params={'document': self.item.id})
        else:
            dlg = self.create_custom(self.model)
            max_row = dlg.get_max_row() + 1
            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, max_row, True, ['parent'])
            dlg.fill_from_model(1, max_row + 1, False, ['name', 'description'])

            max_row = dlg.get_max_row() + 1
            select = XferCompSelect('docext')
            select.set_select([
                (item, item)
                for item in DocEditor.get_all_extension_supported()
            ])
            select.set_value(select.select_list[0][1])
            select.set_location(1, max_row)
            select.description = _('document type')
            dlg.add_component(select)
            dlg.add_action(self.get_action(TITLE_OK, 'images/ok.png'),
                           close=CLOSE_YES,
                           params={'CONFIRME': 'YES'})
            dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 21
0
 def edit(self, xfer):
     obj_model = xfer.get_components('modelname')
     obj_kind = xfer.get_components('kind')
     xfer.tab = obj_model.tab
     sel_models = self._get_basic_model(xfer).get_select_contact_type()
     model_current = obj_model.value
     xfer.remove_component('modelname')
     model_select = XferCompSelect('modelname')
     model_select.description = obj_model.description
     model_select.set_value(model_current)
     model_select.set_select(sel_models)
     model_select.set_location(obj_model.col, obj_model.row, obj_model.colspan, obj_model.rowspan)
     model_select.set_size(obj_model.vmin, obj_model.hmin)
     xfer.add_component(model_select)
     if len(sel_models) == 1:
         xfer.params['modelname'] = sel_models[0][0]
         model_select.set_value(xfer.params['modelname'])
         xfer.change_to_readonly('modelname')
     self._edit_add_args(xfer, obj_kind)
     obj_kind.java_script = """
Exemplo n.º 22
0
 def edit(self, xfer):
     obj_model = xfer.get_components('modelname')
     obj_kind = xfer.get_components('kind')
     xfer.tab = obj_model.tab
     sel_models = self._get_basic_model(xfer).get_select_contact_type()
     model_current = obj_model.value
     xfer.remove_component('modelname')
     model_select = XferCompSelect('modelname')
     model_select.description = obj_model.description
     model_select.set_value(model_current)
     model_select.set_select(sel_models)
     model_select.set_location(obj_model.col, obj_model.row, obj_model.colspan, obj_model.rowspan)
     model_select.set_size(obj_model.vmin, obj_model.hmin)
     xfer.add_component(model_select)
     if len(sel_models) == 1:
         xfer.params['modelname'] = sel_models[0][0]
         model_select.set_value(xfer.params['modelname'])
         xfer.change_to_readonly('modelname')
     self._edit_add_args(xfer, obj_kind)
     obj_kind.java_script = """
Exemplo n.º 23
0
    def _change_city_select(self, xfer, list_postalcode, obj_city):

        obj_country = xfer.get_components('country')
        city_current = obj_city.value
        city_list = {}
        obj_country.value = ""
        for item_postalcode in list_postalcode:
            city_list[item_postalcode.city] = item_postalcode.city
            if item_postalcode.city == city_current:
                obj_country.value = item_postalcode.country
        if obj_country.value == "":
            obj_country.value = list_postalcode[0].country
            city_current = list_postalcode[0].city
        xfer.remove_component('city')
        xfer.tab = obj_city.tab
        city_select = XferCompSelect('city')
        city_select.set_value(city_current)
        city_select.set_select(city_list)
        city_select.set_location(obj_city.col, obj_city.row, obj_city.colspan, obj_city.rowspan)
        city_select.description = obj_city.description
        city_select.set_size(obj_city.vmin, obj_city.hmin)
        city_select.set_action(xfer.request, xfer.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        xfer.add_component(city_select)
Exemplo n.º 24
0
 def fillresponse_header(self):
     self.new_tab(_('Season'))
     show_filter = self.getparam('show_filter', 0)
     edt = XferCompSelect("show_filter")
     edt.set_select([(0, _('Near active')), (1, _('All'))])
     edt.set_value(show_filter)
     edt.set_location(0, 3)
     edt.description = _('Show season')
     edt.set_action(self.request,
                    self.get_action(),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(edt)
     self.filter = Q()
     if show_filter == 0:
         try:
             year_ref = Season.current_season().reference_year
             designation_begin = "%d/%d" % (year_ref - 2, year_ref - 1)
             designation_end = "%d/%d" % (year_ref + 2, year_ref + 3)
             self.filter = Q(designation__gte=designation_begin) & Q(
                 designation__lte=designation_end)
         except Exception:
             pass
Exemplo n.º 25
0
 def fillresponse(self, season):
     if season is None:
         working_season = Season.current_season()
     else:
         working_season = Season.objects.get(id=season)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     sel = XferCompSelect('season')
     sel.set_needed(True)
     sel.set_select_query(Season.objects.all())
     sel.set_value(working_season.id)
     sel.set_location(1, 0)
     sel.description = _('season')
     sel.set_action(self.request,
                    self.get_action('', ''),
                    modal=FORMTYPE_REFRESH,
                    close=CLOSE_NO)
     self.add_component(sel)
     stat_result = Degree.get_statistic(working_season)
     if len(stat_result) == 0:
         lab = XferCompLabelForm('lbl_season')
         lab.set_color('red')
         lab.set_value_as_infocenter(_('no degree!'))
         lab.set_location(1, 1, 2)
         self.add_component(lab)
     else:
         total = 0
         pos_y = 2
         for activity, sublist in stat_result:
             subtotal = 0
             if activity is not None:
                 lab = XferCompLabelForm("lblactivite_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(activity))
                 lab.set_location(0, pos_y, 3)
                 self.add_component(lab)
                 pos_y += 1
             for degree_name, val in sublist:
                 lab = XferCompLabelForm("title_%d" % pos_y)
                 lab.set_value(degree_name)
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("val_%d" % pos_y)
                 lab.set_value(six.text_type(val))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 subtotal += val
                 total += val
                 pos_y += 1
             if activity is not None:
                 lab = XferCompLabelForm("lblsubtotal_%d" % activity.id)
                 lab.set_value_as_header(_("Total"))
                 lab.set_location(1, pos_y)
                 self.add_component(lab)
                 lab = XferCompLabelForm("subtotal_%d" % activity.id)
                 lab.set_italic()
                 lab.set_value(six.text_type(subtotal))
                 lab.set_location(2, pos_y)
                 self.add_component(lab)
                 pos_y += 1
         lab = XferCompLabelForm("lbltotal")
         lab.set_value_as_headername(_("Total"))
         lab.set_location(1, pos_y)
         self.add_component(lab)
         lab = XferCompLabelForm("total")
         lab.set_value_as_name(six.text_type(total))
         lab.set_location(2, pos_y)
         self.add_component(lab)
     self.add_action(DegreeStatisticPrint.get_action(
         TITLE_PRINT, "images/print.png"),
                     close=CLOSE_NO,
                     params={'classname': self.__class__.__name__})
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Exemplo n.º 26
0
    def _get_from_selector(self):
        if not isinstance(self.selector, list) and (self.selector is not None):
            raise LucteriosException(GRAVE, "Error of print selector!")
        gui = XferContainerCustom()
        gui.model = self.model
        gui._initialize(self.request)
        gui.is_view_right = self.is_view_right
        gui.caption = self.caption
        gui.extension = self.extension
        gui.action = self.action
        gui.params = self.params
        pdfreport = self.get_persistent_pdfreport()
        if (pdfreport is not None) and (not isinstance(pdfreport, list)
                                        or len(pdfreport) == len(self.items)):
            presitent_report = XferCompCheck('PRINT_PERSITENT')
            presitent_report.set_value(True)
            presitent_report.set_location(0, 0, 2)
            presitent_report.description = _('Get saved report')
            presitent_report.java_script = """
var is_persitent=current.getValue();
parent.get('PRINT_MODE').setEnabled(!is_persitent);
parent.get('print_sep').setEnabled(!is_persitent);
"""
            if self.selector is not None:
                for name_selector, _selector, _selector in self.selector:
                    presitent_report.java_script += "parent.get('%s').setEnabled(!is_persitent);\n" % name_selector
            gui.add_component(presitent_report)
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_REGENERATE_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)
        elif (pdfreport is not None):
            sep = XferCompLabelForm('print_sep')
            sep.set_value_center(self.PRINT_WARNING_SAVING_MSG)
            sep.set_location(0, 1, 2)
            gui.add_component(sep)

        print_mode = XferCompSelect('PRINT_MODE')
        print_mode.set_select(self.print_selector)
        print_mode.set_value(PRINT_PDF_FILE)
        print_mode.set_location(0, 2, 2)
        print_mode.description = _('Kind of report')
        gui.add_component(print_mode)
        if self.selector is not None:
            row_idx = 3
            for name_selector, title_selector, option_selector in self.selector:
                if isinstance(option_selector, list):
                    comp = XferCompSelect(name_selector)
                    comp.set_select(option_selector)
                    comp.set_value(gui.getparam(name_selector, 0))
                elif isinstance(option_selector, tuple):
                    comp = XferCompFloat(name_selector, option_selector[0],
                                         option_selector[1],
                                         option_selector[2])
                    comp.set_value(option_selector[0])
                elif isinstance(option_selector, six.binary_type):
                    comp = XferCompEdit(name_selector)
                    comp.set_value(option_selector.decode())
                elif isinstance(option_selector, six.text_type):
                    comp = XferCompMemo(name_selector)
                    comp.with_hypertext = True
                    comp.set_value(option_selector)
                elif isinstance(option_selector, bool):
                    comp = XferCompCheck(name_selector)
                    comp.set_value(option_selector)
                else:
                    comp = None
                if comp is not None:
                    comp.set_location(0, row_idx, 2)
                    comp.description = title_selector
                    gui.add_component(comp)
                    row_idx += 1
        gui.add_action(self.get_action(_("Print"), "images/print.png"),
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_YES)
        gui.add_action(WrapAction(_("Close"), "images/close.png"))
        return gui
Exemplo n.º 27
0
 def get_writing_comp(self, field_name):
     def get_value_from_field(default):
         val = getattr(self.item, field_name)
         if val is None:
             if is_needed:
                 if dep_field.default != NOT_PROVIDED:
                     val = dep_field.default
                 else:
                     val = default
         return val
     from django.db.models.fields import IntegerField, DecimalField, BooleanField, TextField, DateField, TimeField, DateTimeField, CharField
     from django.db.models.fields.related import ForeignKey
     from django.core.exceptions import ObjectDoesNotExist
     dep_field = self.item.get_field_by_name(field_name)
     is_needed = dep_field.unique or not (dep_field.blank or dep_field.null)
     if isinstance(dep_field, IntegerField):
         if (dep_field.choices is not None) and (len(dep_field.choices) > 0):
             comp = XferCompSelect(field_name)
             comp.set_select(list(dep_field.choices))
             min_value = 0
         else:
             min_value, max_value = get_range_value(dep_field)
             comp = XferCompFloat(field_name, min_value, max_value, 0)
         comp.set_value(get_value_from_field(min_value))
     elif isinstance(dep_field, DecimalField):
         min_value, max_value = get_range_value(dep_field)
         comp = XferCompFloat(
             field_name, min_value, max_value, dep_field.decimal_places)
         comp.set_value(get_value_from_field(min_value))
     elif isinstance(dep_field, BooleanField):
         comp = XferCompCheck(field_name)
         comp.set_value(get_value_from_field(False))
     elif isinstance(dep_field, TextField):
         comp = XferCompMemo(field_name)
         comp.set_value(get_value_from_field(""))
     elif isinstance(dep_field, DateField):
         comp = XferCompDate(field_name)
         comp.set_value(get_value_from_field(datetime.date.today()))
     elif isinstance(dep_field, TimeField):
         comp = XferCompTime(field_name)
         comp.set_value(get_value_from_field(datetime.time()))
     elif isinstance(dep_field, DateTimeField):
         comp = XferCompDateTime(field_name)
         comp.set_value(get_value_from_field(datetime.datetime.now()))
     elif isinstance(dep_field, ForeignKey):
         comp = XferCompSelect(field_name)
         try:
             value = self.item
             for fieldname in field_name.split('.'):
                 value = getattr(value, fieldname)
         except ObjectDoesNotExist:
             value = None
         if value is None:
             comp.set_value(0)
         else:
             comp.set_value(value.id)
         if hasattr(self.item, fieldname + '_query'):
             sub_select = getattr(self.item, field_name + '_query')
         else:
             sub_select = dep_field.remote_field.model.objects.all()
         comp.set_needed(not dep_field.null)
         comp.set_select_query(sub_select)
     else:
         comp = XferCompEdit(field_name)
         comp.set_value(get_value_from_field(""))
         if isinstance(dep_field, CharField):
             comp.size = dep_field.max_length
     comp.set_needed(is_needed)
     comp.description = six.text_type(dep_field.verbose_name)
     return comp