Beispiel #1
0
    def fillresponse(self, begin_date, end_date):
        self.item.set_dates(begin_date, end_date)
        date_init = XferCompDate("begin_date")
        date_init.set_needed(True)
        date_init.set_value(self.item.date_begin)
        date_init.set_location(1, 0)
        date_init.description = _('initial date')
        date_init.set_action(self.request,
                             self.get_action(),
                             close=CLOSE_NO,
                             modal=FORMTYPE_REFRESH)
        self.add_component(date_init)
        date_end = XferCompDate("end_date")
        date_end.set_needed(True)
        date_end.set_value(self.item.date_end)
        date_end.set_location(3, 0)
        date_end.description = _('current date')
        date_end.set_action(self.request,
                            self.get_action(),
                            close=CLOSE_NO,
                            modal=FORMTYPE_REFRESH)
        self.add_component(date_end)

        XferShowEditor.fillresponse(self)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                     'Show', self),
                        close=CLOSE_NO,
                        params={'item_name': self.field_id},
                        pos_act=0)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                     'Email', self),
                        close=CLOSE_NO,
                        params={'item_name': self.field_id},
                        pos_act=0)
Beispiel #2
0
    def show_third(self, xfer, right=""):
        xfer.params["supporting"] = self.item.id
        third = xfer.get_components("third")
        third.colspan -= 2
        if WrapAction.is_permission(xfer.request, right):
            btn = XferCompButton("change_third")
            btn.set_location(third.col + third.colspan, third.row)
            btn.set_action(
                xfer.request,
                ActionsManage.get_action_url("payoff.Supporting", "Third", xfer),
                modal=FORMTYPE_MODAL,
                close=CLOSE_NO,
                params={"code_mask": self.item.get_third_mask()},
            )
            xfer.add_component(btn)

        if self.item.third is not None:
            btn = XferCompButton("show_third")
            btn.set_is_mini(True)
            btn.set_location(third.col + third.colspan + 1, third.row)
            btn.set_action(
                xfer.request,
                ActionsManage.get_action_url("accounting.Third", "Show", xfer),
                modal=FORMTYPE_MODAL,
                close=CLOSE_NO,
                params={"third": self.item.third.id},
            )
            xfer.add_component(btn)
        lbl = XferCompLabelForm("info")
        lbl.set_color("red")
        lbl.set_location(1, xfer.get_max_row() + 1, 4)
        lbl.set_value(self.item.get_info_state())
        xfer.add_component(lbl)
Beispiel #3
0
    def fillresponse(self, begin_date, end_date):
        self.item.set_dates(begin_date, end_date)
        lbl = XferCompLabelForm('lbl_begin_date')
        lbl.set_value_as_name(_('initial date'))
        lbl.set_location(1, 0)
        self.add_component(lbl)
        date_init = XferCompDate("begin_date")
        date_init.set_needed(True)
        date_init.set_value(self.item.date_begin)
        date_init.set_location(2, 0)
        date_init.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_init)
        lbl = XferCompLabelForm('lbl_end_date')
        lbl.set_value_as_name(_('current date'))
        lbl.set_location(3, 0)
        self.add_component(lbl)
        date_end = XferCompDate("end_date")
        date_end.set_needed(True)
        date_end.set_value(self.item.date_end)
        date_end.set_location(4, 0)
        date_end.set_action(self.request, self.get_action(), close=CLOSE_NO, modal=FORMTYPE_REFRESH)
        self.add_component(date_end)

        XferShowEditor.fillresponse(self)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Show', self),
                        close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
        self.add_action(ActionsManage.get_action_url('payoff.Supporting', 'Email', self),
                        close=CLOSE_NO, params={'item_name': self.field_id}, pos_act=0)
Beispiel #4
0
 def _show_entryline(self, xfer):
     from diacamma.accounting.views_entries import EntryAccountDel
     link_grid_lines = xfer.get_components('entryline')
     link_grid_lines.description = ''
     link_grid_lines.actions = []
     link_grid_lines.colspan = 2
     link_grid_lines.add_action(xfer.request,
                                ActionsManage.get_action_url(
                                    'accounting.EntryAccount',
                                    'OpenFromLine', xfer),
                                modal=FORMTYPE_MODAL,
                                unique=SELECT_SINGLE,
                                close=CLOSE_NO)
     link_grid_lines.add_action(xfer.request,
                                EntryAccountDel.get_action(
                                    TITLE_DELETE, "images/delete.png"),
                                modal=FORMTYPE_MODAL,
                                unique=SELECT_MULTI,
                                close=CLOSE_NO)
     link_grid_lines.add_action(xfer.request,
                                ActionsManage.get_action_url(
                                    'accounting.EntryAccount', 'Close',
                                    xfer),
                                modal=FORMTYPE_MODAL,
                                unique=SELECT_MULTI,
                                close=CLOSE_NO)
     link_grid_lines.add_action(xfer.request,
                                ActionsManage.get_action_url(
                                    'accounting.EntryAccount', 'Link',
                                    xfer),
                                modal=FORMTYPE_MODAL,
                                unique=SELECT_MULTI,
                                close=CLOSE_NO)
Beispiel #5
0
 def show(self, xfer):
     AbstractContactEditor.show(self, xfer)
     obj_user = xfer.get_components('user')
     obj_user.colspan = 2
     xfer.tab = obj_user.tab
     btn = XferCompButton('userbtn')
     btn.is_mini = True
     btn.set_location(obj_user.col + 2, obj_user.row, 1, 1)
     if self.item.user is None:
         act = ActionsManage.get_action_url('CORE.LucteriosUser', 'UserAdd',
                                            xfer)
         act.set_value("", "images/add.png")
         btn.set_action(xfer.request,
                        act,
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_NO)
     else:
         act = ActionsManage.get_action_url('CORE.LucteriosUser', 'Edit',
                                            xfer)
         act.set_value("", "images/edit.png")
         btn.set_action(xfer.request,
                        act,
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_NO,
                        params={
                            'user_actif': six.text_type(self.item.user.id),
                            'IDENT_READ': 'YES'
                        })
     xfer.add_component(btn)
Beispiel #6
0
def thirdaddon_accounting(item, xfer):
    if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'):
        try:
            entry_lines_filter = Q(entrylineaccount__third=item)
            lines_filter = xfer.getparam('lines_filter', 0)
            if lines_filter == 0:
                entry_lines_filter &= Q(year=FiscalYear.get_current())
            elif lines_filter == 1:
                entry_lines_filter &= Q(year=FiscalYear.get_current()) & Q(close=False)
            xfer.new_tab(_('entry of account'))
            lbl = XferCompLabelForm('lbl_lines_filter')
            lbl.set_value_as_name(_('Accounts filter'))
            lbl.set_location(0, 1)
            xfer.add_component(lbl)
            edt = XferCompSelect("lines_filter")
            edt.set_select([(0, _('All entries of current fiscal year')), (1, _(
                'Only no-closed entries of current fiscal year')), (2, _('All entries for all fiscal year'))])
            edt.set_value(lines_filter)
            edt.set_location(1, 1)
            edt.set_action(xfer.request, xfer.get_action(),
                           modal=FORMTYPE_REFRESH, close=CLOSE_NO)
            xfer.add_component(edt)
            entries = EntryAccount.objects.filter(entry_lines_filter)
            link_grid_lines = XferCompGrid('entryaccount')
            link_grid_lines.set_model(entries, EntryAccount.get_default_fields(), xfer)
            link_grid_lines.set_location(0, 2, 2)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'OpenFromLine', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Link', xfer),
                                       modal=FORMTYPE_MODAL, unique=SELECT_MULTI, close=CLOSE_NO)
            xfer.add_component(link_grid_lines)
        except LucteriosException:
            pass
Beispiel #7
0
 def fillresponse(self):
     self.fields_desc.initial(self.item)
     self.read_criteria_from_params()
     self.fillresponse_add_title()
     self.fillresponse_search_select()
     self.fillresponse_search_values()
     self.fillresponse_show_criteria()
     row = self.get_max_row()
     if isinstance(self.filter, Q) and (len(self.filter.children) > 0):
         self.items = self.model.objects.filter(
             self.filter)
     else:
         self.items = self.model.objects.all()
     grid = XferCompGrid(self.field_id)
     grid.set_model(self.items, self.fieldnames, self)
     grid.add_actions(self, action_list=self.action_grid)
     grid.set_location(0, row + 4, 4)
     grid.set_size(200, 500)
     self.add_component(grid)
     lbl = XferCompLabelForm("nb")
     lbl.set_location(0, row + 5, 4)
     lbl.set_value(_("Total number of %(name)s: %(count)d") % {
                   'name': self.model._meta.verbose_name_plural, 'count': grid.nb_lines})
     self.add_component(lbl)
     for act_type, title, icon in self.action_list:
         self.add_action(ActionsManage.get_act_changed(
             self.model.__name__, act_type, title, icon), {'close': CLOSE_NO})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Beispiel #8
0
 def fillresponse(self):
     modal_name = self.item.contact.__class__.get_long_name()
     field_id = self.item.contact.__class__.__name__.lower()
     if field_id == 'legalentity':
         field_id = 'legal_entity'
     self.redirect_action(ActionsManage.get_action_url(modal_name, 'Show', self), close=CLOSE_NO,
                          params={field_id: six.text_type(self.item.contact.id)})
Beispiel #9
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
Beispiel #10
0
 def _entryline_editor(self, xfer, serial_vals, debit_rest, credit_rest):
     last_row = xfer.get_max_row() + 5
     lbl = XferCompLabelForm('sep1')
     lbl.set_location(0, last_row, 6)
     lbl.set_value("{[center]}{[hr/]}{[/center]}")
     xfer.add_component(lbl)
     lbl = XferCompLabelForm('sep2')
     lbl.set_location(1, last_row + 1, 5)
     lbl.set_value_center(_("Add a entry line"))
     xfer.add_component(lbl)
     entry_line = EntryLineAccount()
     entry_line.editor.edit_line(xfer, 0, last_row + 2, debit_rest, credit_rest)
     if entry_line.has_account:
         btn = XferCompButton('entrybtn')
         btn.set_location(3, last_row + 5)
         btn.set_action(xfer.request, ActionsManage.get_action_url(
             'accounting.EntryLineAccount', 'Add', xfer), close=CLOSE_YES)
         xfer.add_component(btn)
     self.item.editor.show(xfer)
     grid_lines = xfer.get_components('entrylineaccount')
     xfer.remove_component('entrylineaccount')
     new_grid_lines = XferCompGrid('entrylineaccount_serial')
     new_grid_lines.set_model(self.item.get_entrylineaccounts(serial_vals), None, xfer)
     new_grid_lines.set_location(grid_lines.col, grid_lines.row, grid_lines.colspan + 2, grid_lines.rowspan)
     new_grid_lines.add_action_notified(xfer, EntryLineAccount)
     xfer.add_component(new_grid_lines)
     nb_lines = len(new_grid_lines.record_ids)
     return nb_lines
