dashboard stock and pricing does not show existing stockrecord value

22 views
Skip to first unread message

John Boyd

unread,
Mar 15, 2021, 1:29:42 PMMar 15
to django-oscar
Hello,

I forked the dashboard catalogue app because I added an extra vat field to the StockRecord model.

Everything seems to be working fine however the vat input in the dashboard stock and pricing section does not show the value for existing products. However the correct values are shown in the standard django admin page.

See below.

Oscar Dashboard:
django_oscat_dashboard.png 

Django Admin:
oscar_admin.png

 I followed the docs for forking app.

My new models.py in forked partner app:
models.py.png

settings.py:
settings.py.png

Also in settings.py (new dashboard config):
catalogue_dashboard.png

And finally new forked forms.py:
forked_forms.png

So, if anyone can point me in the right direction, any help will
be greatly appreciated.

Note that I had bulk loaded the product and  stockrecord information
previously without using the dashboard. The product and stockrecord information is correct in the database.

Best Regards,
John.


solari...@gmail.com

unread,
Mar 15, 2021, 11:02:06 PMMar 15
to django-oscar
You're running into the issue described here - your choices are defined as floats, which are not the same as Decimal values, hence why the initial value of the form fields in the dashboard is not populated: https://stackoverflow.com/questions/5050574/decimal-field-in-django-admin-form

John Boyd

unread,
Mar 16, 2021, 11:52:27 AMMar 16
to django-oscar
Hello solarissmoke,

Thanks very much for looking at my query.

I think it may be something else.
At one time I had a default value of 12.5 in the DecimalField of the model. So the the initial value of of the form field was always 12.5, no problem there.

My issue is that for existing products I expected to see what is the present value , instead in the stock and pricing form I always saw 12.5.
Hence the reason why I removed the default,  hoping that when I looked at an existing product I would see the existing value of vat.
Instead I just see "----'.

The dropdrown works as it should. See pic below. 
However I don't see present values.
 I have also changed my model as per the link you suggested but no change.

dropdown.png

Updated model:

updated_model.png

solari...@gmail.com

unread,
Mar 17, 2021, 12:25:47 AMMar 17
to django-oscar
I'm still reasonably confident that how you're defining the decimal is where the problem is. See this comment in particular: https://stackoverflow.com/questions/5050574/decimal-field-in-django-admin-form#comment79560756_5050585 . Because of how Django compares values when rendering a select (it converts to a string), D('12.5') is going to be considered different from D('12.50') - and your model field is defined to store 2 decimal places.

Hope this helps,

Samir


John Boyd

unread,
Mar 17, 2021, 7:46:11 AMMar 17
to django-oscar
solarissmoke,

I am hiding at the back of the class in shame.

You are absolutely correct. I just added the extra digits and it works perfectly now.
I had actually read that comment as you originally recommended but completely passed over it.

Thanks very much for your help and patience.

Best Regards,
John.

Updated working model:

working_model.png

Best Regards,
John.
Reply all
Reply to author
Forward
0 new messages