wbcrm 1.44.2__py2.py3-none-any.whl → 1.44.4__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of wbcrm might be problematic. Click here for more details.

wbcrm/filters/accounts.py CHANGED
@@ -32,6 +32,10 @@ class AccountFilter(wb_filters.FilterSet):
32
32
  method="filter_not_owner",
33
33
  )
34
34
 
35
+ status = wb_filters.MultipleChoiceFilter(
36
+ choices=Account.Status.choices, label="Status", default=[Account.Status.OPEN.value]
37
+ )
38
+
35
39
  def filter_not_owner(self, queryset, name, value):
36
40
  if value:
37
41
  return queryset.exclude(owner__in=value)
@@ -46,7 +50,6 @@ class AccountFilter(wb_filters.FilterSet):
46
50
  model = Account
47
51
  fields = {
48
52
  "reference_id": ["icontains"],
49
- "status": ["exact"],
50
53
  "is_active": ["exact"],
51
54
  "parent": ["exact", "isnull"],
52
55
  "is_terminal_account": ["exact"],
wbcrm/models/accounts.py CHANGED
@@ -25,7 +25,6 @@ from wbcore.metadata.configs.buttons import ActionButton
25
25
  from wbcore.models import WBModel
26
26
  from wbcore.signals import pre_merge
27
27
  from wbcore.utils.models import (
28
- ActiveObjectManager,
29
28
  ComplexToStringMixin,
30
29
  DeleteToDisableMixin,
31
30
  )
@@ -67,14 +66,19 @@ class AccountDefaultQueryset(QuerySet):
67
66
  ).filter((Q(is_public=True) & Q(has_descending_roles=True)) | Q(has_direct_role=True))
68
67
 
69
68
 
70
- class AccountManager(ActiveObjectManager):
69
+ class AccountManager(models.Manager):
71
70
  def get_queryset(self) -> AccountDefaultQueryset:
72
- return AccountDefaultQueryset(self.model).filter(is_active=True)
71
+ return AccountDefaultQueryset(self.model)
73
72
 
74
73
  def filter_for_user(self, user: User, validity_date: date | None = None, strict: bool = False) -> QuerySet:
75
74
  return self.get_queryset().filter_for_user(user, validity_date=validity_date, strict=strict)
76
75
 
77
76
 
77
+ class ActiveAccountManager(AccountManager):
78
+ def get_queryset(self):
79
+ return super().get_queryset().filter(is_active=True)
80
+
81
+
78
82
  class OpenAccountObjectManager(AccountManager):
79
83
  def get_queryset(self):
80
84
  return super().get_queryset().filter(status=Account.Status.OPEN, is_active=True)
@@ -261,6 +265,10 @@ class Account(ComplexToStringMixin, DeleteToDisableMixin, WBModel, MPTTModel):
261
265
  # else:
262
266
  # self.is_terminal_account = False
263
267
  self.is_terminal_account = self.is_leaf_node()
268
+ if not self.is_active:
269
+ self.status = self.Status.CLOSE
270
+ if self.status == self.Status.CLOSE:
271
+ self.is_active = False
264
272
  super().save(*args, **kwargs)
265
273
  # self.children.update() TODO recompute str for all children
266
274
  # Account.objects.filter(id=self.id).update(computed_str=self.compute_str())
@@ -333,7 +341,8 @@ class Account(ComplexToStringMixin, DeleteToDisableMixin, WBModel, MPTTModel):
333
341
  verbose_name_plural = _("Accounts")
334
342
  permissions = [("administrate_account", "Administrate Account")]
335
343
 
336
- objects = AccountManager()
344
+ objects = ActiveAccountManager()
345
+ all_objects = AccountManager()
337
346
  open_objects = OpenAccountObjectManager()
338
347
  tree_objects = TreeManager()
339
348
 
