From b411160ee57d032602c43c775a50d97a2606e737 Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 6 Dec 2024 15:57:10 +0530 Subject: [PATCH] [ADD] PMS: Added company fields and updated the views based on company change for period and question templates --- pms/forms.py | 2 ++ pms/models.py | 3 ++- .../question_template_list.html | 17 ++++++++++++++++- pms/templates/okr/key_result/kr_list.html | 8 ++++---- pms/templates/period/period_list.html | 12 +++++++++++- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/pms/forms.py b/pms/forms.py index 23c5dc315..79fd09d19 100644 --- a/pms/forms.py +++ b/pms/forms.py @@ -855,6 +855,7 @@ class QuestionTemplateForm(ModelForm): def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) reload_queryset(self.fields) + self.fields["company_id"].required = True self.fields["company_id"].widget.attrs.update( { "class": "oh-select oh-select-2 w-100", @@ -1018,6 +1019,7 @@ class PeriodForm(ModelForm): kwargs["initial"] = set_date_field_initial(instance) super().__init__(*args, **kwargs) reload_queryset(self.fields) + self.fields["company_id"].required = True self.fields["company_id"].widget.attrs.update( { "class": "oh-select oh-select-2 w-100", diff --git a/pms/models.py b/pms/models.py index 3a417855e..3680bb2ae 100644 --- a/pms/models.py +++ b/pms/models.py @@ -432,7 +432,7 @@ class QuestionTemplate(HorillaModel): ) company_id = models.ManyToManyField(Company, blank=True, verbose_name=_("Company")) - objects = HorillaCompanyManager() + objects = HorillaCompanyManager("company_id") def __str__(self): return self.question_template @@ -811,6 +811,7 @@ class EmployeeBonusPoint(HorillaModel): on_delete=models.CASCADE, related_name="employeebonuspoint_set", ) + objects = HorillaCompanyManager("employee_id__employee_work_info__company_id") def __str__(self): return f"{self.employee_id.employee_first_name} - {self.bonus_point}" diff --git a/pms/templates/feedback/question_template/question_template_list.html b/pms/templates/feedback/question_template/question_template_list.html index cf2a9c514..5d03c671b 100644 --- a/pms/templates/feedback/question_template/question_template_list.html +++ b/pms/templates/feedback/question_template/question_template_list.html @@ -15,8 +15,9 @@
{% trans "Title" %}
{% trans "Total Question" %}
+
{% trans "Company" %}
{% if perms.pms.change_questiontemplate or perms.pms.delete_questiontemplate or request.user|filtersubordinates %} -
+
{% trans "Actions" %}
{% endif %}
@@ -47,6 +48,20 @@ class="oh-sticky-table__td" >{{question_template.question.count}} + + {% for cmp in question_template.company_id.all %} + {% if cmp.company %} + {{cmp.company}} , + {% endif %} + {% empty %} + {% trans "None." %} + {% endfor %} + {% if perms.pms.change_questiontemplate or perms.pms.delete_questiontemplate or request.user|filtersubordinates %}
diff --git a/pms/templates/okr/key_result/kr_list.html b/pms/templates/okr/key_result/kr_list.html index 2d6f9e33d..53787bfdf 100644 --- a/pms/templates/okr/key_result/kr_list.html +++ b/pms/templates/okr/key_result/kr_list.html @@ -63,6 +63,7 @@
{% trans "Target Value" %}
{% trans "Duration" %}
{% trans "Descrption" %}
+
{% trans "Company" %}
{% comment %}
{% trans "Is Active" %}
{% endcomment %}
{% trans "Actions" %}
@@ -98,10 +99,9 @@
{{kr.description}}
- {% comment %}
- {{kr.target_value}} -
{% endcomment %} - +
+ {{kr.company_id}} +
@@ -37,6 +38,15 @@
{{period.end_date}}
+
+ {% for p in period.company_id.all %} + {% if p.company %} + {{p.company}} , + {% endif %} + {% empty %} + {% trans "None." %} + {% endfor %} +
{% if perms.pms.change_period or perms.pms.delete_period or request.user|filtersubordinates %}