Exemplo n.º 1
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.º 2
0
 def get_write_comp(self):
     if self.type == 0:  # String
         if self.args['Multi']:
             param_cmp = XferCompMemo(self.name)
             param_cmp.with_hypertext = self.args['HyperText']
         else:
             param_cmp = XferCompEdit(self.name)
         param_cmp.set_value(self.value)
     elif self.type == 1:  # Integer
         param_cmp = XferCompFloat(
             self.name, minval=self.args['Min'], maxval=self.args['Max'], precval=0)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 2:  # Real
         param_cmp = XferCompFloat(self.name, minval=self.args['Min'], maxval=self.args[
                                   'Max'], precval=self.args['Prec'])
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 3:  # Boolean
         param_cmp = XferCompCheck(self.name)
         param_cmp.set_value(six.text_type(self.value))
         param_cmp.set_needed(True)
     elif self.type == 4:  # Select
         param_cmp = XferCompSelect(self.name)
         selection = []
         for sel_idx in range(0, self.args['Enum']):
             selection.append((sel_idx, ugettext_lazy(self.name + ".%d" % sel_idx)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
         param_cmp.set_needed(True)
     elif self.type == 5:  # password
         param_cmp = XferCompPassword(self.name)
         param_cmp.security = 0
         param_cmp.set_value('')
     elif self.type == 6:  # select in object
         if (self.meta_info[0] != "") and (self.meta_info[1] != ""):
             db_mdl = apps.get_model(self.meta_info[0], self.meta_info[1])
         else:
             db_mdl = None
         if self.args['Multi']:
             param_cmp = XferCompCheckList(self.name)
             param_cmp.simple = 2
         else:
             param_cmp = XferCompSelect(self.name)
         param_cmp.set_needed(self.meta_info[4])
         selection = []
         if not self.meta_info[4]:
             if (self.args['oldtype'] == 1) or (self.args['oldtype'] == 2):
                 selection.append((0, None))
             else:
                 selection.append(('', None))
         if db_mdl is None:
             selection = self.meta_info[2]
         else:
             for obj_item in db_mdl.objects.filter(self.meta_info[2]):
                 selection.append((getattr(obj_item, self.meta_info[3]), six.text_type(obj_item)))
         param_cmp.set_select(selection)
         param_cmp.set_value(self.value)
     param_cmp.description = six.text_type(ugettext_lazy(self.name))
     return param_cmp
Exemplo n.º 3
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.º 4
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];
    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)
Exemplo n.º 5
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.º 6
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.º 7
0
    def fillresponse(self):
        model_module = ".".join(self.item.model_associated().__module__.split('.')[:-1])
        if self.getparam('SAVE') is None:
            dlg = self.create_custom(self.model)
            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)

            lbl = XferCompLabelForm('lbl_default_model')
            lbl.set_value_as_name(_("Model to reload"))
            lbl.set_location(1, 1)
            dlg.add_component(lbl)
            sel = XferCompSelect('default_model')
            sel.set_select(PrintModel.get_default_model(model_module, self.item.modelname, self.item.kind))
            sel.set_location(2, 1)
            dlg.add_component(sel)

            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.item.load_model(model_module, self.getparam("default_model", ""), is_default=None):
                self.message(_('Model reloaded'))
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
def finalizeyear_condo(xfer):
    year = FiscalYear.get_current(xfer.getparam('year'))
    if year is not None:
        ventilate = xfer.getparam("ventilate", 0)
        if xfer.observer_name == "core.custom":
            if year.check_to_close() > 0:
                raise LucteriosException(IMPORTANT, _("This fiscal year has entries not closed!"))
            result = year.total_revenue - year.total_expense
            if abs(result) > 0.001:
                row = xfer.get_max_row() + 1
                lbl = XferCompLabelForm('title_condo')
                lbl.set_value(_('This fiscal year has a result no null equals to %s.') % format_devise(result, 5))
                lbl.set_location(0, row, 2)
                xfer.add_component(lbl)
                lbl = XferCompLabelForm('question_condo')
                lbl.set_value(_('Where do you want to ventilate this amount?'))
                lbl.set_location(0, row + 1)
                xfer.add_component(lbl)
                sel_cmpt = [('0', _("For each owner"))]
                for account in year.chartsaccount_set.filter(type_of_account=2).order_by('code'):
                    sel_cmpt.append((account.id, six.text_type(account)))
                sel = XferCompSelect("ventilate")
                sel.set_select(sel_cmpt)
                sel.set_value(ventilate)
                sel.set_location(1, row + 1)
                xfer.add_component(sel)
        elif xfer.observer_name == "core.acknowledge":
            for set_cost in year.setcost_set.filter(year=year, set__is_active=True, set__type_load=0):
                if ventilate == 0:
                    current_system_condo().ventilate_costaccounting(set_cost.set, set_cost.cost_accounting, 1, Params.getvalue("condominium-current-revenue-account"))
                set_cost.cost_accounting.close()
            current_system_condo().ventilate_result(year, ventilate)
Exemplo n.º 10
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.º 11
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.º 12
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.º 13
0
 def _get_meta_comp(self):
     if self.args['Multi']:
         param_cmp = XferCompCheckList(self.name)
         param_cmp.simple = 2
     else:
         param_cmp = XferCompSelect(self.name)
     return param_cmp
