Refactor purchase views per master4
This commit is contained in:
parent
7cee515187
commit
533b491124
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -28,12 +28,10 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
from rattail.db import model
|
||||
|
||||
import formalchemy as fa
|
||||
from webhelpers2.html import HTML, tags
|
||||
|
||||
from tailbone import forms
|
||||
from tailbone.db import Session
|
||||
from tailbone.views import MasterView3 as MasterView
|
||||
from tailbone.views import MasterView4 as MasterView
|
||||
|
||||
|
||||
class PurchaseView(MasterView):
|
||||
|
@ -77,6 +75,13 @@ class PurchaseView(MasterView):
|
|||
'batches',
|
||||
]
|
||||
|
||||
row_labels = {
|
||||
'vendor_code': "Vendor Item Code",
|
||||
'upc': "UPC",
|
||||
'po_unit_cost': "PO Unit Cost",
|
||||
'po_total': "PO Total",
|
||||
}
|
||||
|
||||
row_grid_columns = [
|
||||
'sequence',
|
||||
'upc',
|
||||
|
@ -92,6 +97,27 @@ class PurchaseView(MasterView):
|
|||
'invoice_total',
|
||||
]
|
||||
|
||||
row_form_fields = [
|
||||
'sequence',
|
||||
'vendor_code',
|
||||
'upc',
|
||||
'product',
|
||||
'department',
|
||||
'case_quantity',
|
||||
'cases_ordered',
|
||||
'units_ordered',
|
||||
'cases_received',
|
||||
'units_received',
|
||||
'cases_damaged',
|
||||
'units_damaged',
|
||||
'cases_expired',
|
||||
'units_expired',
|
||||
'po_unit_cost',
|
||||
'po_total',
|
||||
'invoice_unit_cost',
|
||||
'invoice_total',
|
||||
]
|
||||
|
||||
def get_instance_title(self, purchase):
|
||||
if purchase.status >= self.enum.PURCHASE_STATUS_COSTED:
|
||||
if purchase.invoice_date:
|
||||
|
@ -268,38 +294,20 @@ class PurchaseView(MasterView):
|
|||
self.enum.PURCHASE_STATUS_COSTED):
|
||||
g.hide_column('po_total')
|
||||
|
||||
def _preconfigure_row_fieldset(self, fs):
|
||||
fs.vendor_code.set(label="Vendor Item Code")
|
||||
fs.upc.set(label="UPC")
|
||||
fs.po_unit_cost.set(label="PO Unit Cost", renderer=forms.renderers.CurrencyFieldRenderer)
|
||||
fs.po_total.set(label="PO Total", renderer=forms.renderers.CurrencyFieldRenderer)
|
||||
fs.invoice_unit_cost.set(renderer=forms.renderers.CurrencyFieldRenderer)
|
||||
fs.invoice_total.set(renderer=forms.renderers.CurrencyFieldRenderer)
|
||||
fs.append(fa.Field('department', value=lambda i: '{} {}'.format(i.department_number, i.department_name)))
|
||||
def configure_row_form(self, f):
|
||||
super(PurchaseView, self).configure_row_form(f)
|
||||
|
||||
def configure_row_fieldset(self, fs):
|
||||
# currency fields
|
||||
f.set_type('po_unit_cost', 'currency')
|
||||
f.set_type('po_total', 'currency')
|
||||
f.set_type('invoice_unit_cost', 'currency')
|
||||
f.set_type('invoice_total', 'currency')
|
||||
|
||||
fs.configure(
|
||||
include=[
|
||||
fs.sequence,
|
||||
fs.vendor_code,
|
||||
fs.upc,
|
||||
fs.product,
|
||||
fs.department,
|
||||
fs.case_quantity,
|
||||
fs.cases_ordered,
|
||||
fs.units_ordered,
|
||||
fs.cases_received,
|
||||
fs.units_received,
|
||||
fs.cases_damaged,
|
||||
fs.units_damaged,
|
||||
fs.cases_expired,
|
||||
fs.units_expired,
|
||||
fs.po_unit_cost,
|
||||
fs.po_total,
|
||||
fs.invoice_unit_cost,
|
||||
fs.invoice_total,
|
||||
])
|
||||
# department
|
||||
f.set_renderer('department', self.render_row_department)
|
||||
|
||||
def render_row_department(self, row, field):
|
||||
return "{} {}".format(row.department_number, row.department_name)
|
||||
|
||||
def receiving_worksheet(self):
|
||||
purchase = self.get_instance()
|
||||
|
|
Loading…
Reference in a new issue