예제 #1
0
def refto(x):
    if x is None:
        return '`None`'
    if issubclass(x, models.Model):
        return ':doc:`' + x.__name__ + ' <' + full_model_name(x) + '>`'
    #~ if isinstance(x,Field):
    return ':ref:`' + x.verbose_name + ' <' + settings.SITE.source_name \
        + '.' + full_model_name(x.model) + '.' + x.name + '>`'
예제 #2
0
 def __init__(self,model,table_class):
     self.table_class = table_class
     model = dd.resolve_model(model)
     self.model = model
     value = dd.full_model_name(model)
     text = model._meta.verbose_name + ' (%s)' % dd.full_model_name(model)
     #~ text = model._meta.verbose_name + ' (%s.%s)' % (model.__module__,model.__name__)
     name = None
     super(VoucherType,self).__init__(value,text,name)
예제 #3
0
파일: models.py 프로젝트: raffas/lino
    def get_slave_summary(self, obj, ar):
        vtypes = set()
        for m in dd.models_by_base(vat.VatDocument):
            vtypes.add(
                VoucherTypes.get_by_value(dd.full_model_name(m)))

        elems = []
        actions = []

        def add_action(btn):
            if btn is None:
                return False
            actions.append(btn)
            return True

        for jnl in Journal.objects.filter(voucher_type__in=vtypes):
            sar = ar.spawn(
                InvoicesByJournal,
                master_instance=jnl,
                known_values=dict(partner=obj))
            # logger.info(
            #     "20140604 sar.requesting_panel %s",
            #     sar.requesting_panel)
            if add_action(sar.insert_button(unicode(jnl), icon_name=None)):
                actions.append(' ')

        elems += [E.br(), _("Create voucher in journal ")] + actions
        return E.div(*elems)
예제 #4
0
    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 = set()
        for m in rt.models_by_base(vat.VatDocument):
            vtypes.add(
                VoucherTypes.get_by_value(dd.full_model_name(m)))

        actions = []

        def add_action(btn):
            if btn is None:
                return False
            actions.append(btn)
            return True

        for vt in vtypes:
            for jnl in vt.get_journals():
                sar = ar.spawn(
                    vt.table_class,
                    master_instance=jnl,
                    known_values=dict(partner=obj))
                if add_action(sar.insert_button(unicode(jnl),
                                                icon_name=None)):
                    actions.append(' ')

        elems += [E.br(), _("Create voucher in journal ")] + actions
        return E.div(*elems)
예제 #5
0
 def get_master_id_display(self,value):
     if self.master_type:
         try:
             return unicode(self.master_type.get_object_for_this_type(pk=value))
         except self.master_type.model_class().DoesNotExist,e:
             return "%s with pk %r does not exist" % (
                 dd.full_model_name(self.master_type.model_class()),value)
예제 #6
0
파일: makedocs.py 프로젝트: raffas/lino
    def generate_files(self):

        from lino.ui.extjs3 import UI

        # ~ UI = settings.SITE.get_ui_class
        ui = UI(make_messages=True)
        # ~ # install Lino urls under root location (`/`)
        # ~ ui = urlpatterns = ui.get_patterns()
        # ~ settings.SITE.setup()
        ui.make_linolib_messages()

        context = dict(
            header=rstgen.header,
            h1=curry(rstgen.header, 1),
            table=rstgen.table,
            doc=doc2rst,
            loading=loading,
            models=models,
            abstract=abstract,
            refto=refto,
            # ~ py2rst=rstgen.py2rst,
            full_model_name=full_model_name,
            model_overview=model_overview,
            model_referenced_from=model_referenced_from,
            model_ref=model_ref,
        )
        self.generate("index.rst.tmpl", "index.rst", **context)
        for a in loading.get_apps():
            app_label = a.__name__.split(".")[-2]
            app_models = models.get_models(a, include_auto_created=True)
            context.update(app=a, app_label=app_label, app_models=app_models)
            self.generate("app.rst.tmpl", "%s.rst" % app_label, **context)
            for model in app_models:
                context.update(model=model)
                self.generate("model.rst.tmpl", "%s.rst" % full_model_name(model), **context)
예제 #7
0
파일: makedocs.py 프로젝트: raffas/lino
def refto(x):
    if x is None:
        return "`None`"
    if issubclass(x, models.Model):
        return ":doc:`" + x.__name__ + " <" + full_model_name(x) + ">`"
    # ~ if isinstance(x,Field):
    return (
        ":ref:`"
        + x.verbose_name
        + " <"
        + settings.SITE.source_name
        + "."
        + full_model_name(x.model)
        + "."
        + x.name
        + ">`"
    )
예제 #8
0
파일: models.py 프로젝트: raffas/lino
 def create_journal(cls, trade_type=None, account=None, chart=None, **kw):
 #~ def create_journal(cls,jnl_id,trade_type,**kw):
     #~ doctype = get_doctype(cls)
     #~ jnl = Journal(doctype=doctype,id=jnl_id,*args,**kw)
     if isinstance(account, basestring):
         account = chart.get_account_by_ref(account)
         #~ account = account.Account.objects.get(chart=chart,ref=account)
     if isinstance(trade_type, basestring):
         trade_type = vat.TradeTypes.get_by_name(trade_type)
     vt = VoucherTypes.get_by_value(dd.full_model_name(cls))
     kw.update(chart=chart)
     if account is not None:
         kw.update(account=account)
     #~ jnl = Journal(trade_type=tt,voucher_type=vt,id=jnl_id,**kw)
     return Journal(trade_type=trade_type, voucher_type=vt, **kw)
예제 #9
0
파일: models.py 프로젝트: raffas/lino
 def get_journals(cls):
     vt = VoucherTypes.get_by_value(dd.full_model_name(cls))
     #~ doctype = get_doctype(cls)
     return Journal.objects.filter(voucher_type=vt).order_by('seqno')
예제 #10
0
파일: models.py 프로젝트: raffas/lino
 def journal_choices(cls):
     logger.info("20140603 journal_choices %r", cls)
     vt = VoucherTypes.get_by_value(dd.full_model_name(cls))
     qs = Journal.objects.filter(voucher_type=vt)
     logger.info("20140603 %s %s ", vt, qs.query)
     return qs
예제 #11
0
파일: models.py 프로젝트: raffas/lino
 def get_choices_text(self, obj, request, field):
     if field.name == "content_type":
         return "%s (%s)" % (dd.full_model_name(obj.model_class()), obj)
     return obj.get_choices_text(request, self, field)
예제 #12
0
파일: models.py 프로젝트: cuchac/lino
def on_remove_child(sender=None, request=None, child=None, **kw):
    master = get_master(sender)
    if master is None:
        return
    log_change(ChangeTypes.remove_child, request,
               master, sender, dd.full_model_name(child))