Beispiel #11
0
 def show(self, xfer):
     row = xfer.get_max_row() + 1
     lbl = XferCompLabelForm('lbl_entrylineaccount')
     lbl.set_location(1, row)
     lbl.set_value_as_name(EntryLineAccount._meta.verbose_name)
     xfer.add_component(lbl)
     comp = XferCompGrid('entryaccount')
     comp.set_model(EntryAccount.objects.filter(entrylineaccount__account=self.item), None, xfer)
     comp.add_action(xfer.request, ActionsManage.get_action_url(
         'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_NO)
     comp.add_action(xfer.request, ActionsManage.get_action_url('accounting.EntryAccount', 'Close', xfer), unique=SELECT_MULTI, close=CLOSE_NO)
     if self.item.is_third:
         comp.add_action(xfer.request, ActionsManage.get_action_url(
             'accounting.EntryAccount', 'Link', xfer), unique=SELECT_MULTI, close=CLOSE_NO)
     comp.set_location(2, row)
     xfer.add_component(comp)
Beispiel #12
0
 def fillresponse(self):
     if "SAVE" in self.params.keys():
         del self.params["SAVE"]
     if self.has_changed:
         self.item.editor.before_save(self)
         try:
             self.item.save()
             self.has_changed = False
             if self.fill_manytomany_fields():
                 self.item.save()
         except IntegrityError as err:
             getLogger("lucterios.core.container").info("%s", err)
             six.print_(err)
             self.raise_except(_("This record exists yet!"),
                               self.raise_except_class)
     if self.except_msg == '':
         self.item.editor.saving(self)
     if self.getparam('URL_TO_REDIRECT') is not None:
         url_text = self.getparam('URL_TO_REDIRECT')
         self.redirect_action(WrapAction('', '', url_text=url_text),
                              params={self.field_id: self.item.id})
     elif isinstance(self.redirect_to_show, six.text_type):
         self.redirect_action(ActionsManage.get_action_url(
             self.model.get_long_name(), self.redirect_to_show, self),
                              params={self.field_id: self.item.id})
Beispiel #13
0
def conf_wizard_accounting(wizard_ident, xfer):
    if isinstance(wizard_ident, list) and (xfer is None):
        wizard_ident.append(("accounting_params", 21))
        wizard_ident.append(("accounting_fiscalyear", 22))
        wizard_ident.append(("accounting_journal", 23))
    elif (xfer is not None) and (wizard_ident == "accounting_params"):
        xfer.add_title(_("Diacamma accounting"), _('Parameters'), _('Configuration of accounting parameters'))
        select_account_system(xfer)
        fill_params(xfer, True)
    elif (xfer is not None) and (wizard_ident == "accounting_fiscalyear"):
        xfer.add_title(_("Diacamma accounting"), _('Fiscal year list'), _('Configuration of fiscal years'))
        xfer.fill_grid(5, FiscalYear, 'fiscalyear', FiscalYear.objects.all())
        try:
            current_year = FiscalYear.get_current()
            nb_account = len(ChartsAccount.objects.filter(year=current_year))
            lbl = XferCompLabelForm('nb_account')
            lbl.set_value(_("Total of charts of accounts in current fiscal year: %d") % nb_account)
            lbl.set_location(0, 10)
            xfer.add_component(lbl)
            if nb_account == 0:
                xfer.item = ChartsAccount()
                xfer.item.year = current_year
                btn = XferCompButton('initialfiscalyear')
                btn.set_location(1, 10)
                btn.set_action(xfer.request, ActionsManage.get_action_url(ChartsAccount.get_long_name(), 'AccountInitial', xfer), close=CLOSE_NO)
                xfer.add_component(btn)
        except LucteriosException as lerr:
            lbl = XferCompLabelForm('nb_account')
            lbl.set_value(six.text_type(lerr))
            lbl.set_location(0, 10, 2)
            xfer.add_component(lbl)
    elif (xfer is not None) and (wizard_ident == "accounting_journal"):
        xfer.add_title(_("Diacamma accounting"), _('Journals'), _('Configuration of journals'))
        xfer.fill_grid(5, Journal, 'journal', Journal.objects.all())
Beispiel #14
0
 def fillresponse(self):
     img_title = XferCompImage('img')
     img_title.set_location(0, 0, 1, 6)
     img_title.set_value(self.icon_path())
     self.add_component(img_title)
     lab = XferCompLabelForm('title')
     lab.set_location(1, 0, 2)
     lab.set_value_as_title(_("Print models"))
     self.add_component(lab)
     self.fill_from_model(2, 1, False, ['name'])
     self.fill_from_model(2, 2, True, ['kind'])
     self.item.mode = int(self.item.mode)
     if self.item.kind == 1:
         self.fill_from_model(2, 3, False, ['mode'])
         self.get_components('mode').set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
         if (self.item.mode == 1) and (self.item.value[:6] != '<model'):
             self.item.value = "<model>\n<body>\n<text>%s</text></body>\n</model>" % self.item.value
     if self.item.kind == 0:
         self._fill_listing_editor()
     elif (self.item.kind == 1) and (self.item.mode == 0):
         self._fill_label_editor()
     elif (self.item.kind == 2) or ((self.item.kind == 1) and (self.item.mode == 1)):
         self._fill_report_editor()
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_EDIT, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Beispiel #15
0
    def show(self, xfer):
        xfer.params['supporting'] = self.item.id
        third = xfer.get_components('thirdtotal')
        xfer.tab = third.tab
        btn = XferCompButton('show_third')
        btn.set_location(third.col + third.colspan, third.row)
        act_btn = ActionsManage.get_action_url('accounting.Third', 'Show',
                                               xfer)
        if act_btn is not None:
            act_btn.caption = _('third')
        btn.set_action(xfer.request,
                       act_btn,
                       modal=FORMTYPE_MODAL,
                       close=CLOSE_NO,
                       params={'third': self.item.third.id})
        btn.rowspan = 2
        xfer.add_component(btn)

        lots = xfer.get_components('propertylot')
        lots.actions = []
        lots.delete_header('owner')

        if hasattr(xfer.item.third.contact.get_final_child(),
                   'structure_type'):
            contact = xfer.get_components('ownercontact')
            xfer.tab = contact.tab
            old_item = xfer.item
            xfer.item = old_item.third.contact.get_final_child()
            xfer.filltab_from_model(contact.col, contact.row + 1, True,
                                    ['responsability_set'])
            xfer.item = old_item

        self._show_entryline(xfer)
        self._show_current_class_loads(xfer)
        self._show_call_payoff(xfer)
Beispiel #16
0
    def edit(self, xfer):
        if xfer.item.id is None:
            third = xfer.get_components('third')
            xfer.remove_component('third')
            xfer.remove_component('lbl_third')
            lbl = XferCompLabelForm('lbl_third')
            lbl.set_location(third.col - 1, third.row)
            lbl.set_value_as_name(_('third'))
            xfer.add_component(lbl)

            sel = XferCompSelect('third')
            sel.needed = True
            sel.set_location(third.col, third.row)
            owner_third_ids = []
            for owner in Owner.objects.all():
                owner_third_ids.append(owner.third_id)
            items = Third.objects.all().exclude(id__in=owner_third_ids).distinct()
            items = sorted(items, key=lambda t: six.text_type(t))
            sel.set_select_query(items)
            xfer.add_component(sel)
            btn = XferCompButton('add_third')
            btn.set_location(3, 0)
            btn.set_is_mini(True)
            btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Add', xfer), close=CLOSE_NO,
                           modal=FORMTYPE_MODAL, params={'new_account': Params.getvalue('condominium-default-owner-account')})
            xfer.add_component(btn)
        else:
            xfer.change_to_readonly('third')
Beispiel #17
0
 def add_action_notified(self, xfer_custom, model=None):
     from lucterios.framework.xferadvance import action_list_sorted
     if model is None:
         model = xfer_custom.model.get_long_name()
     elif hasattr(model, "get_long_name"):
         model = model.get_long_name()
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_GRID, xfer_custom, model, key=action_list_sorted, gridname=self.name):
         self.add_action(xfer_custom.request, act, **opt)
Beispiel #18
0
 def add_action_notified(self, xfer_custom, model=None):
     from lucterios.framework.xferadvance import action_list_sorted
     if model is None:
         model = xfer_custom.model.get_long_name()
     elif hasattr(model, "get_long_name"):
         model = model.get_long_name()
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_GRID, xfer_custom, model, key=action_list_sorted, gridname=self.name):
         self.add_action(xfer_custom.request, act, **opt)
Beispiel #19
0
def add_auditlogs_button(xfer, model, posx, posy):
    if xfer.with_auditlog_btn and LucteriosLogEntry.objects.get_for_model(model).count() > 0:
        btn = XferCompButton('auditlogbtn')
        btn.set_action(xfer.request, ActionsManage.get_action_url(LucteriosLogEntry.get_long_name(), 'Show', xfer),
                       modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'model': model.get_long_name()})
        btn.set_is_mini(True)
        btn.set_location(posx, posy)
        xfer.add_component(btn)
Beispiel #20
0
 def fillresponse(self):
     self.redirect_action(ActionsManage.get_action_url(
         'payoff.Supporting', 'Email', self),
                          close=CLOSE_NO,
                          params={
                              'item_name': self.field_id,
                              "modelname": self.model.get_long_name()
                          })
Beispiel #21
0
 def fillresponse(self, individual):
     XferSave.fillresponse(self)
     if self.except_msg == '':
         obj_indiv = Individual.objects.get(pk=individual)
         obj_indiv.user = self.item
         obj_indiv.save()
         obj_indiv.editor.saving(self)
         self.redirect_action(ActionsManage.get_action_url('CORE.LucteriosUser', 'Edit', self),
                              params={'user_actif': six.text_type(self.item.id), 'IDENT_READ': 'YES'})
Beispiel #22
0
 def fillresponse(self, individual):
     XferSave.fillresponse(self)
     if self.except_msg == '':
         obj_indiv = Individual.objects.get(pk=individual)
         obj_indiv.user = self.item
         obj_indiv.save()
         obj_indiv.editor.saving(self)
         self.redirect_action(ActionsManage.get_action_url('CORE.LucteriosUser', 'Edit', self),
                              params={'user_actif': six.text_type(self.item.id), 'IDENT_READ': 'YES'})
Beispiel #23
0
 def show(self, xfer):
     AbstractContactEditor.show(self, xfer)
     obj_user = xfer.get_components('user')
     obj_user.colspan = 2
     xfer.tab = obj_user.tab
     btn = XferCompButton('userbtn')
     btn.is_mini = True
     btn.set_location(obj_user.col + 2, obj_user.row, 1, 1)
     if self.item.user is None:
         act = ActionsManage.get_action_url('CORE.LucteriosUser', 'UserAdd', xfer)
         act.set_value("", "images/add.png")
         btn.set_action(xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO)
     else:
         act = ActionsManage.get_action_url('CORE.LucteriosUser', 'Edit', xfer)
         act.set_value("", "images/edit.png")
         btn.set_action(xfer.request, act, modal=FORMTYPE_MODAL, close=CLOSE_NO,
                        params={'user_actif': six.text_type(self.item.user.id), 'IDENT_READ': 'YES'})
     xfer.add_component(btn)
Beispiel #24
0
 def fillresponse(self):
     current_contact = self.item.contact.get_final_child()
     modal_name = current_contact.__class__.get_long_name()
     field_id = current_contact.__class__.__name__.lower()
     self.redirect_action(
         ActionsManage.get_action_url(modal_name, 'Show', self),
         modal=FORMTYPE_MODAL,
         close=CLOSE_NO,
         params={field_id: six.text_type(current_contact.id)})
Beispiel #25
0
 def fillresponse(self):
     XferShowEditor.fillresponse(self)
     self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                  'Show', self),
                     close=CLOSE_NO,
                     params={
                         'item_name': 'callfundssupporting',
                         'callfundssupporting': self.item.supporting_id
                     },
                     pos_act=0)
     self.add_action(ActionsManage.get_action_url('payoff.Supporting',
                                                  'Email', self),
                     close=CLOSE_NO,
                     params={
                         'item_name': 'callfundssupporting',
                         'callfundssupporting': self.item.supporting_id
                     },
                     pos_act=0)
Beispiel #26
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
Beispiel #27
0
 def show(self, xfer):
     xfer.params['supporting'] = self.item.id
     third = xfer.get_components('third')
     xfer.tab = third.tab
     btn = XferCompButton('show_third')
     btn.set_location(third.col + third.colspan, third.row)
     btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Show', xfer),
                    modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'third': self.item.third.id})
     xfer.add_component(btn)
     lblpartition = xfer.get_components('lbl_partition_set')
     lblpartition.value = _("current class loads")
     partition = xfer.get_components('partition')
     partition.actions = []
     partition.delete_header('owner')
     lots = xfer.get_components('propertylot')
     lots.actions = []
     lots.delete_header('owner')
     callfunds = xfer.get_components('callfunds')
     callfunds.actions = []
     callfunds.add_action(xfer.request, ActionsManage.get_action_url('condominium.CallFunds', 'Show', xfer), close=CLOSE_NO, unique=SELECT_SINGLE)
Beispiel #28
0
def add_auditlog_button(xfer, instance, posx, posy):
    if xfer.with_auditlog_btn and LucteriosLogEntry.objects.get_for_object(instance).count() > 0:
        btn = XferCompButton('auditlogbtn')
        btn.set_action(xfer.request, ActionsManage.get_action_url(LucteriosLogEntry.get_long_name(), 'Show', xfer),
                       modal=FORMTYPE_MODAL, close=CLOSE_NO, params={'model': instance.__class__.get_long_name(),
                                                                     'objid': instance.id})
        btn.set_is_mini(True)
        btn.set_location(posx, posy)
        if xfer.tab > 0:
            xfer.tab = 1
        xfer.add_component(btn)
Beispiel #29
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"])
Beispiel #30
0
 def fillresponse(self):
     if self.item.id is None:
         raise LucteriosException(IMPORTANT, _("This record not exist!\nRefresh your application."))
     max_row = self.get_max_row() + 1
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, max_row, True)
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_SHOW, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(_('Close'), 'images/close.png'))
Beispiel #31
0
 def fillresponse(self, field_id):
     self.items = self.model.objects.filter(
         id__in=self.getparam(field_id, ()))
     if len(self.items) < 2:
         raise LucteriosException(
             IMPORTANT, _("Impossible: you must to select many records!"))
     if self.item.id is None:
         self.item = self.items[0]
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         grid = XferCompGrid(self.field_id)
         grid.add_header('value', _('designation'))
         grid.add_header('select', _('is main?'), 'bool')
         for item in self.items:
             grid.set_value(item.id, 'value', six.text_type(item))
             grid.set_value(item.id, 'select', item.id == self.item.id)
         grid.set_location(1, 1)
         grid.add_action(self.request, self.get_action(_("Edit"), "images/show.png"), {
                         'modal': FORMTYPE_MODAL, 'close': CLOSE_NO, 'unique': SELECT_SINGLE, 'params': {"CONFIRME": 'OPEN'}})
         grid.add_action(self.request, self.get_action(
             _("Select"), "images/ok.png"), {'modal': FORMTYPE_REFRESH, 'close': CLOSE_NO, 'unique': SELECT_SINGLE})
         dlg.add_component(grid)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"),
                        {'close': CLOSE_YES, 'modal': FORMTYPE_MODAL, 'params': {'CONFIRME': 'YES', self.field_id: self.item.id}})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"), {})
     elif self.getparam("CONFIRME") == 'YES':
         alias_objects = []
         for item in self.items:
             if item.id != self.item.id:
                 alias_objects.append(item.get_final_child())
         self.item.get_final_child().merge_objects(alias_objects)
         self.redirect_action(ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
     else:
         self.redirect_action(ActionsManage.get_act_changed(self.model.__name__, 'show', '', ''), {
                              'params': {field_id: self.item.id}})
Beispiel #32
0
 def fillresponse(self, field_id):
     self.items = self.model.objects.filter(id__in=self.getparam(field_id, ())).distinct()
     if len(self.items) < 2:
         raise LucteriosException(IMPORTANT, _("Impossible: you must to select many records!"))
     item_id = self.getparam('mrg_' + self.field_id, 0)
     if item_id != 0:
         self.item = self.model.objects.get(id=item_id)
     if (self.item is None) or (self.item.id is None):
         self.item = self.items[0]
     if self.getparam("CONFIRME") is None:
         dlg = self.create_custom()
         lbl = XferCompLabelForm('title')
         lbl.set_value_as_title(self.caption)
         lbl.set_location(1, 0)
         dlg.add_component(lbl)
         grid = XferCompGrid('mrg_' + self.field_id)
         grid.add_header('value', _('designation'))
         grid.add_header('select', _('is main?'), 'B')
         for item in self.items:
             grid.set_value(item.id, 'value', six.text_type(item))
             grid.set_value(item.id, 'select', item.id == self.item.id)
         grid.set_location(1, 1)
         grid.add_action(self.request, self.get_action(_("Edit"), "images/show.png"),
                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE, params={"CONFIRME": 'OPEN'})
         grid.add_action(self.request, self.get_action(_("Select"), "images/ok.png"),
                         modal=FORMTYPE_REFRESH, close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.add_component(grid)
         dlg.add_action(self.get_action(_('Ok'), "images/ok.png"), close=CLOSE_YES, modal=FORMTYPE_MODAL,
                        params={'CONFIRME': 'YES', 'mrg_' + self.field_id: self.item.id})
         dlg.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
     elif self.getparam("CONFIRME") == 'YES':
         alias_objects = []
         for item in self.items:
             if item.id != self.item.id:
                 alias_objects.append(item.get_final_child())
         self.item.get_final_child().merge_objects(alias_objects)
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self), params={field_id: self.item.id})
     else:
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), 'Show', self), params={field_id: self.item.id})
Beispiel #33
0
 def fillresponse(self):
     if self.item.id is None:
         raise LucteriosException(IMPORTANT, _("This record not exist!\nRefresh your application."))
     max_row = self.get_max_row() + 1
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, max_row, True)
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_SHOW, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(_('Close'), 'images/close.png'))
     add_auditlog_button(self, self.item, 0, max(6, self.get_max_row()) + 20)
Beispiel #34
0
 def fill_confirm(self, transition, trans):
     withpayoff = self.getparam('withpayoff', True)
     if (transition != 'valid') or (self.item.bill_type == 0):
         XferTransition.fill_confirm(self, transition, trans)
         if transition == 'cancel':
             if self.trans_result is not None:
                 self.redirect_action(ActionsManage.get_action_url('invoice.Bill', 'Show', self), params={self.field_id: self.trans_result})
     elif self.getparam("CONFIRME") is None:
         self.fill_dlg_payoff(withpayoff)
     else:
         XferTransition.fill_confirm(self, transition, trans)
         if (self.item.bill_type != 0) and withpayoff:
             Payoff.multi_save((self.item.id,), self.getparam('amount', 0.0), self.getparam('mode', 0), self.getparam('payer'),
                               self.getparam('reference'), self.getparam('bank_account', 0), self.getparam('date_payoff'))
