Allow "arbitrary" PO attachment to purchase batch
for sake of other POS integration etc.
This commit is contained in:
parent
08a75f6e9f
commit
1be26b7f33
4 changed files with 74 additions and 111 deletions
|
@ -87,8 +87,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
default_uom_is_case = True
|
||||
|
||||
purchase_order_fieldname = 'purchase'
|
||||
|
||||
labels = {
|
||||
'truck_dump_batch': "Truck Dump Parent",
|
||||
'invoice_parser_key': "Invoice Parser",
|
||||
|
@ -390,7 +388,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
return title
|
||||
|
||||
def configure_form(self, f):
|
||||
super(ReceivingBatchView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
model = self.model
|
||||
batch = f.model_instance
|
||||
allow_truck_dump = self.batch_handler.allow_truck_dump_receiving()
|
||||
|
@ -498,18 +496,28 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
f.set_widget('store_uuid', dfwidget.HiddenWidget())
|
||||
|
||||
# purchase
|
||||
if (self.creating and workflow in ('from_po', 'from_po_with_invoice')
|
||||
and self.purchase_order_fieldname == 'purchase'):
|
||||
f.replace('purchase', 'purchase_uuid')
|
||||
field = self.batch_handler.get_purchase_order_fieldname()
|
||||
if field == 'purchase':
|
||||
field = 'purchase_uuid'
|
||||
# TODO: workflow "invoice_with_po" is for costing mode, should rename?
|
||||
if self.creating and workflow in (
|
||||
'from_po', 'from_po_with_invoice', 'invoice_with_po'):
|
||||
f.replace('purchase', field)
|
||||
purchases = self.batch_handler.get_eligible_purchases(
|
||||
vendor, self.enum.PURCHASE_BATCH_MODE_RECEIVING)
|
||||
values = [(p.uuid, self.batch_handler.render_eligible_purchase(p))
|
||||
vendor, self.batch_mode)
|
||||
values = [(self.batch_handler.get_eligible_purchase_key(p),
|
||||
self.batch_handler.render_eligible_purchase(p))
|
||||
for p in purchases]
|
||||
f.set_widget('purchase_uuid', dfwidget.SelectWidget(values=values))
|
||||
f.set_label('purchase_uuid', "Purchase Order")
|
||||
f.set_required('purchase_uuid')
|
||||
elif self.creating or not batch.purchase:
|
||||
f.set_widget(field, dfwidget.SelectWidget(values=values))
|
||||
if field == 'purchase_uuid':
|
||||
f.set_label(field, "Purchase Order")
|
||||
f.set_required(field)
|
||||
elif self.creating:
|
||||
f.remove_field('purchase')
|
||||
else: # not creating
|
||||
if field != 'purchase_uuid':
|
||||
f.replace('purchase', field)
|
||||
f.set_renderer(field, self.render_purchase)
|
||||
|
||||
# department
|
||||
if self.creating:
|
||||
|
@ -939,8 +947,9 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
Assign the original purchase order to the given batch. Default
|
||||
behavior assumes a Rattail Purchase object is what we're after.
|
||||
"""
|
||||
field = self.batch_handler.get_purchase_order_fieldname()
|
||||
purchase = self.handler.assign_purchase_order(
|
||||
batch, po_form.validated[self.purchase_order_fieldname],
|
||||
batch, po_form.validated[field],
|
||||
session=self.Session())
|
||||
|
||||
department = self.department_for_purchase(purchase)
|
||||
|
@ -1992,7 +2001,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._receiving_defaults(config)
|
||||
cls._purchasing_defaults(config)
|
||||
cls._batch_defaults(config)
|
||||
cls._defaults(config)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue