mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-06 07:18:48 +00:00
Ref: https://stackoverflow.com/questions/37958130/automatically-round-djangos-decimalfield-according-to-the-max-digits-and-decima
80 lines
1.7 KiB
Python
80 lines
1.7 KiB
Python
"""
|
|
Django Forms for interacting with Company app
|
|
"""
|
|
|
|
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from InvenTree.forms import HelperForm
|
|
from InvenTree.fields import RoundingDecimalFormField
|
|
|
|
from .models import Company
|
|
from .models import SupplierPart
|
|
from .models import SupplierPriceBreak
|
|
|
|
|
|
class EditCompanyForm(HelperForm):
|
|
""" Form for editing a Company object """
|
|
|
|
class Meta:
|
|
model = Company
|
|
fields = [
|
|
'name',
|
|
'description',
|
|
'website',
|
|
'address',
|
|
'phone',
|
|
'email',
|
|
'contact',
|
|
'is_customer',
|
|
'is_supplier',
|
|
]
|
|
|
|
|
|
class CompanyImageForm(HelperForm):
|
|
""" Form for uploading a Company image """
|
|
|
|
class Meta:
|
|
model = Company
|
|
fields = [
|
|
'image'
|
|
]
|
|
|
|
|
|
class EditSupplierPartForm(HelperForm):
|
|
""" Form for editing a SupplierPart object """
|
|
|
|
class Meta:
|
|
model = SupplierPart
|
|
fields = [
|
|
'part',
|
|
'supplier',
|
|
'SKU',
|
|
'description',
|
|
'manufacturer',
|
|
'MPN',
|
|
'URL',
|
|
'note',
|
|
'base_cost',
|
|
'multiple',
|
|
'packaging',
|
|
# 'lead_time'
|
|
]
|
|
|
|
|
|
class EditPriceBreakForm(HelperForm):
|
|
""" Form for creating / editing a supplier price break """
|
|
|
|
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
|
|
|
cost = RoundingDecimalFormField(max_digits=10, decimal_places=5)
|
|
|
|
class Meta:
|
|
model = SupplierPriceBreak
|
|
fields = [
|
|
'part',
|
|
'quantity',
|
|
'cost',
|
|
'currency',
|
|
]
|