def handle(self, *args, **options): if len(args) == 0: raise CommandError(self.help) models = [] from lino_cosi.lib.ledger.choicelists import VoucherTypes for vt in VoucherTypes.items(): models.append(vt.get_items_model()) models.append(vt.model) # from lino_cosi.lib.ledger.mixins import VoucherItem # models = list(rt.models_by_base(rt.modules.ledger.Voucher)) # models += list(rt.models_by_base(VoucherItem)) # from lino_cosi.lib.finan.mixins import (FinancialVoucher, # FinancialVoucherItem) # models = list(rt.models_by_base(FinancialVoucher)) # models += list(rt.models_by_base(FinancialVoucherItem)) # # models.append(rt.modules.ledger.Journal) # models.append(rt.modules.ledger.Voucher) models.append(rt.modules.ledger.Movement) if True: for m in models: qs = m.objects.all() dd.logger.info("Delete %d rows from %s.", qs.count(), m) qs.delete() # for obj in qs: # obj.delete() for pth in args: tim = TimLoader(pth) for obj in expand(tim.objects()): obj.full_clean() obj.save() tim.write_report()
def get_slave_summary(self, obj, ar): elems = [] sar = self.request(master_instance=obj) # elems += ["Partner:", unicode(ar.master_instance)] for voucher in sar: vc = voucher.get_mti_leaf() if vc and vc.state.name == "draft": elems += [ar.obj2html(vc), " "] vtypes = [] for vt in VoucherTypes.items(): if issubclass(vt.model, VatDocument): vtypes.append(vt) actions = [] if not ar.get_user().profile.readonly: for vt in vtypes: for jnl in vt.get_journals(): sar = vt.table_class.insert_action.request_from( ar, master_instance=jnl, known_values=dict(partner=obj)) btn = sar.ar2button(label=unicode(jnl), icon_name=None) if len(actions): actions.append(', ') actions.append(btn) elems += [E.br(), _("Create voucher in journal"), " "] + actions return E.div(*elems)
must be :class:`lino_cosi.lib.vat.models.VatAccountInvoice`) """ params_layout = "partner state year" column_names = "number voucher_date due_date " \ "partner " \ "total_incl " \ "total_base total_vat user workflow_buttons *" #~ "ledger_remark:10 " \ insert_layout = """ partner voucher_date total_incl """ VoucherTypes.add_item(VatAccountInvoice, InvoicesByJournal) class ItemsByInvoice(dd.Table): model = 'vat.InvoiceItem' column_names = "account title vat_class total_base total_vat total_incl" master_key = 'voucher' order_by = ["seqno"] auto_fit_column_widths = True class VouchersByPartner(dd.VirtualTable): """A :class:`lino.core.tables.VirtualTable` which shows all VatDocument vouchers by :class:`lino_xl.lib.contacts.models.Partner`. It has a customized slave summary.
class ClientVouchers(PartnerVouchers): model = 'client_vouchers.ClientVoucher' order_by = ["-id"] column_names = "date id number project amount user *" detail_layout = ClientVoucherDetail() insert_layout = """ journal project date amount """ class ClientVouchersByJournal(ClientVouchers, ByJournal): """Shows all simple invoices of a given journal (whose :attr:`Journal.voucher_type` must be :class:`lino_cosi.lib.sales.models.ClientVoucher`). """ params_layout = "project partner state year" column_names = "number date project amount user workflow_buttons *" insert_layout = """ project date amount """ order_by = ["-number"] from .models import ClientVoucher VoucherTypes.add_item(ClientVoucher, ClientVouchersByJournal)
""" order_by = ["-id"] class ProjectInvoicesByJournal(InvoicesByJournal): column_names = "number voucher_date " \ "project partner amount due_date user workflow_buttons *" insert_layout = """ project partner voucher_date """ detail_layout = ProjectInvoiceDetail() VoucherTypes.add_item(AccountInvoice, InvoicesByJournal, _("Invoices")) VoucherTypes.add_item(AccountInvoice, ProjectInvoicesByJournal, _("Project invoices")) class VouchersByPartner(dd.VirtualTable): """Shows all ledger vouchers of a given partner. This is a :class:`lino.core.tables.VirtualTable` with a customized slave summary. """ label = _("Partner vouchers") order_by = ["-date", '-id'] master = 'contacts.Partner' slave_grid_format = 'summary'
def add_voucher_type(sender, **kw): VoucherTypes.add_item('sales.VatProductInvoice', InvoicesByJournal)
voucher = item.voucher kw.update(for_journal=voucher.journal) if not dd.plugins.finan.suggest_future_vouchers: kw.update(date_until=voucher.voucher_date) kw.update(partner=item.partner) return kw class SuggestionsByBankStatementItem(SuggestionsByVoucherItem): """A :class:`SuggestionsByVoucherItem` table for a :class:`BankStatementItem`. """ master = 'finan.BankStatementItem' class SuggestionsByPaymentOrderItem(SuggestionsByVoucherItem): """A :class:`SuggestionsByVoucherItem` table for a :class:`PaymentOrderItem`. """ master = 'finan.PaymentOrderItem' # Declare the voucher types: VoucherTypes.add_item(JournalEntry, JournalEntriesByJournal) VoucherTypes.add_item(PaymentOrder, PaymentOrdersByJournal) VoucherTypes.add_item(BankStatement, BankStatementsByJournal) # VoucherTypes.add_item(Grouper, GroupersByJournal)
""" order_by = ["-id"] class ProjectInvoicesByJournal(InvoicesByJournal): column_names = "number voucher_date " \ "project partner amount due_date user workflow_buttons *" insert_layout = """ project partner voucher_date """ detail_layout = ProjectInvoiceDetail() VoucherTypes.add_item( AccountInvoice, InvoicesByJournal, _("Invoices")) VoucherTypes.add_item( AccountInvoice, ProjectInvoicesByJournal, _("Project invoices")) class VouchersByPartner(dd.VirtualTable): """Shows all ledger vouchers of a given partner. This is a :class:`lino.core.tables.VirtualTable` with a customized slave summary. """ label = _("Partner vouchers") order_by = ["-date", '-id'] master = 'contacts.Partner' slave_grid_format = 'summary'