|
@@ -17,11 +17,28 @@ class CostInline(admin.TabularInline):
|
|
|
extra = 0
|
|
|
|
|
|
|
|
|
+class ServiceInline(admin.TabularInline):
|
|
|
+ model = Service
|
|
|
+ fields = ('name', 'monthly_unit_cost', 'new_subscriber_cost')
|
|
|
+ readonly_fields = ('name', 'monthly_unit_cost', 'new_subscriber_cost')
|
|
|
+ show_change_link = True
|
|
|
+ extra = 0
|
|
|
+
|
|
|
+ def monthly_unit_cost(self, obj):
|
|
|
+ return '{:.2f}€'.format(obj.get_prices()['unit_recurring_price'])
|
|
|
+ monthly_unit_cost.short_description = "Coût de revient mensuel"
|
|
|
+
|
|
|
+ def new_subscriber_cost(self, obj):
|
|
|
+ return '{:.2f}€'.format(obj.get_prices()['total_goods_value_share'])
|
|
|
+ new_subscriber_cost.short_description = "Coût nouv. abo"
|
|
|
+
|
|
|
+
|
|
|
@admin.register(Document)
|
|
|
class DocumentAdmin(admin.ModelAdmin):
|
|
|
list_display = ('name', 'date', 'type')
|
|
|
actions = ['copy']
|
|
|
- inlines = [GoodInline, CostInline]
|
|
|
+ inlines = [ServiceInline, GoodInline, CostInline]
|
|
|
+ save_on_top = True
|
|
|
|
|
|
def copy(self, request, queryset):
|
|
|
for i in queryset.all():
|
|
@@ -105,6 +122,7 @@ class ServiceAdmin(admin.ModelAdmin):
|
|
|
'fields': ('reusable',)
|
|
|
})
|
|
|
)
|
|
|
+ save_on_top = True
|
|
|
|
|
|
def get_form(self, request, obj=None, **kwargs):
|
|
|
if obj:
|