Exemplo n.º 14
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.º 15
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.º 16
0
 def get_comp(self, value):
     comp = None
     args = self.item.get_args()
     if self.item.kind == 0:
         if args['multi']:
             comp = XferCompMemo(self.item.get_fieldname())
         else:
             comp = XferCompEdit(self.item.get_fieldname())
         comp.set_value(value)
     elif (self.item.kind == 1) or (self.item.kind == 2):
         comp = XferCompFloat(
             self.item.get_fieldname(), args['min'], args['max'], args['prec'])
         comp.set_value(value)
     elif self.item.kind == 3:
         comp = XferCompCheck(self.item.get_fieldname())
         comp.set_value(value)
     elif self.item.kind == 4:
         val_selected = value
         try:
             select_id = int(value)
         except ValueError:
             select_id = 0
         select_list = []
         for sel_item in args['list']:
             if sel_item == val_selected:
                 select_id = len(select_list)
             select_list.append((len(select_list), sel_item))
         comp = XferCompSelect(self.item.get_fieldname())
         comp.set_select(select_list)
         comp.set_value(select_id)
     return comp
Exemplo n.º 17
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.º 18
0
 def fill_dlg(self):
     self.item.can_be_valid()
     dlg = self.create_custom()
     dlg.item = self.item
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     dlg.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0, 6)
     dlg.add_component(lbl)
     dlg.fill_from_model(1, 1, True, ['activity', 'date'])
     dlg.get_components('activity').colspan = 3
     dlg.get_components('date').colspan = 3
     lbl = XferCompLabelForm('sep')
     lbl.set_value("{[hr/]}")
     lbl.set_location(0, 4, 7)
     dlg.add_component(lbl)
     row_id = 5
     for participant in self.item.participant_set.all():
         lbl = XferCompLabelForm('name_%d' % participant.id)
         lbl.set_value_as_name(six.text_type(participant))
         lbl.set_location(0, row_id)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current_%d' % participant.id)
         lbl.set_value(participant.current_degree)
         lbl.set_location(1, row_id)
         dlg.add_component(lbl)
         sel = XferCompSelect('degree_%d' % participant.id)
         sel.set_select_query(participant.allow_degree())
         sel.set_location(2, row_id)
         dlg.add_component(sel)
         if Params.getvalue("event-subdegree-enable") == 1:
             sel = XferCompSelect('subdegree_%d' % participant.id)
             sel.set_select_query(participant.allow_subdegree())
             sel.set_location(3, row_id)
             dlg.add_component(sel)
         edt = XferCompMemo('comment_%d' % participant.id)
         edt.set_value(participant.comment)
         edt.set_location(4, row_id)
         dlg.add_component(edt)
         row_id += 1
     dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"),
                    close=CLOSE_YES,
                    params={'CONFIRME': 'YES'})
     dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Exemplo n.º 19
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.º 20
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
     lbl = XferCompLabelForm('lblPrintMode')
     lbl.set_value_as_name(_('Kind of report'))
     lbl.set_location(0, 0)
     gui.add_component(lbl)
     print_mode = XferCompSelect('PRINT_MODE')
     print_mode.set_select(self.print_selector)
     print_mode.set_value(PRINT_PDF_FILE)
     print_mode.set_location(1, 0)
     gui.add_component(print_mode)
     if self.selector is not None:
         row_idx = 1
         for name_selector, title_selector, option_selector in self.selector:
             lbl = XferCompLabelForm('lbl' + name_selector)
             lbl.set_value_as_name(title_selector)
             lbl.set_location(0, row_idx)
             gui.add_component(lbl)
             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])
             comp.set_location(1, row_idx)
             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.º 21
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.º 22
0
 def _create_comp_integerfield(self, field_name, dep_field):
     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(
         self._get_value_from_field(field_name, dep_field, min_value))
     return comp
Exemplo n.º 23
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.º 24
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.º 25
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.º 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:
            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.º 27
0
 def edit(self, xfer):
     old_account = xfer.get_components("code")
     xfer.remove_component("code")
     sel_code = XferCompSelect("code")
     sel_code.set_location(old_account.col, old_account.row,
                           old_account.colspan + 1, old_account.rowspan)
     existed_codes = []
     for acc_ratio in RecoverableLoadRatio.objects.all():
         existed_codes.append(acc_ratio.code)
     for item in FiscalYear.get_current().chartsaccount_set.all().filter(
             code__regex=current_system_account().get_expence_mask(
             )).exclude(code__in=existed_codes).order_by('code'):
         sel_code.select_list.append((item.code, str(item)))
     sel_code.set_value(self.item.code)
     xfer.add_component(sel_code)
Exemplo n.º 28
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.º 29
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.º 30
0
 def fillresponse(self):
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0)
         dlg.add_component(img)
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_record')
         lbl.set_value_as_name(_('record'))
         lbl.set_location(1, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('record')
         lbl.set_value(six.text_type(self.item))
         lbl.set_location(2, 1)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_current')
         lbl.set_value_as_name(_('current model'))
         lbl.set_location(1, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('current')
         lbl.set_value(self.item.__class__._meta.verbose_name)
         lbl.set_location(2, 2)
         dlg.add_component(lbl)
         lbl = XferCompLabelForm('lbl_newmodel')
         lbl.set_value_as_name(_('new model'))
         lbl.set_location(1, 3)
         dlg.add_component(lbl)
         lbl = XferCompSelect('newmodel')
         lbl.set_select(self.item.__class__.get_select_contact_type(False))
         lbl.set_location(2, 3)
         dlg.add_component(lbl)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL, params={'CONFIRME': 'YES'})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
     else:
         new_model = apps.get_model(self.getparam('newmodel'))
         field_id_name = "%s_ptr_id" % self.model.__name__.lower()
         new_object = new_model(**{field_id_name: self.item.pk})
         new_object.save()
         new_object.__dict__.update(self.item.__dict__)
         new_object.save()
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self))