Show related customer orders for Pending Product view

and similar tweaks
This commit is contained in:
Lance Edgar 2023-09-10 07:45:25 -05:00
parent 64c58a3cf8
commit 48daa042d1
2 changed files with 65 additions and 21 deletions

View file

@ -53,24 +53,22 @@
<section class="modal-card-body">
<p class="block">
If this Product already exists, you can declare that by
If this product already exists, you can declare that by
identifying the record below.
</p>
<p class="block">
The app will take care of updating any Customer Orders
etc. as needed once you declare the match.
</p>
<b-field grouped>
<b-field label="Pending">
<span>${instance.full_description}</span>
</b-field>
<b-field label="Actual Product" expanded>
<tailbone-autocomplete name="product_uuid"
v-model="resolveProductUUID"
ref="resolveProductAutocomplete"
service-url="${url('products.autocomplete')}">
</tailbone-autocomplete>
</b-field>
<b-field label="Pending Product">
<span>${instance.full_description}</span>
</b-field>
<b-field label="Actual Product" expanded>
<tailbone-autocomplete name="product_uuid"
v-model="resolveProductUUID"
ref="resolveProductAutocomplete"
service-url="${url('products.autocomplete')}">
</tailbone-autocomplete>
</b-field>
</section>

View file

@ -2229,6 +2229,7 @@ class PendingProductView(MasterView):
form_fields = [
'_product_key_',
'product',
'brand_name',
'brand',
'description',
@ -2237,14 +2238,34 @@ class PendingProductView(MasterView):
'department',
'vendor_name',
'vendor',
'vendor_item_code',
'unit_cost',
'case_size',
'regular_price_amount',
'special_order',
'notes',
'status_code',
'created',
'user',
'status_code',
'resolved',
'resolved_by',
]
has_rows = True
model_row_class = model.CustomerOrderItem
rows_title = "Customer Orders"
# TODO: add support for this someday
rows_viewable = False
# TODO: this clearly needs help
row_grid_columns = [
# 'upc',
'brand_name',
'description',
'size',
'vendor_name',
# 'regular_price',
# 'current_price',
]
def configure_grid(self, g):
@ -2264,6 +2285,10 @@ class PendingProductView(MasterView):
model = self.model
pending = f.model_instance
# product
f.set_readonly('product') # TODO
f.set_renderer('product', self.render_product)
# department
if self.creating or self.editing:
if 'department' in f:
@ -2342,13 +2367,6 @@ class PendingProductView(MasterView):
else:
f.set_readonly('created')
# user
if self.creating:
f.remove('user')
else:
f.set_readonly('user')
f.set_renderer('user', self.render_user)
# status_code
if self.creating:
f.remove('status_code')
@ -2356,7 +2374,23 @@ class PendingProductView(MasterView):
# f.set_readonly('status_code')
f.set_enum('status_code', self.enum.PENDING_PRODUCT_STATUS)
# user
if self.creating:
f.remove('user')
else:
f.set_readonly('user')
f.set_renderer('user', self.render_user)
# resolved*
if self.creating:
f.remove('resolved', 'resolved_by')
else:
if not pending.resolved:
f.remove('resolved', 'resolved_by')
def editable_instance(self, pending):
if self.request.is_root:
return True
if pending.status_code == self.enum.PENDING_PRODUCT_STATUS_RESOLVED:
return False
return True
@ -2419,9 +2453,21 @@ class PendingProductView(MasterView):
app = self.get_rattail_app()
products_handler = app.get_products_handler()
products_handler.resolve_product(pending, product, self.request.user)
kwargs = self.get_resolve_product_kwargs()
products_handler.resolve_product(pending, product, self.request.user, **kwargs)
return redirect
def get_resolve_product_kwargs(self, **kwargs):
return kwargs
def get_row_data(self, pending):
model = self.model
return self.Session.query(model.CustomerOrderItem)\
.filter(model.CustomerOrderItem.pending_product == pending)
def get_parent(self, item):
return item.pending_product
@classmethod
def defaults(cls, config):
cls._defaults(config)