Beispiel #35
0
 def fillresponse(self):
     if self.is_new:
         self.caption = self.caption_add
     else:
         self.caption = self.caption_modify
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, 0, False)
     if len(self.actions) == 0:
         self.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"})
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_EDIT, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
Beispiel #36
0
 def _show_current_class_loads(self, xfer):
     partition = xfer.get_components('partition')
     partition.actions = []
     partition.description = _("current class loads")
     partition.delete_header('owner')
     xfer.tab = partition.tab
     row = xfer.get_max_row() + 1
     btn = XferCompButton('show_load_count')
     btn.set_location(partition.col, row)
     btn.set_action(xfer.request,
                    ActionsManage.get_action_url('condominium.Owner',
                                                 'LoadCount', xfer),
                    modal=FORMTYPE_MODAL,
                    close=CLOSE_NO)
     xfer.add_component(btn)
Beispiel #37
0
 def fillresponse(self):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0)
     self.add_component(lbl)
     self.fillresponse_header()
     self.fillresponse_body()
     if self.model is not None:
         for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_LIST, self, key=action_list_sorted):
             self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Beispiel #38
0
def thirdaddon_invoice(item, xfer):
    if WrapAction.is_permission(xfer.request, 'invoice.change_bill'):
        try:
            FiscalYear.get_current()
            xfer.new_tab(_('Invoice'))
            current_filter, status_filter = _add_bill_filter(xfer, 1)
            current_filter &= Q(third=item)
            bills = Bill.objects.filter(current_filter)
            bill_grid = XferCompGrid('bill')
            bill_grid.set_model(bills, Bill.get_default_fields(status_filter), xfer)
            bill_grid.set_location(0, 2, 2)
            bill_grid.add_action(xfer.request, ActionsManage.get_action_url('invoice.Bill', 'Show', xfer), modal=FORMTYPE_MODAL, unique=SELECT_SINGLE, close=CLOSE_NO)
            xfer.add_component(bill_grid)
        except LucteriosException:
            pass
Beispiel #39
0
 def fillresponse(self):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0)
     self.add_component(lbl)
     self.fillresponse_header()
     self.fillresponse_body()
     add_auditlogs_button(self, self.model, 0, self.get_max_row() + 20)
     if self.model is not None:
         for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_LIST, self, key=action_list_sorted):
             self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
Beispiel #40
0
 def fillresponse(self):
     if self.is_new:
         self.caption = self.caption_add
     else:
         self.caption = self.caption_modify
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, 0, False)
     if len(self.actions) == 0:
         self.add_action(self.get_action(TITLE_OK, 'images/ok.png'), params={"SAVE": "YES"})
     for act, opt in ActionsManage.get_actions(ActionsManage.ACTION_IDENT_EDIT, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
     add_auditlog_button(self, self.item, 0, max(6, self.get_max_row()) + 20)
Beispiel #41
0
 def _show_call_payoff(self, xfer):
     callfunds = xfer.get_components('callfunds')
     callfunds.actions = []
     callfunds.colspan = 3
     callfunds.add_action(xfer.request,
                          ActionsManage.get_action_url(
                              'condominium.CallFunds', 'Show', xfer),
                          close=CLOSE_NO,
                          unique=SELECT_SINGLE)
     payments = xfer.get_components('payments')
     payments.colspan = 3
     payments.move_action('diacamma.condominium/paymentDel', -1)
     payoff = xfer.get_components('payoff')
     payoff.colspan = 3
     payoff.actions = []
     payoff.description = _('additional payoffs')
Beispiel #42
0
 def fillresponse(self):
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0)
     self.add_component(img)
     lbl = XferCompLabelForm('title')
     lbl.set_value_as_title(self.caption)
     lbl.set_location(1, 0)
     self.add_component(lbl)
     self.fillresponse_header()
     self.fillresponse_body()
     if self.model is not None:
         for act_type, title, icon in self.action_list:
             self.add_action(ActionsManage.get_act_changed(
                 self.model.__name__, act_type, title, icon), {'close': CLOSE_NO})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Beispiel #43
0
 def show(self, xfer):
     xfer.tab = 0
     old_item = xfer.item
     xfer.item = self.item.contact.get_final_child()
     xfer.filltab_from_model(1, 1, True, ['address', ('postal_code', 'city'), 'country', ('tel1', 'tel2')])
     btn = XferCompButton('show')
     btn.set_location(2, 5, 3, 1)
     modal_name = xfer.item.__class__.get_long_name()
     field_id = xfer.item.__class__.__name__.lower()
     if field_id == 'legalentity':
         field_id = 'legal_entity'
     btn.set_action(xfer.request, ActionsManage.get_action_url(modal_name, 'Show', xfer), close=CLOSE_NO,
                    params={field_id: six.text_type(xfer.item.id)})
     xfer.add_component(btn)
     xfer.item = old_item
     Signal.call_signal("third_addon", self.item, xfer)
Beispiel #44
0
 def fillresponse(self):
     max_row = self.get_max_row() + 1
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 6)
     self.add_component(img)
     self.fill_from_model(1, max_row, True)
     for action_item in self.action_list:
         act_type, title, icon, close = action_item[:4]
         if len(action_item) > 4:
             params = action_item[4]
         else:
             params = {}
         self.add_action(ActionsManage.get_act_changed(
             self.model.__name__, act_type, title, icon), {'close': close, 'params': params})
     self.add_action(WrapAction(_('Close'), 'images/close.png'), {})
