Пример #1
0
    def inventory_list(self):
        products = Product.find_by_vendor(self.request.ctx.user.vendor) if self.request.ctx.user and self.request.ctx.user.is_vendor_user() else Product.find_all(self.enterprise_id) #pylint: disable-msg=E1120

        campaigns = Campaign.find_all(self.enterprise_id)

        response = {
            'page': 1,
            'total': 1,
            'records': len(products)}

        rows = []

        for prod in products:
            #log.debug('%s %s/%s' % (p.product_id, i+1, len(products)))
            # blank spot at the beginning of the row is to make room for the
            # action buttons.  don't remove it.
            cells = ['', unicode(prod.product_id),
                     util.nvl(prod.name),
                     util.nvl(prod.sku),
                     util.nvl(prod.manufacturer),
                     util.nvl(unicode(prod.inventory)),
                     util.nvl(unicode(prod.inventory_par)),
                     util.nvl(unicode(prod.unit_cost))]
            # the column ordering in the UI is dependant on the order of the
            # campaigns that comes back from Campaign.find_all().  We use the
            # same ordering here so we are fine not adding some campaign ID here.
            for camp in campaigns:
                cells.append(util.nvl(util.money(prod.get_retail_price(camp))))

            rows.append({'id': str(prod.product_id),
                         'cell': cells})

        response['rows'] = rows
        return json.dumps(response)
Пример #2
0
 def list(self):
     return {'products' : Product.find_by_vendor(self.enterprise_id,
                                                 self.request.ctx.user.vendor) \
                 if self.request.ctx.user.is_vendor_user() \
                 else Product.find_all(self.enterprise_id)}
Пример #3
0
 def show_inventory(self):
     return {'products' : Product.find_by_vendor(self.enterprise_id, self.request.ctx.user.vendor) \
                 if self.request.ctx.user.is_vendor_user() else Product.find_inventory_tracked(self.enterprise_id),
             'campaigns' : Campaign.find_all(self.enterprise_id)
             }