| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/erp/asset/__pycache__/ |
Upload File : |
o
hͦha
� @ s\ d Z ddlZddlZddlZddlmZmZ ddlmZ ddlZ ddl
mZ ddlm
Z
ddlmZ ddlmZ dd lmZ dd
lmZmZmZ ddlmZmZmZ ddlmZ dd
lmZ ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC ddlDmEZE ddlFmGZGmHZH ddlImJZJ ddlKmLZLmMZMmNZNmOZOmPZP ddlQmRZR ddlSmTZT ddlUmVZV ddlWmXZX dd� ZYeMeLePd�dd� ���ZZeMd�dd ��Z[eMeLePd!�d"d#� ���Z\eMeLd$d%� ��Z]eMePd&d'�d(d)� ��Z^eMeLd*d+� ��Z_eMeLePd,d'�d-d.� ���Z`eMeLePd/d'�d0d1� ���ZaeMePd2d'�d3d4� ��Zbd5d6� ZceMePd7d'�d8d9� ��ZdeMePd7d'�d:d;� ��Zed<d=� ZfeMeLd>d?� ��ZgeMeLePd@d'�dAdB� ���ZhdCdD� ZieMePd@d'�dEdF� ��ZjeMePd@d'�dGdH� ��ZkeMdIdJ� �ZleMePdKd'�dLdM� ��ZmdNdO� ZneMePdP�dQdR� ��ZoeMdSdT� �ZpeMeLdUdV� ��ZqeMeLdWdX� ��ZreMeLdYdZ� ��Zsd[d\� Zted]d^�Zud_d`� Zvdadb� ZweMePdd'�dcdd� ��ZxeMdedf� �ZyeMePd7�dgdh� ��ZzeMePdid'�djdk� ��Z{eMePdld'�dmdn� ��Z|eMePdod'�dpdq� ��Z}eMePdrd'�dsdt� ��Z~eMeLdudv� ��ZeMdwdx� �Z�eMePd7d'�dydz� ��Z�eMePdPd'�d{d|� ��Z�eMePd}d'�d~d� ��Z�eMePd7d'�d�d�� ��Z�eMePd7d'�d�d�� ��Z�eMePd}d'�d�d�� ��Z�eMePd}d'�d�d�� ��Z�eMePd}d'�d�d�� ��Z�eMeOd�eG�d�d�� ��Z�eMeLd�d�� ��Z�eMeLd�d�� ��Z�dS )�z#"
asset.py
This module is used to � N)�date�datetime)�parse_qs)�messages)�ContentFile)�FileSystemStorage)� Paginator)�ProtectedError)�HttpResponse�HttpResponseRedirect�JsonResponse)�get_object_or_404�redirect�render)�reverse)�gettext_lazy)
�AssetAllocationFilter�AssetAllocationReGroup�AssetCategoryFilter�AssetExportFilter�AssetFilter�AssetHistoryFilter�AssetHistoryReGroup�AssetRequestFilter�AssetRequestReGroup�CustomAssetFilter)�AssetAllocationForm�AssetBatchForm�AssetCategoryForm� AssetForm�AssetReportForm�AssetRequestForm�AssetReturnForm)�Asset�AssetAssignment�
AssetCategory�AssetDocuments�AssetLot�AssetRequest�ReturnImages)�closest_numbers�
eval_validate�filtersubordinates�get_key_instances�get_pagination�
paginator_qry�sortby)�Company)�Employee�EmployeeWorkInformation)�settings)�hx_request_required�login_required�manager_can_enter�owner_can_enter�permission_required)�group_by_queryset)�HORILLA_DATE_FORMATS)�horilla_users_with_perms)�notifyc C sD z|� � t�| td�� W dS ty! t�| td�� Y dS w )zJ
Handle the deletion of an asset and provide message to the user.
zAsset deleted successfullyzYou cannot delete this asset.N)�deleter �success�_r �error)�request�asset� rD �/var/www/erp/asset/views.py� asset_delN s �rF zasset.add_assetc C s� d|i}| j �d�rt| j |d�nt|d�}| jdkr8t| j|d�}|�� r8|�� t�| t d�� t
d|d�S d|i}t| d |�S )
a{
View function for creating a new asset object.
Args:
request (HttpRequest): A Django HttpRequest object that contains information
about the current request.
asset_category_id (int): An integer representing the ID of the asset category for which
the asset is being created.
Returns:
If the request method is 'POST' and the form is valid, the function saves the
new asset object to the database
and redirects to the asset creation page with a success message.
If the form is not valid, the function returns the asset creation page with the
form containing the invalid data.
If the request method is not 'POST', the function renders the asset creation
page with the form initialized with
the ID of the asset category for which the asset is being created.
Raises:
None
�asset_category_id�csrfmiddlewaretoken��initial�POSTzAsset created successfully�asset-creation)rG �asset_creation_formzasset/asset_creation.html)�GET�getr �methodrK �is_valid�saver r? r@ r r )rB rG �initial_data�form�contextrD rD rE �asset_creationY s
��
rV c C s� t � }|r1tjj|d�}t d|id�}| j�d�s1| jjtjj|dd�jks,| j� d�r-nt
t�S | jdkrrt | j
| jd|id�}|�� rr|�� }t�| td �� |�� rr| jrr| j�d
�D ]
}tjj||d� q^t| j�dd
��S t| d||d��S )z7
Function for adding asset report to the asset
��id�asset_idrI �
asset_listT)rY �return_date__isnull�asset.change_assetrK zReport added successfully.�file)�asset_reportr] �HTTP_REFERER�/zasset/asset_report_form.html)�asset_report_formrY )r r# �objectsrO rN �user�employee_getr$ �assigned_to_employee_id�has_permr �asset_request_allocation_viewrP rK �FILESrQ rR r r? r@ �getlistr&