Beispiel #45
0
 def show_third_ex(self, xfer):
     xfer.params["supporting"] = self.item.id
     third = xfer.get_components("third")
     third.colspan -= 1
     if self.item.third is not None:
         btn = XferCompButton("show_third")
         btn.set_is_mini(True)
         btn.set_location(third.col + third.colspan, third.row)
         btn.set_action(
             xfer.request,
             ActionsManage.get_action_url("accounting.Third", "Show", xfer),
             modal=FORMTYPE_MODAL,
             close=CLOSE_NO,
             params={"third": self.item.third.id},
         )
         xfer.add_component(btn)
Beispiel #46
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_act_changed(self.model.__name__, 'show', '', ''), {})
Beispiel #47
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"])
Beispiel #48
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))
Beispiel #49
0
 def show(self, xfer):
     destination_file = join("documents",
                             "document_%s" % six.text_type(self.item.id))
     if not isfile(join(get_user_dir(), destination_file)):
         raise LucteriosException(IMPORTANT, _("File not found!"))
     obj_cmt = xfer.get_components('creator')
     down = XferCompDownLoad('filename')
     down.compress = True
     down.http_file = True
     down.maxsize = 0
     down.set_value(self.item.name)
     down.set_download(destination_file)
     down.set_action(xfer.request,
                     ActionsManage.get_action_url('documents.Document',
                                                  'AddModify', xfer),
                     modal=FORMTYPE_MODAL,
                     close=CLOSE_NO)
     down.set_location(obj_cmt.col, obj_cmt.row + 1, 4)
     xfer.add_component(down)
Beispiel #50
0
 def edit(self, xfer):
     IndividualEditor.edit(self, xfer)
     birthday = xfer.get_components('birthday')
     if birthday is not None:
         birthday.needed = True
     if (self.item.id is None) and (xfer.getparam(
             'legal_entity',
             0) == 0) and (Params.getobject("member-family-type")
                           is not None):
         genre = xfer.get_components('genre')
         genre.colspan -= 1
         btn = XferCompButton('famillybtn')
         btn.set_location(genre.col + genre.colspan, genre.row)
         btn.set_action(xfer.request,
                        ActionsManage.get_action_url(
                            'member.Adherent', 'familyAdherentAdd', xfer),
                        modal=FORMTYPE_MODAL,
                        close=CLOSE_YES)
         xfer.add_component(btn)
Beispiel #51
0
 def fillresponse(self):
     self.fields_desc.initial(self.item)
     self.read_criteria_from_params()
     self.fillresponse_add_title()
     self.fillresponse_search_select()
     self.fillresponse_search_values()
     self.fillresponse_show_criteria()
     row = self.get_max_row()
     self.filter_items()
     grid = XferCompGrid(self.field_id)
     grid.set_model(self.items, self.fieldnames, self)
     grid.add_action_notified(self)
     grid.set_location(0, row + 4, 6)
     grid.set_size(200, 500)
     self.add_component(grid)
     for act, opt in ActionsManage.get_actions(
             ActionsManage.ACTION_IDENT_LIST, self, key=action_list_sorted):
         self.add_action(act, **opt)
     self.add_action(WrapAction(_('Close'), 'images/close.png'))
Beispiel #52
0
 def fillresponse(self):
     if "SAVE" in self.params.keys():
         del self.params["SAVE"]
     if self.has_changed:
         self.item.editor.before_save(self)
         try:
             self.item.save()
             self.has_changed = False
             if self.fill_manytomany_fields():
                 self.item.save()
         except IntegrityError as err:
             getLogger("lucterios.core.container").info("%s", err)
             six.print_(err)
             self.raise_except(
                 _("This record exists yet!"), self.raise_except_class)
     if self.except_msg == '':
         self.item.editor.saving(self)
     if isinstance(self.redirect_to_show, six.text_type):
         self.redirect_action(ActionsManage.get_act_changed(
             self.model.__name__, self.redirect_to_show, '', ''), {'params': {self.field_id: self.item.id}})
Beispiel #53
0
 def show(self, xfer):
     destination_file = join("documents", "document_%s" % six.text_type(self.item.id))
     if not isfile(join(get_user_dir(), destination_file)):
         raise LucteriosException(IMPORTANT, _("File not found!"))
     obj_cmt = xfer.get_components('creator')
     down = XferCompDownLoad('filename')
     down.compress = True
     down.http_file = True
     down.maxsize = 0
     down.set_value(self.item.name)
     down.set_download(destination_file)
     down.set_action(xfer.request, ActionsManage.get_action_url('documents.Document', 'AddModify', xfer),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     down.set_location(obj_cmt.col, obj_cmt.row + 1, 4)
     xfer.add_component(down)
     link = self.item.shared_link
     if link is not None:
         shared_link = XferCompEdit('shared_link')
         shared_link.description = _('shared link')
         shared_link.set_value(link)
         shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4)
         xfer.add_component(shared_link)
Beispiel #54
0
 def show(self, xfer):
     self._add_cost_savebtn(xfer)
     last_row = xfer.get_max_row() + 10
     lbl = XferCompLabelForm('sep3')
     lbl.set_location(0, last_row + 1, 6)
     lbl.set_value_center("{[hr/]}")
     xfer.add_component(lbl)
     xfer.filltab_from_model(1, last_row + 2, True, ['entrylineaccount_set'])
     grid_lines = xfer.get_components('entrylineaccount')
     grid_lines.actions = []
     if self.item.has_third:
         sum_customer = get_amount_sum(self.item.entrylineaccount_set.filter(
             account__code__regex=current_system_account().get_third_mask()).aggregate(Sum('amount')))
         if ((sum_customer < 0) and not self.item.has_cash) or ((sum_customer > 0) and self.item.has_cash):
             lbl = XferCompLabelForm('asset_warning')
             lbl.set_location(0, last_row + 3, 6)
             lbl.set_value_as_header(_("entry of accounting for an asset"))
             xfer.add_component(lbl)
     if self.item.link is not None:
         linkentries = EntryAccount.objects.filter(link=self.item.link).exclude(id=self.item.id)
         if len(linkentries) == 0:
             self.item.unlink()
         else:
             lbl = XferCompLabelForm('sep4')
             lbl.set_location(0, last_row + 4, 6)
             lbl.set_value_center("{[hr/]}")
             xfer.add_component(lbl)
             lbl = XferCompLabelForm('entrylinklab')
             lbl.set_location(1, last_row + 5, 5)
             lbl.set_value_center(_("Linked entries"))
             xfer.add_component(lbl)
             link_grid_lines = XferCompGrid('entryaccount_link')
             link_grid_lines.set_model(linkentries, fieldnames=None, xfer_custom=xfer)
             link_grid_lines.set_location(1, last_row + 6, 5)
             link_grid_lines.add_action(xfer.request, ActionsManage.get_action_url(
                 'accounting.EntryAccount', 'OpenFromLine', xfer), unique=SELECT_SINGLE, close=CLOSE_YES, params={'field_id': 'entryaccount_link', 'journal': ''})
             xfer.add_component(link_grid_lines)
     if self.added:
         xfer.add_action(xfer.get_action(TITLE_MODIFY, "images/ok.png"), params={"SAVE": "YES"})
Beispiel #55
0
 def fillresponse(self):
     if "SAVE" in self.params.keys():
         del self.params["SAVE"]
     if self.has_changed:
         self.item.editor.before_save(self)
         try:
             self.item.save()
             self.has_changed = False
             if self.fill_manytomany_fields():
                 self.item.save()
         except IntegrityError as err:
             getLogger("lucterios.core.container").info("%s", err)
             six.print_(err)
             self.raise_except(
                 _("This record exists yet!"), self.raise_except_class)
     if self.except_msg == '':
         self.item.editor.saving(self)
     if self.getparam('URL_TO_REDIRECT') is not None:
         url_text = self.getparam('URL_TO_REDIRECT')
         self.redirect_action(WrapAction('', '', url_text=url_text), params={self.field_id: self.item.id})
     elif isinstance(self.redirect_to_show, six.text_type):
         self.redirect_action(ActionsManage.get_action_url(self.model.get_long_name(), self.redirect_to_show, self),
                              params={self.field_id: self.item.id})
Beispiel #56
0
def show_contact_accounting(contact, xfer):
    if WrapAction.is_permission(xfer.request, 'accounting.change_entryaccount'):
        main_third = None
        thirds = Third.objects.filter(contact_id=contact.id)
        if len(thirds) > 1:
            main_third = thirds[0]
            alias_third = []
            for third in thirds:
                if third.id != main_third.id:
                    alias_third.append(third)
            main_third.merge_objects(alias_third)
        elif len(thirds) == 1:
            main_third = thirds[0]
        if main_third is not None:
            xfer.new_tab(_("Financial"))
            xfer.item = main_third
            xfer.filltab_from_model(0, 0, True, ["status", ((_('total'), 'total'),)])
            btn = XferCompButton('show_third')
            btn.set_location(0, 50, 2)
            btn.set_action(xfer.request, ActionsManage.get_action_url('accounting.Third', 'Show', xfer),
                           modal=FORMTYPE_MODAL, close=CLOSE_NO, params={"third": six.text_type(main_third.id)})
            xfer.add_component(btn)
            xfer.item = contact
Beispiel #57
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.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
Beispiel #58
0
 def show(self, xfer):
     if not isfile(self.item.file_path):
         raise LucteriosException(IMPORTANT, _("File not found!"))
     obj_cmt = xfer.get_components('creator')
     down = XferCompDownLoad('filename')
     down.compress = True
     down.http_file = True
     down.maxsize = 0
     down.set_value(self.item.name)
     down.set_download(self.item.file_path)
     down.set_action(xfer.request,
                     ActionsManage.get_action_url(
                         'documents.DocumentContainer', 'AddModify', xfer),
                     modal=FORMTYPE_MODAL,
                     close=CLOSE_NO)
     down.set_location(obj_cmt.col, obj_cmt.row + 1, 4)
     xfer.add_component(down)
     link = self.item.shared_link
     if link is not None:
         shared_link = XferCompEdit('shared_link')
         shared_link.description = _('shared link')
         shared_link.set_value(link)
         shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4)
         xfer.add_component(shared_link)
Beispiel #59
0
    def show(self, xfer):
        IndividualEditor.show(self, xfer)
        if xfer.getparam('adherent') is None:
            xfer.params['adherent'] = xfer.getparam('individual', 0)
        if xfer.getparam('individual') is None:
            xfer.params['individual'] = xfer.getparam('adherent', 0)
        img = xfer.get_components('img')
        img.set_value(get_icon_path("diacamma.member/images/adherent.png"))

        if xfer.item.current_subscription is not None:
            xfer.tab = 1
            row_init = xfer.get_max_row() + 1
            row = row_init + 1
            for doc in xfer.item.current_subscription.docadherent_set.all():
                lbl = XferCompLabelForm("lbl_doc_%d" % doc.id)
                lbl.set_value(six.text_type(doc.document))
                lbl.set_location(2, row)
                xfer.add_component(lbl)
                ckc = XferCompCheck("doc_%d" % doc.id)
                ckc.set_value(doc.value)
                ckc.set_location(3, row)
                xfer.add_component(ckc)
                row += 1
            if row != row_init + 1:
                lbl = XferCompLabelForm("lbl_doc_sep")
                lbl.set_value("{[hr/]}")
                lbl.set_location(1, row_init, 4)
                xfer.add_component(lbl)
                lbl = XferCompLabelForm("lbl_doc")
                lbl.set_value_as_name(_('documents needs'))
                lbl.set_location(1, row_init + 1)
                xfer.add_component(lbl)
                btn = XferCompButton("btn_doc")
                btn.set_location(4, row_init + 1, 1, row - row_init)
                btn.set_action(xfer.request, ActionsManage.get_action_url("member.Adherent", "Doc", xfer), close=CLOSE_NO)
                xfer.add_component(btn)
Beispiel #60
0
 def _initialize(self, request, *_, **kwargs):
     XferContainerCustom._initialize(self, request, *_, **kwargs)
     if isinstance(self.redirect_to_show, six.text_type):
         self.with_auditlog_btn = (ActionsManage.get_action_url(
             self.model.get_long_name(), self.redirect_to_show, self) is
                                   None)