Add basic edit support for Purchases

This commit is contained in:
Lance Edgar 2022-07-24 21:10:52 -05:00
parent 0dc344b821
commit 36d4f0a5f7
2 changed files with 43 additions and 9 deletions

View file

@ -42,7 +42,6 @@ class PurchaseView(MasterView):
""" """
model_class = model.Purchase model_class = model.Purchase
creatable = False creatable = False
editable = False
has_rows = True has_rows = True
model_row_class = model.PurchaseItem model_row_class = model.PurchaseItem
@ -73,7 +72,6 @@ class PurchaseView(MasterView):
'status', 'status',
'buyer', 'buyer',
'date_ordered', 'date_ordered',
'date_received',
'po_number', 'po_number',
'po_total', 'po_total',
'ship_method', 'ship_method',
@ -81,6 +79,7 @@ class PurchaseView(MasterView):
'invoice_date', 'invoice_date',
'invoice_number', 'invoice_number',
'invoice_total', 'invoice_total',
'date_received',
'created', 'created',
'created_by', 'created_by',
'batches', 'batches',
@ -201,22 +200,57 @@ class PurchaseView(MasterView):
def configure_form(self, f): def configure_form(self, f):
super(PurchaseView, self).configure_form(f) super(PurchaseView, self).configure_form(f)
# id
f.set_renderer('id', self.render_id_str) f.set_renderer('id', self.render_id_str)
f.set_readonly('id')
f.set_renderer('store', self.render_store) f.set_renderer('store', self.render_store)
# vendor
f.set_renderer('vendor', self.render_vendor) f.set_renderer('vendor', self.render_vendor)
f.set_readonly('vendor')
# department
f.set_renderer('department', self.render_department) f.set_renderer('department', self.render_department)
# buyer
f.set_readonly('buyer')
# date_ordered
f.set_type('date_ordered', 'date_jquery')
# po_number
f.set_label('po_number', "PO Number")
# po_total
f.set_type('po_total', 'currency')
f.set_readonly('po_total')
f.set_label('po_total', "PO Total")
# notes_to_vendor
f.set_type('notes_to_vendor', 'text_wrapped')
# date_received
f.set_type('date_received', 'date_jquery')
# invoice_date
f.set_type('invoice_date', 'date_jquery')
# invoice_total
f.set_type('invoice_total', 'currency')
f.set_readonly('invoice_total')
# status
f.set_readonly('status') f.set_readonly('status')
f.set_enum('status', self.enum.PURCHASE_STATUS) f.set_enum('status', self.enum.PURCHASE_STATUS)
f.set_label('po_number', "PO Number") # batches
f.set_label('po_total', "PO Total")
f.set_type('po_total', 'currency')
f.set_type('invoice_total', 'currency')
f.set_renderer('batches', self.render_batches) f.set_renderer('batches', self.render_batches)
f.set_readonly('batches')
# created
f.set_readonly('created')
f.set_readonly('created_by')
if self.viewing: if self.viewing:
purchase = f.model_instance purchase = f.model_instance

View file

@ -539,7 +539,7 @@ class ReceivingBatchView(PurchasingBatchView):
f.set_widget('purchase_uuid', dfwidget.SelectWidget(values=values)) f.set_widget('purchase_uuid', dfwidget.SelectWidget(values=values))
f.set_label('purchase_uuid', "Purchase Order") f.set_label('purchase_uuid', "Purchase Order")
f.set_required('purchase_uuid') f.set_required('purchase_uuid')
else: elif self.creating or not batch.purchase:
f.remove_field('purchase') f.remove_field('purchase')
# department # department