Initial support for mobile ordering
plus various other changes required for that
This commit is contained in:
		
							parent
							
								
									5afa832684
								
							
						
					
					
						commit
						65c63dad3e
					
				
					 12 changed files with 289 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -51,6 +51,9 @@ class OrderingBatchView(PurchasingBatchView):
 | 
			
		|||
    model_title = "Ordering Batch"
 | 
			
		||||
    model_title_plural = "Ordering Batches"
 | 
			
		||||
    index_title = "Ordering"
 | 
			
		||||
    mobile_creatable = True
 | 
			
		||||
    rows_editable = True
 | 
			
		||||
    mobile_rows_editable = True
 | 
			
		||||
 | 
			
		||||
    row_grid_columns = [
 | 
			
		||||
        'sequence',
 | 
			
		||||
| 
						 | 
				
			
			@ -241,6 +244,69 @@ class OrderingBatchView(PurchasingBatchView):
 | 
			
		|||
            'batch_po_total': '${:0,.2f}'.format(batch.po_total or 0),
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    def render_mobile_listitem(self, batch, i):
 | 
			
		||||
        return "({}) {} on {} for ${:0,.2f}".format(batch.id_str, batch.vendor,
 | 
			
		||||
                                                    batch.date_ordered, batch.po_total)
 | 
			
		||||
 | 
			
		||||
    def mobile_create(self):
 | 
			
		||||
        """
 | 
			
		||||
        Mobile view for creating a new ordering batch
 | 
			
		||||
        """
 | 
			
		||||
        mode = self.batch_mode
 | 
			
		||||
        data = {'mode': mode}
 | 
			
		||||
 | 
			
		||||
        vendor = None
 | 
			
		||||
        if self.request.method == 'POST' and self.request.POST.get('vendor'):
 | 
			
		||||
            vendor = self.Session.query(model.Vendor).get(self.request.POST['vendor'])
 | 
			
		||||
            if vendor:
 | 
			
		||||
 | 
			
		||||
                # fetch first to avoid flush below
 | 
			
		||||
                store = self.rattail_config.get_store(self.Session())
 | 
			
		||||
 | 
			
		||||
                batch = self.model_class()
 | 
			
		||||
                batch.mode = mode
 | 
			
		||||
                batch.vendor = vendor
 | 
			
		||||
                batch.store = store
 | 
			
		||||
                batch.buyer = self.request.user.employee
 | 
			
		||||
                batch.date_ordered = localtime(self.rattail_config).date()
 | 
			
		||||
                batch.created_by = self.request.user
 | 
			
		||||
                batch.po_total = 0
 | 
			
		||||
                kwargs = self.get_batch_kwargs(batch, mobile=True)
 | 
			
		||||
                batch = self.handler.make_batch(self.Session(), **kwargs)
 | 
			
		||||
                if self.handler.should_populate(batch):
 | 
			
		||||
                    self.handler.populate(batch)
 | 
			
		||||
                return self.redirect(self.request.route_url('mobile.ordering.view', uuid=batch.uuid))
 | 
			
		||||
 | 
			
		||||
        data['index_title'] = self.get_index_title()
 | 
			
		||||
        data['index_url'] = self.get_index_url(mobile=True)
 | 
			
		||||
        data['mode_title'] = self.enum.PURCHASE_BATCH_MODE[mode].capitalize()
 | 
			
		||||
        return self.render_to_response('create', data, mobile=True)
 | 
			
		||||
 | 
			
		||||
    def preconfigure_mobile_fieldset(self, fs):
 | 
			
		||||
        super(OrderingBatchView, self).preconfigure_mobile_fieldset(fs)
 | 
			
		||||
        fs.vendor.set(attrs={'hyperlink': False})
 | 
			
		||||
 | 
			
		||||
    def configure_mobile_fieldset(self, fs):
 | 
			
		||||
        fields = [
 | 
			
		||||
            fs.vendor,
 | 
			
		||||
            fs.department,
 | 
			
		||||
            fs.date_ordered,
 | 
			
		||||
            fs.po_number,
 | 
			
		||||
            fs.po_total,
 | 
			
		||||
            fs.created,
 | 
			
		||||
            fs.created_by,
 | 
			
		||||
            fs.notes,
 | 
			
		||||
            fs.status_code,
 | 
			
		||||
            fs.complete,
 | 
			
		||||
        ]
 | 
			
		||||
        batch = fs.model
 | 
			
		||||
        if (self.viewing or self.deleting) and batch.executed:
 | 
			
		||||
            fields.extend([
 | 
			
		||||
                fs.executed,
 | 
			
		||||
                fs.executed_by,
 | 
			
		||||
            ])
 | 
			
		||||
        fs.configure(include=fields)
 | 
			
		||||
 | 
			
		||||
    def download_excel(self):
 | 
			
		||||
        """
 | 
			
		||||
        Download ordering batch as Excel spreadsheet.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue