2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-10 23:14:13 +00:00

[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-24 23:28:36 +01:00
committed by GitHub
parent e730b5c24c
commit 1960e662a7
3 changed files with 85 additions and 115 deletions

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".