[BUG] Fix ownership (#4244)

* Reenable ownership tests

* [BUG] Stock item ownership results in stock item being read-only
Fixes #4229

* rebuild ownership tests

* jsut test stock stuff for now

* move ownership check to Owner

* fix assertation with lazy objects

* test all of stock

* Add edit checks

* remove old tests

* run full coverage again

* fix test
This commit is contained in:
Matthias Mair
2023-01-25 09:28:36 +11:00
committed by GitHub
parent e730b5c24c
commit 1960e662a7
3 changed files with 78 additions and 108 deletions
+2 -2
View File
@@ -146,7 +146,7 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
# So, no ownership checks to perform!
return True
return user in owner.get_related_owners(include_group=True)
return owner.is_user_allowed(user, include_group=True)
def clean(self):
"""Custom clean action for the StockLocation model:
@@ -864,7 +864,7 @@ class StockItem(InvenTreeBarcodeMixin, MetadataMixin, MPTTModel):
if owner is None:
return True
return user in owner.get_related_owners(include_group=True)
return owner.is_user_allowed(user, include_group=True)
def is_stale(self):
"""Returns True if this Stock item is "stale".