Initial (basic) views for invoice costing batches
still a bit of feature preview at the moment, but maybe is mostly done?
This commit is contained in:
parent
ed705ff867
commit
bbfffd45fc
4 changed files with 393 additions and 39 deletions
|
@ -38,7 +38,6 @@ from rattail import pod
|
|||
from rattail.db import model, Session as RattailSession
|
||||
from rattail.time import localtime, make_utc
|
||||
from rattail.util import pretty_quantity, prettify, OrderedDict, simple_error
|
||||
from rattail.vendors.invoices import iter_invoice_parsers, require_invoice_parser
|
||||
from rattail.threads import Thread
|
||||
|
||||
import colander
|
||||
|
@ -210,6 +209,10 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
form details for creating a batch will depend on which "type" of batch
|
||||
creation is to be done, and it's much easier to keep conditional logic
|
||||
for that in the server instead of client-side etc.
|
||||
|
||||
See also
|
||||
:meth:`tailbone.views.purchasing.costing:CostingBatchView.create()`
|
||||
which uses similar logic.
|
||||
"""
|
||||
route_prefix = self.get_route_prefix()
|
||||
workflows = self.handler.supported_receiving_workflows()
|
||||
|
@ -440,25 +443,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
'truck_dump_status',
|
||||
'truck_dump_batch')
|
||||
|
||||
# invoice_file
|
||||
if self.creating:
|
||||
f.set_type('invoice_file', 'file', required=False)
|
||||
else:
|
||||
f.set_readonly('invoice_file')
|
||||
f.set_renderer('invoice_file', self.render_downloadable_file)
|
||||
|
||||
# invoice_parser_key
|
||||
if self.creating:
|
||||
parsers = sorted(iter_invoice_parsers(), key=lambda p: p.display)
|
||||
parser_values = [(p.key, p.display) for p in parsers]
|
||||
parser_values.insert(0, ('', "(please choose)"))
|
||||
if use_buefy:
|
||||
f.set_widget('invoice_parser_key', dfwidget.SelectWidget(values=parser_values))
|
||||
else:
|
||||
f.set_widget('invoice_parser_key', forms.widgets.JQuerySelectWidget(values=parser_values))
|
||||
else:
|
||||
f.remove_field('invoice_parser_key')
|
||||
|
||||
# store
|
||||
if self.creating:
|
||||
store = self.rattail_config.get_store(self.Session())
|
||||
|
@ -737,22 +721,11 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
def configure_row_grid(self, g):
|
||||
super(ReceivingBatchView, self).configure_row_grid(g)
|
||||
g.set_label('department_name', "Department")
|
||||
|
||||
# vendor_code
|
||||
g.filters['vendor_code'].default_active = True
|
||||
g.filters['vendor_code'].default_verb = 'contains'
|
||||
|
||||
# catalog_unit_cost
|
||||
g.set_renderer('catalog_unit_cost', self.render_row_grid_cost)
|
||||
g.set_label('catalog_unit_cost', "Catalog Cost")
|
||||
g.filters['catalog_unit_cost'].label = "Catalog Unit Cost"
|
||||
|
||||
# invoice_unit_cost
|
||||
g.set_renderer('invoice_unit_cost', self.render_row_grid_cost)
|
||||
g.set_label('invoice_unit_cost', "Invoice Cost")
|
||||
g.filters['invoice_unit_cost'].label = "Invoice Unit Cost"
|
||||
|
||||
# credits
|
||||
# note that sorting by credits involves a subquery with group by clause.
|
||||
# seems likely there may be a better way? but this seems to work fine
|
||||
|
@ -800,12 +773,6 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
|
||||
return css_class
|
||||
|
||||
def render_row_grid_cost(self, row, field):
|
||||
cost = getattr(row, field)
|
||||
if cost is None:
|
||||
return ""
|
||||
return "{:0,.3f}".format(cost)
|
||||
|
||||
def transform_unit_url(self, row, i):
|
||||
# grid action is shown only when we return a URL here
|
||||
if self.row_editable(row):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue