Skip to content

Commit

Permalink
Added filters precursors in modeladmin and some translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kejebo committed May 7, 2024
1 parent bf1d8fb commit 6a1c33f
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 14 deletions.
23 changes: 21 additions & 2 deletions src/laboratory/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ class LaboratoryAdmin(admin.ModelAdmin):
search_fields = ['name']
list_filter = ['organization']

class PrecursorReportValuesInline(admin.TabularInline):
model = models.PrecursorReportValues
fields = ["object", "measurement_unit", "previous_balance", "new_income", "stock", "month_expense", "final_balance"]

class PrecursorReportAdmin(admin.ModelAdmin):
search_fields = ["laboratory__name","month","year"]
list_filter = ["laboratory__name","month","year"]
list_display = ["consecutive","laboratory","month","year"]
inlines = (PrecursorReportValuesInline, )

class PrecursorReportValuesAdmin(admin.ModelAdmin):
search_fields = ["precursor_report__laboratory__name","object__code", "object__name"]

list_display = ["precursor_report","object","measurement_unit", "final_balance"]

class BaseUnittAdmin(admin.ModelAdmin):
list_display = ["measurement_unit","si_value"]

admin.site.register(models.Laboratory, LaboratoryAdmin)
admin.site.register(models.Protocol)
Expand All @@ -74,13 +91,15 @@ class LaboratoryAdmin(admin.ModelAdmin):
admin.site.register(models.Provider)
admin.site.register(models.ObjectLogChange)
admin.site.register(models.TranferObject)
admin.site.register(models.PrecursorReport)
admin.site.register(models.PrecursorReport,PrecursorReportAdmin)
admin.site.register(models.RegisterUserQR)
admin.site.register(models.OrganizationStructure, OrganizationStrutureAdmin)
admin.site.register(models.UserOrganization)
admin.site.register(models.InformScheduler, InformSchedulerAdmin)
admin.site.register(models.ShelfObjectObservation)
admin.site.register(models.PrecursorReportValues)
admin.site.register(models.BaseUnitValues,BaseUnittAdmin)
admin.site.register(models.PrecursorReportValues,PrecursorReportValuesAdmin)



admin.site.site_header = _('Organilab Administration site')
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Generated by Django 4.1.13 on 2024-05-07 23:00

from django.db import migrations, models
import django.db.models.deletion
import laboratory.catalog


class Migration(migrations.Migration):

dependencies = [
('laboratory', '0140_alter_precursorreportvalues_previous_balance'),
]

operations = [
migrations.AlterField(
model_name='precursorreportvalues',
name='bills',
field=models.CharField(blank=True, max_length=200, verbose_name='Bills'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='final_balance',
field=models.FloatField(default=0.0, verbose_name='Final balance'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='measurement_unit',
field=laboratory.catalog.GTForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='laboratory.catalog', verbose_name='Measurement unit'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='month_expense',
field=models.FloatField(default=0.0, verbose_name='Month expense'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='new_income',
field=models.FloatField(default=0.0, verbose_name='New income'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='object',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='laboratory.object', verbose_name='Object'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='precursor_report',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='laboratory.precursorreport', verbose_name='Report'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='previous_balance',
field=models.FloatField(default=0.0, verbose_name='Previous balance'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='providers',
field=models.CharField(blank=True, max_length=200, verbose_name='Providers'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='quantity',
field=models.FloatField(default=0.0, verbose_name='Quantity'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='reason_to_spend',
field=models.TextField(blank=True, verbose_name='Reason to spend'),
),
migrations.AlterField(
model_name='precursorreportvalues',
name='stock',
field=models.FloatField(default=0.0, verbose_name='Stock'),
),
]
24 changes: 12 additions & 12 deletions src/laboratory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,21 +940,21 @@ def get_object_detail(self):
)

class PrecursorReportValues(models.Model):
precursor_report= models.ForeignKey("PrecursorReport", on_delete= models.CASCADE)
object = models.ForeignKey(Object, on_delete=models.CASCADE)
precursor_report= models.ForeignKey("PrecursorReport", on_delete= models.CASCADE, verbose_name=_("Report"))
object = models.ForeignKey(Object, on_delete=models.CASCADE, verbose_name=_("Object"))
measurement_unit = catalog.GTForeignKey(Catalog,
on_delete=models.DO_NOTHING,
verbose_name=_('measurement unit'),
verbose_name=_('Measurement unit'),
key_name="key", key_value='units')
quantity = models.FloatField(default=0.0)
previous_balance = models.FloatField(default=0.0)
new_income = models.FloatField(default=0.0)
bills = models.CharField(max_length=200, blank=True)
providers = models.CharField(max_length=200, blank=True)
stock = models.FloatField(default=0.0)
month_expense = models.FloatField(default=0.0)
final_balance = models.FloatField(default=0.0)
reason_to_spend = models.TextField(blank=True)
quantity = models.FloatField(default=0.0, verbose_name=_("Quantity"))
previous_balance = models.FloatField(default=0.0, verbose_name=_("Previous balance"))
new_income = models.FloatField(default=0.0, verbose_name=_("New income"))
bills = models.CharField(max_length=200, blank=True, verbose_name=_("Bills"))
providers = models.CharField(max_length=200, blank=True, verbose_name=_("Providers"))
stock = models.FloatField(default=0.0, verbose_name=_("Stock"))
month_expense = models.FloatField(default=0.0, verbose_name=_("Month expense"))
final_balance = models.FloatField(default=0.0, verbose_name=_("Final balance"))
reason_to_spend = models.TextField(blank=True, verbose_name=_("Reason to spend"))

class PrecursorReport(models.Model):
month = models.IntegerField(choices=MONTHS)
Expand Down
21 changes: 21 additions & 0 deletions src/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4614,3 +4614,24 @@ msgstr "Reporte_sobre_precursores_%(month)s_%(consecutive)d"

msgid "Email address is associated to an username."
msgstr "La dirección de correo se encuentra asociada a un nombre de usuario."

msgid "Month expense"
msgstr "Gasto mensual"

msgid "Previous balance"
msgstr "Balance anterior"

msgid "New income"
msgstr "Nuevo ingreso"

msgid "Bills"
msgstr "Facturas"

msgid "Stock"
msgstr "Existencias"

msgid "Reason to spend"
msgstr "Razon del gasto"

msgid "Final balance"
msgstr "Balance final"

0 comments on commit 6a1c33f

Please sign in to comment.