Add category, family, report code support for generic product batch
This commit is contained in:
parent
f8d26b4f8f
commit
798a9893e9
|
@ -75,6 +75,10 @@ class ProductBatchView(BatchMasterView):
|
||||||
'executed_by',
|
'executed_by',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
row_labels = {
|
||||||
|
'reportcode': "Report Code",
|
||||||
|
}
|
||||||
|
|
||||||
row_grid_columns = [
|
row_grid_columns = [
|
||||||
'sequence',
|
'sequence',
|
||||||
'upc',
|
'upc',
|
||||||
|
@ -104,6 +108,9 @@ class ProductBatchView(BatchMasterView):
|
||||||
'department',
|
'department',
|
||||||
'subdepartment_number',
|
'subdepartment_number',
|
||||||
'subdepartment',
|
'subdepartment',
|
||||||
|
'category',
|
||||||
|
'family',
|
||||||
|
'reportcode',
|
||||||
'vendor',
|
'vendor',
|
||||||
'vendor_item_code',
|
'vendor_item_code',
|
||||||
'regular_cost',
|
'regular_cost',
|
||||||
|
@ -161,6 +168,9 @@ class ProductBatchView(BatchMasterView):
|
||||||
f.set_renderer('vendor', self.render_vendor)
|
f.set_renderer('vendor', self.render_vendor)
|
||||||
f.set_renderer('department', self.render_department)
|
f.set_renderer('department', self.render_department)
|
||||||
f.set_renderer('subdepartment', self.render_subdepartment)
|
f.set_renderer('subdepartment', self.render_subdepartment)
|
||||||
|
f.set_renderer('category', self.render_category)
|
||||||
|
f.set_renderer('family', self.render_family)
|
||||||
|
f.set_renderer('reportcode', self.render_report)
|
||||||
|
|
||||||
def get_execute_success_url(self, batch, result, **kwargs):
|
def get_execute_success_url(self, batch, result, **kwargs):
|
||||||
if kwargs['action'] == 'make_label_batch':
|
if kwargs['action'] == 'make_label_batch':
|
||||||
|
@ -182,6 +192,30 @@ class ProductBatchView(BatchMasterView):
|
||||||
fields.append('vendor_abbreviation')
|
fields.append('vendor_abbreviation')
|
||||||
fields.append('vendor_name')
|
fields.append('vendor_name')
|
||||||
|
|
||||||
|
if 'category_uuid' in fields:
|
||||||
|
i = fields.index('category_uuid')
|
||||||
|
fields.insert(i + 1, 'category_code')
|
||||||
|
fields.insert(i + 2, 'category_name')
|
||||||
|
else:
|
||||||
|
fields.append('category_code')
|
||||||
|
fields.append('category_name')
|
||||||
|
|
||||||
|
if 'family_uuid' in fields:
|
||||||
|
i = fields.index('family_uuid')
|
||||||
|
fields.insert(i + 1, 'family_code')
|
||||||
|
fields.insert(i + 2, 'family_name')
|
||||||
|
else:
|
||||||
|
fields.append('family_code')
|
||||||
|
fields.append('family_name')
|
||||||
|
|
||||||
|
if 'reportcode_uuid' in fields:
|
||||||
|
i = fields.index('reportcode_uuid')
|
||||||
|
fields.insert(i + 1, 'report_code')
|
||||||
|
fields.insert(i + 2, 'report_name')
|
||||||
|
else:
|
||||||
|
fields.append('report_code')
|
||||||
|
fields.append('report_name')
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def supplement_row_data(self, row, fields, data):
|
def supplement_row_data(self, row, fields, data):
|
||||||
|
@ -193,6 +227,24 @@ class ProductBatchView(BatchMasterView):
|
||||||
if 'vendor_name' in fields:
|
if 'vendor_name' in fields:
|
||||||
data['vendor_name'] = (vendor.name or '') if vendor else ''
|
data['vendor_name'] = (vendor.name or '') if vendor else ''
|
||||||
|
|
||||||
|
category = row.category
|
||||||
|
if 'category_code' in fields:
|
||||||
|
data['category_code'] = (category.code or '') if category else ''
|
||||||
|
if 'category_name' in fields:
|
||||||
|
data['category_name'] = (category.name or '') if category else ''
|
||||||
|
|
||||||
|
family = row.family
|
||||||
|
if 'family_code' in fields:
|
||||||
|
data['family_code'] = (family.code or '') if family else ''
|
||||||
|
if 'family_name' in fields:
|
||||||
|
data['family_name'] = (family.name or '') if family else ''
|
||||||
|
|
||||||
|
report = row.reportcode
|
||||||
|
if 'report_code' in fields:
|
||||||
|
data['report_code'] = (report.code or '') if report else ''
|
||||||
|
if 'report_name' in fields:
|
||||||
|
data['report_name'] = (report.name or '') if report else ''
|
||||||
|
|
||||||
def get_row_csv_row(self, row, fields):
|
def get_row_csv_row(self, row, fields):
|
||||||
csvrow = super(ProductBatchView, self).get_row_csv_row(row, fields)
|
csvrow = super(ProductBatchView, self).get_row_csv_row(row, fields)
|
||||||
self.supplement_row_data(row, fields, csvrow)
|
self.supplement_row_data(row, fields, csvrow)
|
||||||
|
|
|
@ -826,6 +826,22 @@ class MasterView(View):
|
||||||
url = self.request.route_url('subdepartments.view', uuid=subdepartment.uuid)
|
url = self.request.route_url('subdepartments.view', uuid=subdepartment.uuid)
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
def render_category(self, obj, field):
|
||||||
|
category = getattr(obj, field)
|
||||||
|
if not category:
|
||||||
|
return ""
|
||||||
|
text = "({}) {}".format(category.code, category.name)
|
||||||
|
url = self.request.route_url('categories.view', uuid=category.uuid)
|
||||||
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
def render_family(self, obj, field):
|
||||||
|
family = getattr(obj, field)
|
||||||
|
if not family:
|
||||||
|
return ""
|
||||||
|
text = "({}) {}".format(family.code, family.name)
|
||||||
|
url = self.request.route_url('families.view', uuid=family.uuid)
|
||||||
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
def render_report(self, obj, field):
|
def render_report(self, obj, field):
|
||||||
report = getattr(obj, field)
|
report = getattr(obj, field)
|
||||||
if not report:
|
if not report:
|
||||||
|
|
Loading…
Reference in a new issue