Commit 41f65de9 authored by mehdi's avatar mehdi

add readonly barcode

parent 4151bcae
......@@ -58,8 +58,14 @@ class ReceiptForm(forms.ModelForm):
class PackageForm(forms.ModelForm):
class Meta:
model = Package
fields = ("net_weight", "product", "package_weight", "bobin_weight", "bobin")
fields = ("barcode", "net_weight", "product", "package_weight", "bobin_weight", "bobin")
widgets = {
"barcode": forms.TextInput(
attrs={
"class": "form-control",
'style': 'font-size: 150%; height:calc(2.5rem + 2px)'
}
),
"net_weight": forms.NumberInput(
attrs={
"class": "form-control",
......@@ -67,7 +73,7 @@ class PackageForm(forms.ModelForm):
"onfocus": "this.select();",
"min": 0, "value": 0, "step": 0.01,
'autocomplete': 'off',
'style': 'font-size: xxx-large; height:calc(4rem + 2px)',
'style': 'font-size: 300%; height:calc(4rem + 2px)',
}
),
"product": forms.Select(attrs={"class": "form-control"}),
......@@ -78,6 +84,8 @@ class PackageForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['barcode'].initial = Package.generate_barcode()
self.fields['barcode'].disabled = True
if Package.objects.exists():
last_package = Package.objects.order_by("-id")[0]
self.fields['product'].initial = last_package.product
......
......@@ -159,7 +159,6 @@ class PackageCreateView(LoginRequiredMixin, CreateView):
def form_valid(self, form):
instance = form.save(commit=False)
instance.gross_weight = instance.calc_gross_weight
instance.barcode = Package.generate_barcode()
instance.save()
instance.product.update_inventory_value(instance.net_weight)
# params = {"": [*self.request.GET.getlist(""), instance.id]}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment