Add support for editing invoice cost in receiving batch, per new theme

This commit is contained in:
Lance Edgar 2022-12-05 16:25:55 -06:00
parent 36a5f2ab49
commit cceb66e500
3 changed files with 85 additions and 16 deletions

View file

@ -724,6 +724,11 @@ class ReceivingBatchView(PurchasingBatchView):
and self.has_perm('edit_row')
and self.batch_handler.allow_receiving_edit_catalog_unit_cost())
def allow_edit_invoice_unit_cost(self, batch):
return (not batch.executed
and self.has_perm('edit_row')
and self.batch_handler.allow_receiving_edit_invoice_unit_cost())
def template_kwargs_view(self, **kwargs):
kwargs = super(ReceivingBatchView, self).template_kwargs_view(**kwargs)
batch = kwargs['instance']
@ -749,6 +754,7 @@ class ReceivingBatchView(PurchasingBatchView):
columns=['title', 'count'])
kwargs['allow_edit_catalog_unit_cost'] = self.allow_edit_catalog_unit_cost(batch)
kwargs['allow_edit_invoice_unit_cost'] = self.allow_edit_invoice_unit_cost(batch)
return kwargs
@ -960,6 +966,12 @@ class ReceivingBatchView(PurchasingBatchView):
g.set_click_handler('catalog_unit_cost',
'catalogUnitCostClicked(props.row)')
# invoice_unit_cost
if use_buefy and self.allow_edit_invoice_unit_cost(batch):
g.set_raw_renderer('invoice_unit_cost', self.render_invoice_unit_cost)
g.set_click_handler('invoice_unit_cost',
'invoiceUnitCostClicked(props.row)')
# nb. only show PO *or* invoice cost; prefer the latter unless
# we have a PO and no invoice
if (self.batch_handler.has_purchase_order(batch)
@ -1019,12 +1031,22 @@ class ReceivingBatchView(PurchasingBatchView):
def render_catalog_unit_cost(self):
return HTML.tag('receiving-cost-editor', **{
'field': 'catalog_unit_cost',
'v-model': 'props.row.catalog_unit_cost',
':ref': "'catalogUnitCost_' + props.row.uuid",
':row': 'props.row',
'@input': 'catalogCostConfirmed',
})
def render_invoice_unit_cost(self):
return HTML.tag('receiving-cost-editor', **{
'field': 'invoice_unit_cost',
'v-model': 'props.row.invoice_unit_cost',
':ref': "'invoiceUnitCost_' + props.row.uuid",
':row': 'props.row',
'@input': 'invoiceCostConfirmed',
})
def row_grid_extra_class(self, row, i):
css_class = super(ReceivingBatchView, self).row_grid_extra_class(row, i)
@ -1966,6 +1988,9 @@ class ReceivingBatchView(PurchasingBatchView):
{'section': 'rattail.batch',
'option': 'purchase.receiving.allow_edit_catalog_unit_cost',
'type': bool},
{'section': 'rattail.batch',
'option': 'purchase.receiving.allow_edit_invoice_unit_cost',
'type': bool},
# mobile interface
{'section': 'rattail.batch',