forked from erp-dev/erp
fix: binding merchant and employee at admin site
This commit is contained in:
@@ -25,9 +25,10 @@ class AdminBase(admin.ModelAdmin):
|
||||
return result
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
if not change:
|
||||
if not change and isinstance(obj, models.Employee) is False:
|
||||
if not obj.merchant_id:
|
||||
obj.merchant_id = request.user.employee.merchant.id
|
||||
if request.user.is_superuser is False:
|
||||
obj.merchant_id = request.user.employee.merchant.id
|
||||
return super().save_model(request, obj, form, change)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user