fix: 修复bluk_create root 组织下判断 (#8581)

Co-authored-by: feng626 <1304903146@qq.com>
pull/8582/head
fit2bot 2 years ago committed by GitHub
parent e724cdf53d
commit 5155b3c184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -43,15 +43,19 @@ class OrgManager(models.Manager):
def bulk_create(self, objs, batch_size=None, ignore_conflicts=False):
org = get_current_org()
org_id = org.id
for obj in objs:
obj.org_id = org_id
if org.is_root():
if not self.org_id:
raise ValidationError('Please save in a organization')
else:
obj.org_id = org.id
return super().bulk_create(objs, batch_size, ignore_conflicts)
class OrgModelMixin(models.Model):
org_id = models.CharField(max_length=36, blank=True, default='',
verbose_name=_("Organization"), db_index=True)
org_id = models.CharField(
max_length=36, blank=True, default='', verbose_name=_("Organization"), db_index=True
)
objects = OrgManager()
sep = '@'

Loading…
Cancel
Save