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"> <section class="modal-card-body">
<p class="block"> <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. identifying the record below.
</p> </p>
<p class="block"> <p class="block">
The app will take care of updating any Customer Orders The app will take care of updating any Customer Orders
etc. as needed once you declare the match. etc. as needed once you declare the match.
</p> </p>
<b-field grouped> <b-field label="Pending Product">
<b-field label="Pending"> <span>${instance.full_description}</span>
<span>${instance.full_description}</span> </b-field>
</b-field> <b-field label="Actual Product" expanded>
<b-field label="Actual Product" expanded> <tailbone-autocomplete name="product_uuid"
<tailbone-autocomplete name="product_uuid" v-model="resolveProductUUID"
v-model="resolveProductUUID" ref="resolveProductAutocomplete"
ref="resolveProductAutocomplete" service-url="${url('products.autocomplete')}">
service-url="${url('products.autocomplete')}"> </tailbone-autocomplete>
</tailbone-autocomplete>
</b-field>
</b-field> </b-field>
</section> </section>

View file

@ -2229,6 +2229,7 @@ class PendingProductView(MasterView):
form_fields = [ form_fields = [
'_product_key_', '_product_key_',
'product',
'brand_name', 'brand_name',
'brand', 'brand',
'description', 'description',
@ -2237,14 +2238,34 @@ class PendingProductView(MasterView):
'department', 'department',
'vendor_name', 'vendor_name',
'vendor', 'vendor',
'vendor_item_code',
'unit_cost', 'unit_cost',
'case_size', 'case_size',
'regular_price_amount', 'regular_price_amount',
'special_order', 'special_order',
'notes', 'notes',
'status_code',
'created', 'created',
'user', '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): def configure_grid(self, g):
@ -2264,6 +2285,10 @@ class PendingProductView(MasterView):
model = self.model model = self.model
pending = f.model_instance pending = f.model_instance
# product
f.set_readonly('product') # TODO
f.set_renderer('product', self.render_product)
# department # department
if self.creating or self.editing: if self.creating or self.editing:
if 'department' in f: if 'department' in f:
@ -2342,13 +2367,6 @@ class PendingProductView(MasterView):
else: else:
f.set_readonly('created') 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 # status_code
if self.creating: if self.creating:
f.remove('status_code') f.remove('status_code')
@ -2356,7 +2374,23 @@ class PendingProductView(MasterView):
# f.set_readonly('status_code') # f.set_readonly('status_code')
f.set_enum('status_code', self.enum.PENDING_PRODUCT_STATUS) 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): def editable_instance(self, pending):
if self.request.is_root:
return True
if pending.status_code == self.enum.PENDING_PRODUCT_STATUS_RESOLVED: if pending.status_code == self.enum.PENDING_PRODUCT_STATUS_RESOLVED:
return False return False
return True return True
@ -2419,9 +2453,21 @@ class PendingProductView(MasterView):
app = self.get_rattail_app() app = self.get_rattail_app()
products_handler = app.get_products_handler() 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 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 @classmethod
def defaults(cls, config): def defaults(cls, config):
cls._defaults(config) cls._defaults(config)