示例#1
0
文件: xfersearch.py 项目: povtux/core
 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'), {})
示例#2
0
 def add_legalentities(self, legal_entities):
     self.new_tab(_("Legal entities"))
     grid = XferCompGrid('legal_entity')
     grid.set_model(legal_entities, LegalEntity.get_default_fields())
     grid.add_action(self.request, CurrentLegalEntityShow.get_action(
         _("Edit"), "images/show.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.set_location(1, 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
示例#3
0
 def fill_grid(self, row, model, field_id, items):
     grid = XferCompGrid(field_id)
     if self.size_by_page is not None:
         grid.size_by_page = self.size_by_page
     if self.multi_page:
         xfer = self
     else:
         xfer = None
     grid.set_model(items, self.fieldnames, xfer)
     grid.add_action_notified(self, model=model)
     grid.set_location(0, row + 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
示例#4
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('left', _('Designation'))
     if self.item.last_fiscalyear is not None:
         self.grid.add_header('left_n_1', _('year N-1'), self.hfield, 0, self.format_str)
     self.grid.add_header('left_n', _('year N'), self.hfield, 0, self.format_str)
     self.grid.add_header('space', '')
     self.grid.add_header('right', _('Designation'))
     if self.item.last_fiscalyear is not None:
         self.grid.add_header('right_n_1', _('year N-1'), self.hfield, 0, self.format_str)
     self.grid.add_header('right_n', _('year N'), self.hfield, 0, self.format_str)
     self.grid.set_location(0, 10, 6)
     self.grid.no_pager = True
     self.add_component(self.grid)
示例#5
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('design', _('Designation'))
     if self.item.last_fiscalyear is not None:
         self.grid.add_header('year_n_1', _('year N-1'), self.hfield, 0, self.format_str)
     self.grid.add_header('budget_n', _('budget N'), self.hfield, 0, self.format_str)
     self.grid.add_header('year_n', _('year N'), self.hfield, 0, self.format_str)
     if self.next_year is not None:
         self.grid.add_header('budget_n1', _('budget N+1'), self.hfield, 0, self.format_str)
     if self.next_year_again is not None:
         self.grid.add_header('budget_n2', _('budget N+2'), self.hfield, 0, self.format_str)
     self.grid.set_location(0, 10, 6)
     self.grid.no_pager = True
     self.add_component(self.grid)
示例#6
0
def show_contact_degree(contact, xfer):
    if WrapAction.is_permission(xfer.request, 'event.change_degree'):
        up_contact = contact.get_final_child()
        if isinstance(up_contact, Adherent):
            degrees = Degree.objects.filter(adherent=up_contact)
            xfer.new_tab(_("Degree"))
            grid = XferCompGrid('degrees')
            grid.set_model(degrees, None, xfer)
            grid.add_action_notified(xfer, Degree)
            grid.set_location(0, xfer.get_max_row() + 1, 2)
            grid.set_size(200, 500)
            xfer.add_component(grid)
示例#7
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('designation', _('name'))
     self.grid.add_header('total_debit', _('debit sum'))
     self.grid.add_header('total_credit', _('credit sum'))
     self.grid.add_header('solde_debit', _('debit'))
     self.grid.add_header('solde_credit', _('credit'))
示例#8
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('entry.num', _('numeros'))
     self.grid.add_header('entry.date_entry', _('date entry'))
     self.grid.add_header('entry.date_value', _('date value'))
     self.grid.add_header('entry.designation', _('name'))
     self.grid.add_header('debit', _('debit'))
     self.grid.add_header('credit', _('credit'))
示例#9
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
示例#10
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'))
示例#11
0
 def fill_grid(self, row, model, field_id, items):
     grid = XferCompGrid(field_id)
     if self.multi_page:
         xfer = self
     else:
         xfer = None
     grid.set_model(items, self.fieldnames, xfer)
     grid.add_actions(self, action_list=self.action_grid, model=model)
     grid.set_location(0, row + 1, 2)
     grid.set_size(200, 500)
     self.add_component(grid)
     lbl = XferCompLabelForm("nb_" + field_id)
     lbl.set_location(0, row + 2, 2)
     lbl.set_value(_("Total number of %(name)s: %(count)d") % {
                   'name': model._meta.verbose_name_plural, 'count': grid.nb_lines})
     self.add_component(lbl)
示例#12
0
文件: views.py 项目: julienM77/syndic
    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(2, 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)
        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, 1, True, [((_('name'), 'third'),)])
        grid = XferCompGrid('loadcount')
        grid.set_model(self.item.loadcount_set.all(), None)
        grid.set_location(1, 2, 2)
        self.add_component(grid)

        self.add_action(WrapAction(_('Close'), 'images/close.png'))
示例#13
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('left', _('Expenses'))
     self.grid.add_header('left_n', _('Value'))
     self.grid.add_header('left_b', _('Budget'))
     if self.lastfilter is not None:
         self.grid.add_header('left_n_1', _('Last'))
     self.grid.add_header('space', '')
     self.grid.add_header('right', _('Revenues'))
     self.grid.add_header('right_n', _('Value'))
     self.grid.add_header('right_b', _('Budget'))
     if self.lastfilter is not None:
         self.grid.add_header('right_n_1', _('Last'))
示例#14
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('left', _('Assets'))
     self.grid.add_header('left_n', self.item.get_identify())
     if self.lastfilter is not None:
         self.grid.add_header(
             'left_n_1', self.item.last_fiscalyear.get_identify())
     self.grid.add_header('space', '')
     self.grid.add_header('right', _('Liabilities'))
     self.grid.add_header('right_n', self.item.get_identify())
     if self.lastfilter is not None:
         self.grid.add_header(
             'right_n_1', self.item.last_fiscalyear.get_identify())
示例#15
0
 def define_gridheader(self):
     self.grid = XferCompGrid('report_%d' % self.item.id)
     self.grid.add_header('left', _('Expense'))
     self.grid.add_header('left_n', self.item.get_identify())
     self.grid.add_header('left_b', _('Budget'))
     if self.lastfilter is not None:
         self.grid.add_header(
             'left_n_1', self.item.last_fiscalyear.get_identify())
     self.grid.add_header('space', '')
     self.grid.add_header('right', _('Revenue'))
     self.grid.add_header('right_n', self.item.get_identify())
     self.grid.add_header('right_b', _('Budget'))
     if self.lastfilter is not None:
         self.grid.add_header(
             'right_n_1', self.item.last_fiscalyear.get_identify())
示例#16
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
示例#17
0
 def _show_initial_csv(self):
     tbl = XferCompGrid('CSV')
     for fieldname in self.spamreader.fieldnames:
         if fieldname != '':
             tbl.add_header(fieldname, fieldname)
     row_idx = 1
     for row in self.spamreader:
         if row[self.spamreader.fieldnames[0]] is not None:
             for fieldname in self.spamreader.fieldnames:
                 if fieldname != '':
                     tbl.set_value(row_idx, fieldname, row[fieldname])
             row_idx += 1
     tbl.set_location(1, 1, 2)
     self.add_component(tbl)
     lbl = XferCompLabelForm('nb_line')
     lbl.set_value(_("Total number of items: %d") % (row_idx - 1))
     lbl.set_location(1, 2, 2)
     self.add_component(lbl)
示例#18
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
示例#19
0
文件: views.py 项目: Diacamma2/syndic
def summary_condo(xfer):
    is_right = WrapAction.is_permission(xfer.request, 'condominium.change_set')
    owners = get_owners(xfer.request)
    if is_right or (len(owners) == 1):
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('condotitle')
        lab.set_value_as_infocenter(_('Condominium'))
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
    if len(owners) == 1:
        lab = XferCompLabelForm('condoowner')
        lab.set_value(_('You are a owner'))
        lab.set_location(0, row + 1, 2)
        xfer.add_component(lab)
        grid = XferCompGrid("part")
        grid.set_model(owners[0].partition_set.filter(set__is_active=True), ["set", "value", (_("ratio"), 'ratio')])
        grid.set_location(0, row + 2, 4)
        grid.set_size(200, 500)
        xfer.add_component(grid)
    if is_right:
        row = xfer.get_max_row() + 1
        nb_set = len(Set.objects.filter(is_active=True))
        nb_owner = len(Owner.objects.all())
        lab = XferCompLabelForm('condoinfo')
        lab.set_value_as_header(_("There are %(set)d classes of loads for %(owner)d owners") % {'set': nb_set, 'owner': nb_owner})
        lab.set_location(0, row + 1, 4)
        xfer.add_component(lab)
        if Params.getvalue("condominium-old-accounting"):
            lab = XferCompLabelForm('condoconvinfo')
            lab.set_value_as_header(_("Your condominium account is not in respect of French law{[newline]}An conversion is necessary."))
            lab.set_color('red')
            lab.set_location(0, row + 2, 4)
            xfer.add_component(lab)
            btn = XferCompButton('condoconv')
            btn.set_location(0, row + 3, 4)
            btn.set_action(xfer.request, CondominiumConvert.get_action(_('Convertion ...'), ""), close=CLOSE_NO)
            xfer.add_component(btn)
    if is_right or (len(owners) == 1):
        row = xfer.get_max_row() + 1
        lab = XferCompLabelForm('condosep')
        lab.set_value_as_infocenter("{[hr/]}")
        lab.set_location(0, row, 4)
        xfer.add_component(lab)
        return True
    else:
        return False
示例#20
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"})
示例#21
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})
示例#22
0
    def show(self, xfer):
        obj_body = xfer.get_components('body')
        obj_body.value = "{[div style='border:1px solid black;background-color:#EEE;padding:5px;']}%s{[div]}" % obj_body.value

        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        new_recipients.set_location(obj_recipients.col, obj_recipients.row, obj_recipients.colspan)
        new_recipients.add_header("model", _('model'))
        new_recipients.add_header("filter", _('filter'))
        compid = 0
        for model_title, filter_desc in self.item.recipients_description:
            new_recipients.set_value(compid, "model", model_title)
            new_recipients.set_value(compid, "filter", filter_desc)
            compid += 1
        if compid == 0:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('attachments')
        xfer.remove_component('attachments')
        if xfer.item.is_dynamic:
            xfer.remove_component('__tab_3')
            xfer.remove_component('doc_in_link')
            xfer.remove_component('empty')
        else:
            new_documents = XferCompGrid('attachments')
            new_documents.tab = old_documents.tab
            new_documents.set_location(old_documents.col, old_documents.row, old_documents.colspan)
            new_documents.set_model(self.item.attachments.all(), ["name", "description", "date_modification"], xfer)
            new_documents.add_action(xfer.request, DocumentShow.get_action(TITLE_EDIT, "images/show.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
            if self.item.status == 0:
                new_documents.add_action(xfer.request, MessageRemoveDoc.get_action(_("Remove"), "images/delete.png"),
                                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_MULTI)
                new_documents.add_action(xfer.request, MessageInsertDoc.get_action(_("Insert"), "images/add.png"),
                                         modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_NONE)
            xfer.tab = new_documents.tab
            xfer.add_component(new_documents)
        contact_nb = xfer.get_components('contact_nb')
        if (contact_nb is not None) and (self.item.nb_total > 0):
            xfer.tab = contact_nb.tab
            xfer.fill_from_model(contact_nb.col, contact_nb.row + 1, True, [((_('statistic'), 'statistic'),)])
        return LucteriosEditor.show(self, xfer)
示例#23
0
 def fill_articles(self):
     articles_result = self.item.get_statistics_article()
     grid = XferCompGrid("articles")
     grid.add_header("article", _("article"))
     grid.add_header("amount", _("amount"))
     grid.add_header("number", _("number"))
     grid.add_header("mean", _("mean"))
     grid.add_header("ratio", _("ratio (%)"))
     index = 0
     for art_val in articles_result:
         grid.set_value(index, "article", art_val[0])
         grid.set_value(index, "amount", art_val[1])
         grid.set_value(index, "number", art_val[2])
         grid.set_value(index, "mean", art_val[3])
         grid.set_value(index, "ratio", art_val[4])
         index += 1
     grid.set_location(0, 1, 3)
     grid.set_size(400, 800)
     self.add_component(grid)
示例#24
0
class CostAccountingReport(FiscalYearReport):
    icon = "costAccounting.png"
    model = CostAccounting
    field_id = 'costaccounting'

    def fillresponse(self):
        for self.item in self.items:
            self.new_tab(six.text_type(self.item))
            self.fill_header()
            self.calcul_table()
            self.fill_body()
        self.fill_buttons()

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('left', _('Expenses'))
        self.grid.add_header('left_n', _('Value'))
        self.grid.add_header('left_b', _('Budget'))
        if self.lastfilter is not None:
            self.grid.add_header('left_n_1', _('Last'))
        self.grid.add_header('space', '')
        self.grid.add_header('right', _('Revenues'))
        self.grid.add_header('right_n', _('Value'))
        self.grid.add_header('right_b', _('Budget'))
        if self.lastfilter is not None:
            self.grid.add_header('right_n_1', _('Last'))

    def fill_filterheader(self):
        pass

    def fill_header(self):
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 3)
        self.add_component(img)
        lbl = XferCompLabelForm('lblname')
        lbl.set_value_as_name(
            self.model._meta.verbose_name)
        lbl.set_location(1, 2)
        self.add_component(lbl)
        lbl = XferCompLabelForm('name')
        lbl.set_value(self.item)
        lbl.set_location(2, 2, 4)
        self.add_component(lbl)
        self.filltab_from_model(1, 6, True, [(
            (_('total revenue'), 'total_revenue'), (_('total expense'), 'total_expense'))])
        self.filter = Q(entry__costaccounting=self.item)
        self.fill_filterCode()
        self.fill_filterheader()
        self.define_gridheader()
示例#25
0
 def fill_customers(self):
     costumer_result = self.item.get_statistics_customer()
     grid = XferCompGrid("customers")
     grid.add_header("customer", _("customer"))
     grid.add_header("amount", _("amount"))
     grid.add_header("ratio", _("ratio (%)"))
     index = 0
     for cust_val in costumer_result:
         grid.set_value(index, "customer", cust_val[0])
         grid.set_value(index, "amount", cust_val[1])
         grid.set_value(index, "ratio", cust_val[2])
         index += 1
     grid.set_location(0, 1, 3)
     grid.set_size(400, 800)
     self.add_component(grid)
示例#26
0
class FiscalYearTrialBalance(FiscalYearReport):
    caption = _("Trial balance")
    add_filtering = True

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('designation', _('name'))
        self.grid.add_header('total_debit', _('debit sum'))
        self.grid.add_header('total_credit', _('credit sum'))
        self.grid.add_header('solde_debit', _('debit'))
        self.grid.add_header('solde_credit', _('credit'))

    def _get_balance_values(self):
        balance_values = {}
        data_line_positifs = list(EntryLineAccount.objects.filter(self.filter & Q(amount__gt=0)).values(
            'account').annotate(data_sum=Sum('amount')))
        data_line_negatifs = list(EntryLineAccount.objects.filter(self.filter & Q(amount__lt=0)).values(
            'account').annotate(data_sum=Sum('amount')))
        for data_line in data_line_positifs + data_line_negatifs:
            if abs(data_line['data_sum']) > 0.0001:
                account = ChartsAccount.objects.get(
                    id=data_line['account'])
                if account.code not in balance_values.keys():
                    balance_values[account.code] = [
                        six.text_type(account), 0, 0]
                if (account.credit_debit_way() * data_line['data_sum']) > 0.0001:
                    balance_values[account.code][
                        2] = account.credit_debit_way() * data_line['data_sum']
                else:
                    balance_values[account.code][
                        1] = -1 * account.credit_debit_way() * data_line['data_sum']
        return balance_values

    def calcul_table(self):
        line_idx = 1
        balance_values = self._get_balance_values()
        keys = list(balance_values.keys())
        keys.sort()
        for key in keys:
            self.grid.set_value(
                line_idx, 'designation', balance_values[key][0])
            self.grid.set_value(
                line_idx, 'total_debit', format_devise(balance_values[key][1], 5))
            self.grid.set_value(
                line_idx, 'total_credit', format_devise(balance_values[key][2], 5))
            diff = balance_values[key][1] - balance_values[key][2]
            self.grid.set_value(
                line_idx, 'solde_debit', format_devise(max(0, diff), 0))
            if abs(diff) < 0.0001:
                self.grid.set_value(
                    line_idx, 'solde_credit', format_devise(0, 5))
            else:
                self.grid.set_value(
                    line_idx, 'solde_credit', format_devise(max(0, -1 * diff), 0))
            line_idx += 1
示例#27
0
文件: views.py 项目: Lucterios2/core
    def fillresponse(self):

        grid = XferCompGrid('grid')
        grid.set_location(0, 0)

        grid.add_header('col1', "Integer", 'int')
        grid.add_header('col2', "Float", 'float')
        grid.add_header('col3', "Boolean", 'bool')
        grid.add_header('col4', "String", 'str')

        grid.set_value(1, "col1", 25)
        grid.set_value(1, "col2", 7.54)
        grid.set_value(1, "col3", True)
        grid.set_value(1, "col4", "foo")

        grid.set_value(5, "col1", 0)
        grid.set_value(5, "col2", 789.644)
        grid.set_value(5, "col3", False)
        grid.set_value(5, "col4", "string")

        # grid.add_action(self.get_action('Reopen', ''),-1, {'modal':FORMTYPE_REFRESH})
        self.add_component(grid)
示例#28
0
class FinancialStatus(CondominiumReport):
    caption = _("Financial status")

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('left', _('Designation'))
        if self.item.last_fiscalyear is not None:
            self.grid.add_header('left_n_1', _('year N-1'))
        self.grid.add_header('left_n', _('year N'))
        self.grid.add_header('space', '')
        self.grid.add_header('right', _('Designation'))
        if self.item.last_fiscalyear is not None:
            self.grid.add_header('right_n_1', _('year N-1'))
        self.grid.add_header('right_n', _('year N'))
        self.grid.set_location(0, 10, 6)
        self.grid.no_pager = True
        self.add_component(self.grid)

    def fill_part_of_grid(self,
                          side,
                          current_filter,
                          index_begin,
                          title,
                          sign_value=None,
                          with_third=False):
        data_line, total1, total2, _totalb = convert_query_to_account(
            self.filter & current_filter,
            self.lastfilter & current_filter,
            sign_value=sign_value,
            with_third=with_third)
        add_cell_in_grid(self.grid, index_begin, side,
                         get_spaces(5) + '{[u]}%s{[/u]}' % title)
        line_idx = index_begin + 1
        line_idx = fill_grid(self.grid, line_idx, side, data_line)
        add_cell_in_grid(self.grid, line_idx, side, '')
        line_idx += 1
        return line_idx, total1, total2

    def fill_body(self):
        line__tresor, total1_tresor, total2_tresor = self.fill_part_of_grid(
            'left',
            Q(account__code__regex=current_system_account().get_cash_mask()),
            0, _('Tresory'))
        line__capital, total1_capital, total2_capital = self.fill_part_of_grid(
            'right', Q(account__type_of_account=2), 0,
            _('Provision and advance'))
        line_idx = max(line__tresor, line__capital)
        add_item_in_grid(self.grid, line_idx, 'left',
                         (_('total'), total1_tresor, total2_tresor, None),
                         get_spaces(5) + "{[u]}%s{[/u]}")
        add_item_in_grid(self.grid, line_idx, 'right',
                         (_('total'), total1_capital, total2_capital, None),
                         get_spaces(5) + "{[u]}%s{[/u]}")
        add_cell_in_grid(self.grid, line_idx + 1, 'left', '')
        add_cell_in_grid(self.grid, line_idx + 1, 'right', '')

        last_ids = []
        try:
            last_ids.append(
                EntryAccount.objects.filter(
                    year=self.item).order_by('-id')[0].id)
        except IndexError:
            last_ids.append(0)
        if self.item.last_fiscalyear is not None:
            try:
                last_ids.append(
                    EntryAccount.objects.filter(
                        year=self.item.last_fiscalyear).order_by('-id')[0].id)
            except IndexError:
                last_ids.append(0)
        current_filter = Q(account__type_of_account__in=(0, 1)) & ~Q(
            account__code__regex=current_system_account().get_cash_mask())
        current_filter &= (
            ~Q(entry__year__status=2)
            | ~(Q(entry__journal=5) & Q(entry__id__in=tuple(last_ids))))
        line__creance, total1_creance, total2_creance = self.fill_part_of_grid(
            'left',
            current_filter,
            line_idx + 2,
            _('Créance'),
            sign_value=-1,
            with_third=True)
        line__dette, total1_dette, total2_dette = self.fill_part_of_grid(
            'right',
            current_filter,
            line_idx + 2,
            _('Dettes'),
            sign_value=1,
            with_third=True)
        line_idx = max(line__creance, line__dette)
        add_item_in_grid(self.grid, line_idx, 'left',
                         (_('total'), total1_creance, total2_creance, None),
                         get_spaces(5) + "{[u]}%s{[/u]}")
        add_item_in_grid(self.grid, line_idx, 'right',
                         (_('total'), total1_dette, total2_dette, None),
                         get_spaces(5) + "{[u]}%s{[/u]}")
        add_cell_in_grid(self.grid, line_idx + 1, 'left', '')
        add_cell_in_grid(self.grid, line_idx + 1, 'right', '')
        add_item_in_grid(self.grid, line_idx + 2, 'left',
                         (_('total'), total1_tresor + total1_creance,
                          total2_tresor + total2_creance, None),
                         get_spaces(5) + "{[b]}%s{[/b]}")
        add_item_in_grid(self.grid, line_idx + 2, 'right',
                         (_('total'), total1_capital + total1_dette,
                          total2_capital + total2_dette, None),
                         get_spaces(5) + "{[b]}%s{[/b]}")
示例#29
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(*identfilter).distinct()
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
示例#30
0
    def show(self, xfer):
        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        new_recipients.set_location(obj_recipients.col, obj_recipients.row, obj_recipients.colspan)
        new_recipients.add_header("model", _('model'))
        new_recipients.add_header("filter", _('filter'))
        compid = 0
        for model_title, filter_desc in self.item.recipients_description:
            new_recipients.set_value(compid, "model", model_title)
            new_recipients.set_value(compid, "filter", filter_desc)
            compid += 1
        if compid == 0:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('documents')
        xfer.remove_component('documents')
        new_documents = XferCompGrid('document')
        new_documents.tab = old_documents.tab
        new_documents.set_location(old_documents.col, old_documents.row, old_documents.colspan)
        new_documents.set_model(self.item.documents.all(), ["name", "description", "date_modification"], xfer)
        new_documents.add_action(xfer.request, DocumentShow.get_action(TITLE_EDIT, "images/show.png"),
                                 modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
        if self.item.status == 0:
            new_documents.add_action(xfer.request, MessageRemoveDoc.get_action(_("Remove"), "images/delete.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_MULTI)
            new_documents.add_action(xfer.request, MessageInsertDoc.get_action(_("Insert"), "images/add.png"),
                                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_NONE)
        xfer.tab = new_documents.tab
        xfer.add_component(new_documents)

        return LucteriosEditor.show(self, xfer)
示例#31
0
文件: views.py 项目: mayjo79/core
    def fillresponse(self):

        grid = XferCompGrid('grid')
        grid.set_location(0, 0)

        grid.add_header('col1', "Integer", 'int')
        grid.add_header('col2', "Float", 'float')
        grid.add_header('col3', "Boolean", 'bool')
        grid.add_header('col4', "String", 'str')

        grid.set_value(1, "col1", 25)
        grid.set_value(1, "col2", 7.54)
        grid.set_value(1, "col3", True)
        grid.set_value(1, "col4", "foo")

        grid.set_value(5, "col1", 0)
        grid.set_value(5, "col2", 789.644)
        grid.set_value(5, "col3", False)
        grid.set_value(5, "col4", "string")

        # grid.add_action(self.get_action('Reopen', ''),-1, {'modal':FORMTYPE_REFRESH})
        self.add_component(grid)
示例#32
0
 def fillresponse(self, legal_entity=0, name_filter=''):
     self.item.legal_entity = LegalEntity.objects.get(id=legal_entity)
     img = XferCompImage('img')
     img.set_value(self.icon_path())
     img.set_location(0, 0, 1, 3)
     self.add_component(img)
     self.fill_from_model(1, 0, True, ['legal_entity'])
     comp = XferCompEdit('filter')
     comp.set_value(name_filter)
     comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
     comp.set_location(1, 2)
     comp.description = _('Filtrer by name')
     comp.is_default = True
     self.add_component(comp)
     identfilter = []
     if name_filter != "":
         identfilter = [
             Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)]
     items = Individual.objects.filter(
         *identfilter)
     grid = XferCompGrid('individual')
     grid.set_model(items, None, self)
     grid.set_location(1, 3)
     grid.description = _('individual')
     grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"})
     grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE)
     grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"),
                     modal=FORMTYPE_MODAL, close=CLOSE_NO)
     self.add_component(grid)
示例#33
0
文件: views.py 项目: Diacamma2/asso
 def fillresponse(self, send_email=True):
     cmd_manager = CommandManager(self.getparam('CMD_FILE', ''), self.items)
     if self.getparam('SAVE') is None:
         dlg = self.create_custom(self.model)
         img = XferCompImage('img')
         img.set_value(self.icon_path())
         img.set_location(0, 0, 1, 4)
         dlg.add_component(img)
         lab = XferCompLabelForm('lbl_title')
         lab.set_value_as_title(self.caption)
         lab.set_location(1, 0, 2)
         dlg.add_component(lab)
         grid = XferCompGrid('AdhCmd')
         for fname, ftitle in cmd_manager.get_fields():
             grid.add_header(fname, ftitle)
         for cmd_id, cmd_item in cmd_manager.get_content_txt():
             for head_name, value in cmd_item.items():
                 grid.set_value(cmd_id, head_name, value)
         grid.set_location(1, 2, 2)
         grid.add_action(self.request, AdherentCommandModify.get_action(TITLE_MODIFY, "images/edit.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         grid.add_action(self.request, AdherentCommandDelete.get_action(TITLE_DELETE, "images/delete.png"), close=CLOSE_NO, unique=SELECT_SINGLE)
         dlg.params['CMD_FILE'] = cmd_manager.file_name
         dlg.add_component(grid)
         if len(grid.records) > 0:
             lab = XferCompLabelForm('lbl_send_email')
             lab.set_value_as_name(_('Send quotition by email for each adherent.'))
             lab.set_location(1, 3)
             dlg.add_component(lab)
             chk = XferCompCheck('send_email')
             chk.set_value(send_email)
             chk.set_location(2, 3)
             dlg.add_component(chk)
             dlg.add_action(AdherentCommand.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'SAVE': 'YES'})
         dlg.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
     else:
         dateref = convert_date(self.getparam("dateref", ""), Season.current_season().date_ref)
         if send_email:
             param_email = self.request.META.get('HTTP_REFERER', self.request.build_absolute_uri()), self.language
         else:
             param_email = None
         nb_sub, nb_bill = cmd_manager.create_subscription(dateref, param_email)
         if send_email:
             msg = _('%(nbsub)d new subscription and %(nbbill)d quotation have been sent.') % {'nbsub': nb_sub, 'nbbill': nb_bill}
         else:
             msg = _('%d new subscription have been prepared.') % nb_sub
         self.message(msg)
示例#34
0
    def fillresponse(self, modelname, quotechar="'", delimiter=";", encoding="utf-8", dateformat="%d/%m/%Y", step=0):
        def add_item_if_not_null(new_item):
            if new_item is not None:
                self.items_imported[new_item.id] = new_item

        if modelname is not None:
            self.model = apps.get_model(modelname)
        self.quotechar = quotechar
        self.delimiter = delimiter
        self.encoding = encoding
        self.dateformat = dateformat

        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0, 1, 6)
        self.add_component(img)
        if step == 0:
            lbl = self._select_csv_parameters()
            step = 1
        elif step == 1:
            lbl = XferCompLabelForm('modelname')
            lbl.set_value(self.model._meta.verbose_name.title())
            lbl.set_location(1, 0)
            lbl.description = _('model')
            self.add_component(lbl)
            self._read_csv()
            self.new_tab(_("Fields"))
            self._select_fields()
            self.new_tab(_("Current content"))
            self._show_initial_csv()
            step = 2
        elif step == 2:
            lbl = XferCompLabelForm('modelname')
            lbl.set_value(self.model._meta.verbose_name.title())
            lbl.set_location(1, 0)
            lbl.description = _('model')
            self.add_component(lbl)
            fields_description, csv_readed = self._read_csv_and_convert()
            tbl = XferCompGrid('CSV')
            for field_description in fields_description:
                tbl.add_header(field_description[0], field_description[1], field_description[2], formatstr=field_description[3])
            row_idx = 1
            for row in csv_readed:
                for field_description in fields_description:
                    tbl.set_value(row_idx, field_description[0], row[field_description[0]])
                row_idx += 1
            tbl.set_location(1, 1, 2)
            self.add_component(tbl)
            lbl = XferCompLabelForm('nb_line')
            lbl.set_value(_("Total number of items: %d") % (row_idx - 1))
            lbl.set_location(1, 2, 2)
            self.add_component(lbl)
            step = 3
        elif step == 3:
            fields_description, csv_readed = self._read_csv_and_convert()
            self.model.initialize_import()
            self.items_imported = {}
            for rowdata in csv_readed:
                add_item_if_not_null(self.model.import_data(rowdata, dateformat))
            add_item_if_not_null(self.model.finalize_import())
            lbl = XferCompLabelForm('result')
            lbl.set_value_as_header(_("%d items are been imported") % len(self.items_imported))
            lbl.set_location(1, 2, 2)
            self.add_component(lbl)
            step = 4
        if step < 4:
            if step > 1:
                self.add_action(self.get_action(_('Back'), "images/left.png"),
                                close=CLOSE_NO, modal=FORMTYPE_REFRESH, params={'step': step - 2})
            self.add_action(self.get_action(_('Ok'), "images/ok.png"),
                            close=CLOSE_NO, modal=FORMTYPE_REFRESH, params={'step': step})
            self.add_action(WrapAction(_("Cancel"), "images/cancel.png"))
        else:
            self.add_action(WrapAction(_("Close"), "images/close.png"))
示例#35
0
 def filltab_from_model(self, col, row, readonly, field_names, prefix=''):
     maxsize_of_lines = self.get_maxsize_of_lines(field_names)
     for line_field_name in field_names:
         if not isinstance(line_field_name, tuple):
             line_field_name = line_field_name,
         offset = 0
         height = 1
         comp_col_addon = 0
         for field_name in line_field_name:
             if field_name is None:
                 continue
             colspan = self.get_current_offset(maxsize_of_lines,
                                               len(line_field_name), offset)
             if field_name[-4:] == '_set':  # field is one-to-many relation
                 child = getattr(self.item, field_name).all()
                 if hasattr(self.item, field_name[:-4] + '_query'):
                     child = child.filter(
                         getattr(self.item, field_name[:-4] + '_query'))
                 comp = XferCompGrid(field_name[:-4])
                 comp.set_model(child, None, self)
                 comp.add_action_notified(self, model=child.model)
                 comp.set_location(col + comp_col_addon + offset, row,
                                   colspan, 1)
                 comp.description = six.text_type(
                     child.model._meta.verbose_name)
                 self.add_component(comp)
                 offset += 1 + comp_col_addon
             else:
                 if isinstance(field_name, tuple):
                     verbose_name, field_name = field_name
                 else:
                     verbose_name = None
                 dep_field = self.item.get_field_by_name(field_name)
                 # field real in model
                 if (dep_field is None
                     ) or not dep_field.auto_created or dep_field.concrete:
                     # field not many-to-many
                     if readonly:
                         comp = self.get_reading_comp(field_name, prefix)
                     else:
                         comp = self.get_writing_comp(field_name)
                     comp.set_location(col + comp_col_addon + offset, row,
                                       colspan, 1)
                     if verbose_name is None:
                         comp.description = six.text_type(
                             dep_field.verbose_name)
                     else:
                         comp.description = six.text_type(verbose_name)
                     self.add_component(comp)
                     offset += 1 + comp_col_addon
         row += height
示例#36
0
class FiscalYearIncomeStatement(FiscalYearReport):
    caption = _("Income statement")

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('left', _('Expense'))
        self.grid.add_header('left_n', self.item.get_identify())
        self.grid.add_header('left_b', _('Budget'))
        if self.lastfilter is not None:
            self.grid.add_header(
                'left_n_1', self.item.last_fiscalyear.get_identify())
        self.grid.add_header('space', '')
        self.grid.add_header('right', _('Revenue'))
        self.grid.add_header('right_n', self.item.get_identify())
        self.grid.add_header('right_b', _('Budget'))
        if self.lastfilter is not None:
            self.grid.add_header(
                'right_n_1', self.item.last_fiscalyear.get_identify())

    def fill_filterheader(self):
        if self.item.last_fiscalyear is not None:
            self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
            lbl = XferCompLabelForm('sep_last')
            lbl.set_value("{[br/]}{[br/]}")
            lbl.set_location(2, 11, 3)
            self.add_component(lbl)
            lbl = XferCompLabelForm('lbllast_year')
            lbl.set_value_as_name(self.item.last_fiscalyear.get_identify())
            lbl.set_location(1, 12)
            self.add_component(lbl)
            lbl = XferCompLabelForm('last_year')
            lbl.set_value(six.text_type(self.item.last_fiscalyear))
            lbl.set_location(2, 12, 4)
            self.add_component(lbl)
            lbl = XferCompLabelForm('last_result')
            lbl.set_value(self.item.last_fiscalyear.total_result_text)
            lbl.set_location(2, 13, 4)
            self.add_component(lbl)

    def calcul_table(self):
        self.budgetfilter_right = Q(year=self.item) & Q(code__regex=current_system_account().get_revenue_mask())
        self.budgetfilter_left = Q(year=self.item) & Q(code__regex=current_system_account().get_expence_mask())
        self._add_left_right_accounting(Q(account__type_of_account=4), Q(account__type_of_account=3), True)
示例#37
0
 def show(self, xfer):
     xfer.move_components('lbl_body', 0, 2)
     xfer.move_components('body', 0, 2)
     obj_recipients = xfer.get_components('recipients')
     new_recipients = XferCompGrid('recipient_list')
     new_recipients.set_location(obj_recipients.col, obj_recipients.row, obj_recipients.colspan)
     new_recipients.add_header("model", _('model'))
     new_recipients.add_header("filter", _('filter'))
     compid = 0
     for model_title, filter_desc in self.item.recipients_description:
         new_recipients.set_value(compid, "model", model_title)
         new_recipients.set_value(compid, "filter", filter_desc)
         compid += 1
     if compid > 0:
         nb_contact = len(self.item.get_contacts())
         contact_nb = XferCompLabelForm('contact_nb')
         contact_nb.set_location(obj_recipients.col, obj_recipients.row + 1, obj_recipients.colspan)
         contact_nb.set_value(_("Message defined for %d contacts") % nb_contact)
         xfer.add_component(contact_nb)
     lbl = XferCompLabelForm('sep_body')
     lbl.set_location(obj_recipients.col - 1, obj_recipients.row + 2, 4)
     lbl.set_value("{[hr/]}")
     xfer.add_component(lbl)
     xfer.remove_component('recipients')
     new_recipients.add_action_notified(xfer, 'recipient_list')
     xfer.add_component(new_recipients)
     return LucteriosEditor.show(self, xfer)
示例#38
0
 def filltab_from_model(self, col, row, readonly, field_names):
     maxsize_of_lines = self.get_maxsize_of_lines(field_names)
     for line_field_name in field_names:
         if not isinstance(line_field_name, tuple):
             line_field_name = line_field_name,
         offset = 0
         height = 1
         for field_name in line_field_name:
             if field_name is None:
                 continue
             colspan = self.get_current_offset(
                 maxsize_of_lines, len(line_field_name), offset)
             if field_name[-4:] == '_set':  # field is one-to-many relation
                 child = getattr(self.item, field_name).all()
                 if hasattr(self.item, field_name[:-4] + '_query'):
                     child = child.filter(
                         getattr(self.item, field_name[:-4] + '_query'))
                 lbl = XferCompLabelForm('lbl_' + field_name)
                 lbl.set_location(col + offset, row, 1, 1)
                 lbl.set_value_as_name(
                     child.model._meta.verbose_name)
                 self.add_component(lbl)
                 comp = XferCompGrid(field_name[:-4])
                 comp.set_model(child, None, self)
                 comp.add_actions(self, model=child.model)
                 comp.set_location(col + 1 + offset, row, colspan, 1)
                 self.add_component(comp)
                 offset += 2
             else:
                 if isinstance(field_name, tuple):
                     verbose_name, field_name = field_name
                 else:
                     verbose_name = None
                 dep_field = self.item.get_field_by_name(field_name)
                 # field real in model
                 if (dep_field is None) or not dep_field.auto_created or dep_field.concrete:
                     # field not many-to-many
                     lbl = XferCompLabelForm('lbl_' + field_name)
                     lbl.set_location(col + offset, row, 1, 1)
                     if verbose_name is None:
                         lbl.set_value_as_name(
                             six.text_type(dep_field.verbose_name))
                     else:
                         lbl.set_value_as_name(
                             six.text_type(verbose_name))
                     self.add_component(lbl)
                     if (dep_field is None) or (not (dep_field.is_relation and dep_field.many_to_many)):
                         if readonly:
                             comp = self.get_reading_comp(field_name)
                         else:
                             comp = self.get_writing_comp(field_name)
                         comp.set_location(
                             col + 1 + offset, row, colspan, 1)
                         self.add_component(comp)
                     else:  # field many-to-many
                         if readonly:
                             child = getattr(self.item, field_name).all()
                             comp = XferCompGrid(field_name)
                             comp.set_model(child, None, self)
                             comp.set_location(
                                 col + 1 + offset, row, colspan, 1)
                             self.add_component(comp)
                         else:
                             self.selector_from_model(
                                 col + offset, row, field_name)
                         height = 5
                     offset += 2
         row += height
示例#39
0
 def filltab_from_model(self, col, row, readonly, field_names):
     maxsize_of_lines = self.get_maxsize_of_lines(field_names)
     for line_field_name in field_names:
         if not isinstance(line_field_name, tuple):
             line_field_name = line_field_name,
         offset = 0
         height = 1
         comp_col_addon = 0
         for field_name in line_field_name:
             if field_name is None:
                 continue
             colspan = self.get_current_offset(maxsize_of_lines, len(line_field_name), offset)
             if field_name[-4:] == '_set':  # field is one-to-many relation
                 child = getattr(self.item, field_name).all()
                 if hasattr(self.item, field_name[:-4] + '_query'):
                     child = child.filter(getattr(self.item, field_name[:-4] + '_query'))
                 comp = XferCompGrid(field_name[:-4])
                 comp.set_model(child, None, self)
                 comp.add_action_notified(self, model=child.model)
                 comp.set_location(col + comp_col_addon + offset, row, colspan, 1)
                 comp.description = six.text_type(child.model._meta.verbose_name)
                 self.add_component(comp)
                 offset += 1 + comp_col_addon
             else:
                 if isinstance(field_name, tuple):
                     verbose_name, field_name = field_name
                 else:
                     verbose_name = None
                 dep_field = self.item.get_field_by_name(field_name)
                 # field real in model
                 if (dep_field is None) or not dep_field.auto_created or dep_field.concrete:
                     # field not many-to-many
                     if readonly:
                         comp = self.get_reading_comp(field_name)
                     else:
                         comp = self.get_writing_comp(field_name)
                     comp.set_location(col + comp_col_addon + offset, row, colspan, 1)
                     if verbose_name is None:
                         comp.description = six.text_type(dep_field.verbose_name)
                     else:
                         comp.description = six.text_type(verbose_name)
                     self.add_component(comp)
                     offset += 1 + comp_col_addon
         row += height
示例#40
0
class FiscalYearLedger(FiscalYearReport):
    caption = _("Ledger")
    add_filtering = True

    def __init__(self, **kwargs):
        FiscalYearReport.__init__(self, **kwargs)
        self.last_account = None
        self.last_third = None
        self.last_total = 0
        self.line_idx = 1

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('entry.num', _('numeros'))
        self.grid.add_header('entry.date_entry', _('date entry'))
        self.grid.add_header('entry.date_value', _('date value'))
        self.grid.add_header('entry.designation', _('name'))
        self.grid.add_header('debit', _('debit'))
        self.grid.add_header('credit', _('credit'))

    def _add_total_account(self):
        if self.last_account is not None:
            self.grid.set_value(self.line_idx, 'entry.designation', get_spaces(
                30) + "{[i]}%s{[/i]}" % _('total'))
            self.grid.set_value(self.line_idx, 'debit', "{[i]}%s{[/i]}" % format_devise(
                max((0, -1 * self.last_account.credit_debit_way() * self.last_total)), 0))
            self.grid.set_value(self.line_idx, 'credit', "{[i]}%s{[/i]}" % format_devise(
                max((0, self.last_account.credit_debit_way() * self.last_total)), 0))
            self.line_idx += 1
            self.grid.set_value(self.line_idx, 'entry.designation', '{[br/]}')
            self.line_idx += 1
            self.last_total = 0

    def calcul_table(self):
        self.line_idx = 1
        self.last_account = None
        self.last_third = None
        self.last_total = 0
        for line in EntryLineAccount.objects.filter(self.filter).order_by('account__code', 'entry__date_value', 'third'):
            if self.last_account != line.account:
                self._add_total_account()
                self.last_account = line.account
                self.last_third = None
                self.grid.set_value(self.line_idx, 'entry.designation', get_spaces(
                    15) + "{[u]}{[b]}%s{[/b]}{[/u]}" % six.text_type(self.last_account))
                self.line_idx += 1
            if self.last_third != line.third:
                self.grid.set_value(self.line_idx, 'entry.designation', get_spaces(
                    8) + "{[b]}%s{[/b]}" % six.text_type(line.entry_account))
                self.line_idx += 1
            self.last_third = line.third
            for header in self.grid.headers:
                self.grid.set_value(
                    self.line_idx, header.name, line.evaluate('#' + header.name))
            self.last_total += line.amount
            self.line_idx += 1
        self._add_total_account()
示例#41
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
示例#42
0
 def fill_grid(self, row, model, field_id, items):
     grid = XferCompGrid(field_id)
     if self.size_by_page is not None:
         grid.size_by_page = self.size_by_page
     if self.multi_page:
         xfer = self
     else:
         xfer = None
     grid.set_model(items, self.fieldnames, xfer)
     grid.add_action_notified(self, model=model)
     grid.set_location(0, row + 1, 2)
     grid.set_size(350, 500)
     self.add_component(grid)
示例#43
0
    def fillresponse(self):

        grid = XferCompGrid('grid')
        grid.set_location(0, 0)

        grid.add_header('col1', "Integer", 'N0')
        grid.add_header('col2', "Float", 'N3')
        grid.add_header('col3', "Boolean", 'B')
        grid.add_header('col4', "String", None, 0, "{[b]}%s{[/b]}")

        grid.set_value(1, "col1", 2500)
        grid.set_value(1, "col2", 7.54)
        grid.set_value(1, "col3", True)
        grid.set_value(1, "col4", "foo")

        grid.set_value(5, "col1", 4)
        grid.set_value(5, "col2", 789.644)
        grid.set_value(5, "col3", False)
        grid.set_value(5, "col4", "string")

        # grid.add_action(self.return_action('Reopen', ''),-1, {'modal':FORMTYPE_REFRESH})
        self.add_component(grid)
示例#44
0
class ManageAccounting(CondominiumReport):
    def fill_header(self):
        CondominiumReport.fill_header(self)
        self.next_year = self.item.next_fiscalyear.first()
        if self.next_year is not None:
            lbl = XferCompLabelForm('yearn1')
            lbl.set_location(1, 2, 3)
            lbl.set_value(six.text_type(self.next_year))
            lbl.description = _('year N+1')
            self.add_component(lbl)
            self.next_year_again = self.next_year.next_fiscalyear.first()
            if self.next_year_again is not None:
                lbl = XferCompLabelForm('yearn2')
                lbl.set_location(1, 3, 3)
                lbl.description = _('year N+2')
                lbl.set_value(six.text_type(self.next_year_again))
                self.add_component(lbl)
        else:
            self.next_year_again = None

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('design', _('Designation'))
        if self.item.last_fiscalyear is not None:
            self.grid.add_header('year_n_1', _('year N-1'))
        self.grid.add_header('budget_n', _('budget N'))
        self.grid.add_header('year_n', _('year N'))
        if self.next_year is not None:
            self.grid.add_header('budget_n1', _('budget N+1'))
        if self.next_year_again is not None:
            self.grid.add_header('budget_n2', _('budget N+2'))
        self.grid.set_location(0, 10, 6)
        self.grid.no_pager = True
        self.add_component(self.grid)

    def fill_part_of_grid(self,
                          current_filter,
                          query_budget,
                          index_begin,
                          title,
                          sign_value=None):
        data_line, total1, total2, totalb = convert_query_to_account(
            self.filter & current_filter,
            self.lastfilter & current_filter,
            query_budget=query_budget,
            sign_value=sign_value)
        add_cell_in_grid(self.grid, index_begin, 'design',
                         get_spaces(5) + '{[u]}%s{[/u]}' % title)
        line_idx = index_begin + 1
        for data_item in data_line:
            add_cell_in_grid(self.grid, line_idx, 'design', data_item[0])
            add_cell_in_grid(self.grid, line_idx, 'year_n',
                             format_devise(data_item[1], 5))
            add_cell_in_grid(self.grid, line_idx, 'budget_n',
                             format_devise(data_item[3], 5))
            if self.next_year is not None:
                add_cell_in_grid(self.grid, line_idx, 'budget_n1',
                                 format_devise(data_item[4], 5))
            if self.next_year_again is not None:
                add_cell_in_grid(self.grid, line_idx, 'budget_n2',
                                 format_devise(data_item[5], 5))
            if self.item.last_fiscalyear is not None:
                add_cell_in_grid(self.grid, line_idx, 'year_n_1',
                                 format_devise(data_item[2], 5))
            line_idx += 1
        add_cell_in_grid(self.grid, line_idx, 'design', '')
        line_idx += 1
        add_cell_in_grid(self.grid, line_idx, 'design',
                         get_spaces(5) + "{[u]}%s{[/u]}" % _('total'))
        add_cell_in_grid(self.grid, line_idx, 'year_n',
                         "{[u]}%s{[/u]}" % format_devise(total1, 5))
        add_cell_in_grid(self.grid, line_idx, 'budget_n',
                         "{[u]}%s{[/u]}" % format_devise(totalb[0], 5))
        if self.next_year is not None:
            add_cell_in_grid(self.grid, line_idx, 'budget_n1',
                             "{[u]}%s{[/u]}" % format_devise(totalb[1], 5))
        if self.next_year_again is not None:
            add_cell_in_grid(self.grid, line_idx, 'budget_n2',
                             "{[u]}%s{[/u]}" % format_devise(totalb[2], 5))
        if self.item.last_fiscalyear is not None:
            add_cell_in_grid(self.grid, line_idx, 'year_n_1',
                             "{[u]}%s{[/u]}" % format_devise(total2, 5))
        line_idx += 1
        add_cell_in_grid(self.grid, line_idx, 'design', '')
        return line_idx, total1, total2, totalb
示例#45
0
    def fill_tasks(self):
        self.new_tab(_('Tasks'))
        grid = XferCompGrid('tasks')
        grid.no_pager = True
        grid.add_header('name', _('name'))
        grid.add_header('trigger', _('trigger'))
        grid.add_header('nextdate', _('next date'), 'datetime')
        for job_desc in LucteriosScheduler.get_list():
            grid.set_value(job_desc[0], 'name', job_desc[1])
            grid.set_value(job_desc[0], 'trigger', '%s' % job_desc[2])
            grid.set_value(job_desc[0], 'nextdate', job_desc[3])

        grid.set_location(0, self.get_max_row() + 1, 2)
        grid.set_size(200, 500)
        self.add_component(grid)
示例#46
0
文件: views.py 项目: Diacamma2/asso
    def fillresponse(self, season):
        if season is None:
            working_season = Season.current_season()
        else:
            working_season = Season.objects.get(id=season)
        img = XferCompImage('img')
        img.set_value(self.icon_path())
        img.set_location(0, 0)
        self.add_component(img)
        lab = XferCompLabelForm('lbl_season')
        lab.set_value_as_name(_('season'))
        lab.set_location(1, 0)
        self.add_component(lab)
        sel = XferCompSelect('season')
        sel.set_needed(True)
        sel.set_select_query(Season.objects.all())
        sel.set_value(working_season.id)
        sel.set_location(2, 0)
        sel.set_action(self.request, self.get_action('', ''), modal=FORMTYPE_REFRESH, close=CLOSE_NO)
        self.add_component(sel)
        stat_result = working_season.get_statistic()
        if len(stat_result) == 0:
            lab = XferCompLabelForm('lbl_season')
            lab.set_color('red')
            lab.set_value_as_infocenter(_('no subscription!'))
            lab.set_location(1, 1, 2)
            self.add_component(lab)
        else:
            tab_iden = 0
            for stat_title, stat_city, stat_type in stat_result:
                tab_iden += 1
                if (len(stat_city) > 0) and (len(stat_type) > 0):
                    self.new_tab(stat_title)
                    lab = XferCompLabelForm("lbltown_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by city"))
                    lab.set_location(0, 1)
                    self.add_component(lab)
                    grid = XferCompGrid("town_%d" % tab_iden)
                    grid.add_header("city", _("city"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_city:
                        for stat_key in stat_val.keys():
                            grid.set_value(cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 2)
                    self.add_component(grid)

                    lab = XferCompLabelForm("lbltype_%d" % tab_iden)
                    lab.set_underlined()
                    lab.set_value(_("Result by type"))
                    lab.set_location(0, 3)
                    self.add_component(lab)
                    grid = XferCompGrid("type_%d" % tab_iden)
                    grid.add_header("type", _("type"))
                    grid.add_header("MajW", _("women major"))
                    grid.add_header("MajM", _("men major"))
                    grid.add_header("MinW", _("women minor"))
                    grid.add_header("MinM", _("men minor"))
                    grid.add_header("ratio", _("total (%)"))
                    cmp = 0
                    for stat_val in stat_type:
                        for stat_key in stat_val.keys():
                            if (stat_key == 'type') and not isinstance(stat_val['type'], six.text_type):
                                grid.set_value(cmp, stat_key, six.text_type(
                                    SubscriptionType.objects.get(id=stat_val['type'])))
                            else:
                                grid.set_value(
                                    cmp, stat_key, stat_val[stat_key])
                        cmp += 1
                    grid.set_location(0, 4)
                    self.add_component(grid)
        self.add_action(AdherentStatisticPrint.get_action(TITLE_PRINT, "images/print.png"),
                        close=CLOSE_NO, params={'classname': self.__class__.__name__})
        self.add_action(WrapAction(TITLE_CLOSE, 'images/close.png'))
示例#47
0
class FiscalYearBalanceSheet(FiscalYearReport):
    caption = _("Balance sheet")

    def fill_filterheader(self):
        if self.item.last_fiscalyear is not None:
            self.lastfilter = Q(entry__year=self.item.last_fiscalyear)
            lbl = XferCompLabelForm('sep_last')
            lbl.set_value("{[br/]}{[br/]}")
            lbl.set_location(2, 11, 3)
            self.add_component(lbl)
            lbl = XferCompLabelForm('lbllast_year')
            lbl.set_value_as_name(self.item.last_fiscalyear.get_identify())
            lbl.set_location(1, 12)
            self.add_component(lbl)
            lbl = XferCompLabelForm('last_year')
            lbl.set_value(six.text_type(self.item.last_fiscalyear))
            lbl.set_location(2, 12, 4)
            self.add_component(lbl)
            lbl = XferCompLabelForm('last_result')
            lbl.set_value(self.item.last_fiscalyear.total_result_text)
            lbl.set_location(2, 13, 4)
            self.add_component(lbl)

    def define_gridheader(self):
        self.grid = XferCompGrid('report_%d' % self.item.id)
        self.grid.add_header('left', _('Assets'))
        self.grid.add_header('left_n', self.item.get_identify())
        if self.lastfilter is not None:
            self.grid.add_header(
                'left_n_1', self.item.last_fiscalyear.get_identify())
        self.grid.add_header('space', '')
        self.grid.add_header('right', _('Liabilities'))
        self.grid.add_header('right_n', self.item.get_identify())
        if self.lastfilter is not None:
            self.grid.add_header(
                'right_n_1', self.item.last_fiscalyear.get_identify())

    def calcul_table(self):
        self._add_left_right_accounting(
            Q(account__type_of_account=0), Q(account__type_of_account__in=(1, 2)), False)
示例#48
0
    def fillresponse(self, payer="", reference=""):
        self.fill_header(payer, reference)

        grid = XferCompGrid('entry')
        grid.define_page(self)
        grid.add_header('bill', _('bill'))
        grid.add_header('payer', _('payer'), horderable=1)
        grid.add_header('amount', _('amount'), horderable=1)
        grid.add_header('date', _('date'), horderable=1)
        grid.add_header('reference', _('reference'), horderable=1)
        payoff_nodeposit = DepositDetail.get_payoff_not_deposit(
            payer, reference, grid.order_list)
        for payoff in payoff_nodeposit:
            payoffid = payoff['id']
            grid.set_value(payoffid, 'bill', payoff['bill'])
            grid.set_value(payoffid, 'payer', payoff['payer'])
            grid.set_value(payoffid, 'amount', payoff['amount'])
            grid.set_value(payoffid, 'date', payoff['date'])
            grid.set_value(payoffid, 'reference', payoff['reference'])
        grid.set_location(0, 2, 4)

        grid.add_action(self.request, DepositDetailSave.get_action(_("select"), "images/ok.png"), close=CLOSE_YES, unique=SELECT_MULTI)
        self.add_component(grid)

        self.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png'))
示例#49
0
    def show(self, xfer):
        xfer.move_components('body', 0, 2)
        obj_recipients = xfer.get_components('recipients')
        new_recipients = XferCompGrid('recipient_list')
        new_recipients.tab = obj_recipients.tab
        new_recipients.set_location(obj_recipients.col, obj_recipients.row,
                                    obj_recipients.colspan)
        new_recipients.add_header("model", _('model'))
        new_recipients.add_header("filter", _('filter'))
        compid = 0
        for model_title, filter_desc in self.item.recipients_description:
            new_recipients.set_value(compid, "model", model_title)
            new_recipients.set_value(compid, "filter", filter_desc)
            compid += 1
        if compid == 0:
            xfer.remove_component('contact_nb')
        if not will_mail_send() or (len(self.item.get_contacts(False)) == 0):
            xfer.remove_component('contact_noemail')
        xfer.remove_component('recipients')
        new_recipients.add_action_notified(xfer, 'recipient_list')
        xfer.tab = new_recipients.tab
        xfer.add_component(new_recipients)

        old_documents = xfer.get_components('documents')
        xfer.remove_component('documents')
        new_documents = XferCompGrid('document')
        new_documents.tab = old_documents.tab
        new_documents.set_location(old_documents.col, old_documents.row,
                                   old_documents.colspan)
        new_documents.set_model(self.item.documents.all(),
                                ["name", "description", "date_modification"],
                                xfer)
        new_documents.add_action(xfer.request,
                                 DocumentShow.get_action(
                                     TITLE_EDIT, "images/show.png"),
                                 modal=FORMTYPE_MODAL,
                                 close=CLOSE_NO,
                                 unique=SELECT_SINGLE)
        if self.item.status == 0:
            new_documents.add_action(xfer.request,
                                     MessageRemoveDoc.get_action(
                                         _("Remove"), "images/delete.png"),
                                     modal=FORMTYPE_MODAL,
                                     close=CLOSE_NO,
                                     unique=SELECT_MULTI)
            new_documents.add_action(xfer.request,
                                     MessageInsertDoc.get_action(
                                         _("Insert"), "images/add.png"),
                                     modal=FORMTYPE_MODAL,
                                     close=CLOSE_NO,
                                     unique=SELECT_NONE)
        xfer.tab = new_documents.tab
        xfer.add_component(new_documents)

        return LucteriosEditor.show(self, xfer)