@@ -585,7 +594,8 @@ def handle_user_deactivation(sender, instance, substitute_profile=None, **kwargs
585
594
  for validity in profile_role.validity_set.all():
586
595
  if validity.timespan.upper >= deactivation_date: # type: ignore
587
596
  validity.timespan = DateRange(
588
- validity.timespan.lower, max([deactivation_date, validity.timespan.lower]) # type: ignore
597
+ validity.timespan.lower,
598
+ max([deactivation_date, validity.timespan.lower]), # type: ignore
589
599
  )
590
600
  validity.save()
591
601
  if substitute_profile and validity.timespan.lower <= deactivation_date: # type: ignore
@@ -16,6 +16,9 @@ class AccountRoleTypeRepresentationSerializer(wb_serializers.RepresentationSeria
16
16
  class AccountRepresentationSerializer(wb_serializers.RepresentationSerializer):
17
17
  _detail = wb_serializers.HyperlinkField(reverse_name="wbcrm:account-detail")
18
18
 
19
+ def get_filter_params(self, request):
20
+ return {"is_active": True}
21
+
19
22
  class Meta:
20
23
  model = Account
21
24
  fields = ("id", "computed_str", "_detail")
@@ -17,6 +17,18 @@ class TestAccountModel:
17
17
  def test_init(self, account):
18
18
  assert account.id is not None
19
19
 
20
+ def test_close_account_set_inactive(self, account):
21
+ assert account.is_active
22
+ account.status = Account.Status.CLOSE
23
+ account.save()
24
+ assert not account.is_active
25
+
26
+ def test_disable_account_set_status_close(self, account):
27
+ assert account.status == Account.Status.OPEN
28
+ account.delete()
29
+ assert not account.is_active
30
+ assert account.status == Account.Status.CLOSE
31
+
20
32
  def test_account_with_owner_create_account_role(self, account_factory, entry_factory):
21
33
  customer = entry_factory.create()
22
34
  account = account_factory.create(owner=customer)
@@ -44,14 +44,14 @@ class AccountRepresentationViewSet(AccountPermissionMixin, viewsets.Representati
44
44
  filterset_class = AccountFilter
45
45
 
46
46
  serializer_class = AccountRepresentationSerializer
47
- queryset = Account.objects.all()
47
+ queryset = Account.all_objects.all()
48
48
  ordering = ["title"]
49
49
 
50
50
 
51
51
  class AccountModelViewSet(MergeMixin, AccountPermissionMixin, viewsets.ModelViewSet):
52
52
  serializer_class = AccountModelSerializer
53
53
  filterset_class = AccountFilter
54
- queryset = Account.objects.select_related("owner", "parent").annotate(
54
+ queryset = Account.all_objects.select_related("owner", "parent").annotate(
55
55
  has_children=Exists(Account.objects.filter(parent=OuterRef("pk"))),
56
56
  _group_key=Case(When(has_children=True, then=F("id")), default=None, output_field=IntegerField()),
57
57
  )
@@ -15,6 +15,7 @@ class AccountDisplayConfig(DisplayViewConfig):
15
15
  def get_list_display(self) -> Optional[dp.ListDisplay]:
16
16
  return dp.ListDisplay(
17
17
  fields=[
18
+ dp.Field(key="status", label="Status"),
18
19
  dp.Field(
19
20
  key="owner",
20
21
  label="Owner",
@@ -22,7 +23,6 @@ class AccountDisplayConfig(DisplayViewConfig):
22
23
  dp.Field(key="reference_id", label="Reference ID"),
23
24
  dp.Field(key="is_terminal_account", label="Terminal Account"),
24
25
  dp.Field(key="is_public", label="Public"),
25
- dp.Field(key="is_active", label="Active"),
26
26
  dp.Field(
27
27
  key="llm",
28
28
  label="LLM Analysis",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbcrm
3
- Version: 1.44.2
3
+ Version: 1.44.4
4
4
  Summary: A workbench module that contains all the functionality related to a customer relationship management.
5
5
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
6
6
  Requires-Dist: django-eventtools==1.*
@@ -19,7 +19,7 @@ wbcrm/factories/activities.py,sha256=hr7i7hUOgPclAwB8v5Z1t7tYkCCXIRr4TbJAUuxj1CA
19
19
  wbcrm/factories/groups.py,sha256=2iCMCSPGsMYHGjqfNUcX3gK3AzMivxzJfpw_P0F8QFs,620
20
20
  wbcrm/factories/products.py,sha256=mQ2WHo4jDheppSyQBPGktnTeTp52j0BN0pggPBsAzYE,243
21
21
  wbcrm/filters/__init__.py,sha256=ZX47xCq18N_FTvvFCk2mIlFoValKFaTcxw9xv8qdn0E,305
22
- wbcrm/filters/accounts.py,sha256=RPW7qkuc6bxF9RHeknntMgWOr9tlUhBKqTMMtO1gmTI,2217
22
+ wbcrm/filters/accounts.py,sha256=SeVwNJlNmbVgyZFyXBUFiVxQqmuJ578-EVdNwWJ4DIc,2329
23
23
  wbcrm/filters/activities.py,sha256=zPYPGcMr7wneBgU6ldLBoqE1hLGxUjQZlDKdVqJTNc8,7782
24
24
  wbcrm/filters/groups.py,sha256=KcjyimEoJ7LB_KIRyTIsiNneVWf5ud9CvSqJasffud0,623
25
25
  wbcrm/filters/products.py,sha256=gCiL4MVsaLZgLhyLeclWsBdKLRoYS-C7tL52_VWtfKE,1203
@@ -46,7 +46,7 @@ wbcrm/migrations/0016_auto_20241205_1015.py,sha256=E82BmOegfyJmmmaKemL_bT2OEVywi
46
46
  wbcrm/migrations/0017_event.py,sha256=PzhAVAa2z4itzctQBz-6i__aRDh3TDe029F8leE34W0,1422
47
47
  wbcrm/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  wbcrm/models/__init__.py,sha256=23U2eBeZStYgUKSGfi3q88JtfqfbNTk7MbnLEAGw1gk,287
49
- wbcrm/models/accounts.py,sha256=jUJth33rvm_dv6UFRuelLpfXGrOQFTCyrY7hnNNd97s,25130
49
+ wbcrm/models/accounts.py,sha256=fKSSUsA6saN4HA9SyXzjmjlpsRmNW1jNs7EYD-4PtGE,25429
50
50
  wbcrm/models/activities.py,sha256=EP9yv9dP5ZNUXUrgRVEtRZXsbnMiNXbD1elxq5uYyoM,53909
51
51
  wbcrm/models/events.py,sha256=jUHArKuZlPzMXpzwrtxM0fI6POF2-ETybtphjPQxqqA,393
52
52
  wbcrm/models/groups.py,sha256=T4ikoRw6BNWL5oeHDITsGt0KJWibm3OMYppwnkBliMM,4300
@@ -56,7 +56,7 @@ wbcrm/models/llm/activity_summaries.py,sha256=8dJP_aDVoakanbOnj_jYnSpeqX8b7JYtU1
56
56
  wbcrm/models/llm/analyze_relationship.py,sha256=Po6nE9GrlwKZtL471fsWySJYDqRZGW20cLAQTdiqFGk,2346
57
57
  wbcrm/report/activity_report.py,sha256=AzSfiWne--CG4C4jpcODJtqegxcALCqxvOs9jeD4EB8,4835
58
58
  wbcrm/serializers/__init__.py,sha256=qKwo5e-Ix-Iow1RRdKFC0uZQmuSHzc8DIypIhi_E8HI,726
59
- wbcrm/serializers/accounts.py,sha256=pt9tu8a7P0TO9h4zMBoS1jEfdlqcQ0IaiM1S9sOT13A,4915
59
+ wbcrm/serializers/accounts.py,sha256=5YJD3vsHJEXB8eBjAmrXDRRDV4O46Z56wl_8Xgl77gU,4993
60
60
  wbcrm/serializers/activities.py,sha256=BSxMbvOLrKOBTS98vbzjTodKNWEd_qYv4sfdfSCiUZE,21846
61
61
  wbcrm/serializers/groups.py,sha256=YqiHGiytbD1lIuSUEBk4CwlwipAFs_uh2V9DZG7JukQ,783
62
62
  wbcrm/serializers/products.py,sha256=PCyUAAdcl98CDSyGtH8orE0t1gM5exfW6E4E43Mm1I0,2001
@@ -91,7 +91,7 @@ wbcrm/synchronization/activity/backends/google/tasks.py,sha256=vQ-_z6koyAQd6kjp3
91
91
  wbcrm/synchronization/activity/backends/google/typing_informations.py,sha256=7fDaQEok0kzm_5_vrRrMiakFAh2O3j4G09XWPwYSK1I,2655
92
92
  wbcrm/synchronization/activity/backends/google/utils.py,sha256=glDYCtbQDnTrge2mpVM-GICebneaa_I9KZwCgFkwRMA,11572
93
93
  wbcrm/synchronization/activity/backends/google/request_utils/__init__.py,sha256=FQ8XwEEPtUR-DKHBgiNJQXHPduUNcJM9YiTSEH5LXmQ,530
94
- wbcrm/synchronization/activity/backends/google/request_utils/external_to_internal/create.py,sha256=VyAg2iftSO_hyQthX6dtL299cogIFWsmrhE_xOwZQbs,3622
94
+ wbcrm/synchronization/activity/backends/google/request_utils/external_to_internal/creat,sha256=VyAg2iftSO_hyQthX6dtL299cogIFWsmrhE_xOwZQbs,3622
95
95
  wbcrm/synchronization/activity/backends/google/request_utils/external_to_internal/delete.py,sha256=AvhoJx-vzf2RlHtDPwXy4LXQtxSGaTWQXLiHlmlFCtE,3700
96
96
  wbcrm/synchronization/activity/backends/google/request_utils/external_to_internal/update.py,sha256=4AWhTV-Rdtp4RVijULw7JlIr7ewYVLWv4s6SBb4OKuI,7810
97
97
  wbcrm/synchronization/activity/backends/google/request_utils/internal_to_external/update.py,sha256=XqEfqrLzELrxhCCovP_qvL1FECeiqxhV6caVZHfwRvk,8990
@@ -130,13 +130,13 @@ wbcrm/tests/test_tasks.py,sha256=rVlRa1LNvgPdKDJ3B7SGed7kC5bPFybAYwLwxNp-NHI,418
130
130
  wbcrm/tests/test_viewsets.py,sha256=IjTgeuYMcIjO1HF0p6tHWNSHRyOGQm7niivzwDu8ERo,50232
131
131
  wbcrm/tests/tests.py,sha256=8K8FaLYBB5GUUBjix9W-Lrq6odNeZuMgfSfA7msJEpQ,4801
132
132
  wbcrm/tests/accounts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
133
- wbcrm/tests/accounts/test_models.py,sha256=YmtEG7s-BC5i_E6xSjsjV1qE5-roIxDtmD6Lp1i6qxE,17959
133
+ wbcrm/tests/accounts/test_models.py,sha256=u0ENs2cXS4Ffev2-JCdMtWpSuzXFXvD_iDS6gqpViJM,18387
134
134
  wbcrm/tests/accounts/test_viewsets.py,sha256=bMWftVBcttcQEMu6R6Wx-NYmokAxPYZ6UIj461qu2zA,3661
135
135
  wbcrm/tests/e2e/__init__.py,sha256=-6vGUXo06yKKvpNRO0Jy1eocIXblvn4-wWpTFuCNqRI,79
136
136
  wbcrm/tests/e2e/e2e_wbcrm_utility.py,sha256=on3jthFT1fJtKcdiaW6rTQNctkhHmsfdlmzaEl4JUU4,3313
137
137
  wbcrm/tests/e2e/test_e2e.py,sha256=diugvEYNpeT3GY3kHaaWolZ4gofTDOQv6JX6YKVzR8A,16519
138
138
  wbcrm/viewsets/__init__.py,sha256=aoi2Hry7C6CixqV7ZIVrVPSjrcRcdRkE3zBmm1Va1Qo,668
139
- wbcrm/viewsets/accounts.py,sha256=tDXcpYD_gd1RhC3cugAu87Sfd63AdfxRl6Sekj4fziA,4449
139
+ wbcrm/viewsets/accounts.py,sha256=KJUixdg6iVLI9RVKb8IXiA_d9dBVMQpZM7fDap7CwTY,4457
140
140
  wbcrm/viewsets/activities.py,sha256=7RxNRMZUkWwAGscXR4hThRe8CY6zXJn9OKvP2JjCo0A,12868
141
141
  wbcrm/viewsets/groups.py,sha256=5-ZqTSnd9Lve-RbN5WRluXOYLHHxkZSvjqC6nhAhsNw,1413
142
142
  wbcrm/viewsets/mixins.py,sha256=kpwFjiTuh3vwmIv1Fe8c9DsaPsO4yUQuTvPOttnn7Rg,1112
@@ -147,7 +147,7 @@ wbcrm/viewsets/buttons/accounts.py,sha256=8r07RQ5l-MZQO3yY-NT5D18nJs_lMVweYi28lH
147
147
  wbcrm/viewsets/buttons/activities.py,sha256=82HUR6G2UnzDkAMx6aViH254xZmvzawgYTQR0B-_sd8,3875
148
148
  wbcrm/viewsets/buttons/signals.py,sha256=DbY78n1T_zqs16DW5x_5gsFyd-GUN1KrExWLUvT5-YI,729
149
149
  wbcrm/viewsets/display/__init__.py,sha256=Ryjs6DW42eFHuh3_uW91blo0pgfR07dCDeZzOU12mNM,357
150
- wbcrm/viewsets/display/accounts.py,sha256=wbtwEJN2RA2RAXEQ04FzFKJsTX7PNgut8f8_q44Xsxs,4666
150
+ wbcrm/viewsets/display/accounts.py,sha256=9YcLcOIqj1xd-sO3xbbLzamATVY26nn_FDtcbQxfRsk,4663
151
151
  wbcrm/viewsets/display/activities.py,sha256=QLGlJDBfRbZ8zd-xlcZygiquh6KxwbI2LS7l3No6dsA,18652
152
152
  wbcrm/viewsets/display/groups.py,sha256=fwmqaWrGWS6GwCi2PkjH9dbgwx5uf8pebXrjDB5tIeQ,785
153
153
  wbcrm/viewsets/display/products.py,sha256=D5AmkE4HqZPcablhBmnQRpgCjKMD45vCaKjoAAnvY20,3988
@@ -170,6 +170,6 @@ wbcrm/viewsets/titles/products.py,sha256=cFAK5zljjybabk2U0KzPT2PVfV5vmO_UlJd6QlI
170
170
  wbcrm/viewsets/titles/utils.py,sha256=IaHQTmEG2OwIHS1bRv7sjuT950wefUJNi3yvPdrpNEs,1144
171
171
  wbcrm/workflows/__init__.py,sha256=biwXXPkVJugT9Vc1cwbInAUY8EnVmOauxdPz7e_2w_A,32
172
172
  wbcrm/workflows/assignee_methods.py,sha256=L7ymErtcpFgXdTMTj_lDOVJqsLAGLNT6qMlrkHGuXWM,999
173
- wbcrm-1.44.2.dist-info/METADATA,sha256=r2IrwXCKw2ZDzQ785p8Zkhd9igtC63T70ZHLj67eNl0,450
174
- wbcrm-1.44.2.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
175
- wbcrm-1.44.2.dist-info/RECORD,,
173
+ wbcrm-1.44.4.dist-info/METADATA,sha256=hyrozN0EsGVgWvhUUKX_L19vSFMNILPlXkIfjGg8cCU,450
174
+ wbcrm-1.44.4.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
175
+ wbcrm-1.44.4.dist-info/RECORD,,
File without changes