当前位置: 首页>>代码示例>>Python>>正文


Python Product.get方法代码示例

本文整理汇总了Python中models.Product.get方法的典型用法代码示例。如果您正苦于以下问题:Python Product.get方法的具体用法?Python Product.get怎么用?Python Product.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Product的用法示例。


在下文中一共展示了Product.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_data_for

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
 def set_data_for(self, value=None):
     products = [(Product.get(id=rpt.product_id).name) for rpt in
                 Report.select(fn.Distinct(Report.product))]
     if value:
         products = [(prod.name) for prod in Product.select().where(Product.name.contains(value))
                     .where(Product.name << products).order_by(Product.name.desc())]
     self.data = [(prd, "") for prd in products]
开发者ID:Ciwara,项目名称:GCiss,代码行数:9,代码来源:invoice.py

示例2: save_report

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def save_report(self):
        ''' add operation '''
        # entete de la facture
        self.table_out.changed_value()
        if not self.table_out.isvalid:
            return False
        date_out = str(self.date_out.text())
        datetime_ = date_to_datetime(date_out)
        self.current_store = self.liste_store[self.box_store.currentIndex()]

        values_t = self.table_out.get_table_items()

        for qty, name in values_t:
            rep = Reports(type_=Reports.S, store=self.current_store,
                          date=datetime_, product=Product.get(name=name),
                          qty_use=int(qty))
            try:
                rep.save()
            except:
                self.parent.Notify(
                    u"Ce mouvement n'a pas pu être enrgistré dans les raports", "error")
                return False

        self.parent.change_context(GReportViewWidget)
        self.parent.Notify(u"La sortie des articles avec succès", "success")
开发者ID:fadiga,项目名称:mstock,代码行数:27,代码来源:stock_output.py

示例3: details

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
def details(request, id):
    p = Product.get(id)
    if not p:
        raise Http404("Product cannot be found")
    return render_to_response('store/details.html', 
                              { 'p': p },
                              RequestContext(request))
开发者ID:nicocrm,项目名称:Sailfish.Web,代码行数:9,代码来源:views.py

示例4: changed_value

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def changed_value(self, refresh=False):
        """ Calcule les Resultat """
        self.mtt_ht = 0
        # self.button.setEnabled(False)
        for row_num in xrange(0, self.data.__len__()):
            product = Product.get(
                Product.name == unicode(self.item(row_num, 0).text()))
            last_report = product.last_report
            last_price = product.last_price()
            qtremaining = last_report.remaining
            selling_price = last_price
            invoice_date = unicode(self.parent.invoice_date.text())

            qtsaisi = is_int(self.cellWidget(row_num, 1).text())
            pusaisi = is_int(self.cellWidget(row_num, 2).text())

            if check_is_empty(self.parent.num_invoice):
                return
            if check_is_empty(self.parent.name_client_field.lineEdit()):
                return
            # if check_field(self.parent.invoice_date,
            #                "Le {} est Inférieure à la date de la dernière rapport (<b>{}</b>)".format(date_to_datetime(invoice_date), last_report.date), (last_report.date > date_to_datetime(invoice_date))):
            #     return
            if (pusaisi and check_is_empty(self.cellWidget(row_num, 1))):
                return
            if (pusaisi and check_is_empty(self.cellWidget(row_num, 2))):
                return
            if check_field(self.cellWidget(row_num, 1),
                           u"<b>{}</b> est supérieur à la quantité restante (<b>{}</b>)".format(
                    qtsaisi, qtremaining), qtremaining < qtsaisi):
                return
            if check_field(self.cellWidget(row_num, 2),
                           u"<b>{}</b> est inférieure au prix minimum de vente<b> {} CFA</b>".format(
                    pusaisi, selling_price), pusaisi < selling_price):
                print("E")
                # return

            montant = (qtsaisi * pusaisi)
            self.mtt_ht += montant
            self.setItem(row_num, 3, TotalsWidget(formatted_number(montant)))
            self._update_data(row_num, [qtsaisi, pusaisi, self.mtt_ht])
        self.setItem(
            row_num + 1, 3, TotalsWidget(formatted_number(self.mtt_ht)))
        typ = self.parent.liste_type_invoice[
            self.parent.box_type_inv.currentIndex()]
        self.paid_amount_field.setText(
            str(self.mtt_ht) if typ == Invoice.TYPE_BON else "0")
        self.button.setEnabled(True)
开发者ID:Ciwara,项目名称:GCiss,代码行数:50,代码来源:invoice.py

示例5: edit

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
def edit(request, id):
    u = auth.get_current_user(request)
    if u.is_admin:
        p = Product.get(id)
        if not p:
            raise Http404("Product cannot be found") 
        elif request.method == "POST":
            form = ProductForm(data=request.POST, instance=p)            
            if form.is_valid():
                form.save()
        else:
            form = ProductForm(instance=p)
            return render_to_response('store/edit.html', 
                                      { 'form': form },
                                      RequestContext(request))
    return HttpResponseRedirect(reverse('store-index'))    
开发者ID:nicocrm,项目名称:Sailfish.Web,代码行数:18,代码来源:views.py

示例6: save_b

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
 def save_b(self):
     ''' add operation '''
     # entete de la facture
     if not self.table_buy.isvalid:
         return False
     owner = Owner.get(Owner.islog == True)
     date = str(self.date.text())
     values_t = self.table_buy.get_table_items()
     buy = Buy()
     # buy.date = datetime_
     buy.provd_or_clt = \
         ProviderOrClient.get_or_create(
             "Fournisseur", 000000, ProviderOrClient.FSEUR)
     buy.owner = owner
     try:
         buy.save()
         err = False
     except:
         raise
         raise_error(
             "Erreur", u"Impossible d'enregistrer l'entête de la facture")
         return False
     for name, qty, cost_buying, selling_price in values_t:
         rep = Report()
         rep.buy = buy
         rep.type_ = Report.E
         rep.store = 1
         rep.date = date_to_datetime(date)
         rep.product = Product.get(name=name)
         rep.qty = int(qty)
         rep.cost_buying = int(cost_buying)
         rep.selling_price = int(selling_price)
         try:
             rep.save()
         except Exception as e:
             print(e)
             err = True
     if err:
         buy.delete_instance()
         raise_error("Erreur", u"Ce mouvement n'a pas pu etre "
                     u"enregistré dans les rapports")
         return False
     else:
         self.parent.Notify(u"L'entrée des articles avec succès", "success")
     self.change_main_context(BuyShowViewWidget, buy=buy)
开发者ID:Ciwara,项目名称:GCiss,代码行数:47,代码来源:buy.py

示例7: refresh_

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def refresh_(self, idd):

        self.prod = Product.get(id=idd)
        rest_by_store = ""

        for store in Store.select():
            remaining, nbr_parts = store.get_remaining_and_nb_parts(self.prod)

            if remaining < 10:
                color_style = 'color: DarkGreen'
            if remaining <= 5:
                color_style = 'color: LightCoral'
            if remaining <= 2:
                color_style = 'color: red; text-decoration: blink'
            if remaining >= 10:
                color_style = 'color: LimeGreen;'
            color_style = color_style + \
                "; border:3px solid green; font-size: 15px"
            if Store.select().count() == 1:
                rest_by_store += """ <p><strong style='{color_style}'> {remaining} </strong><i>pièces</i></p>
                """.format(color_style=color_style, remaining=remaining)
            else:
                rest_by_store += """<li> {store}: <strong style='{color_style}'>
                    {nbr_parts} </strong><i>pièces</i> <b>{remaining} </b><i>carton</i>
                    </li>""".format(store=store.name, color_style=color_style, remaining=remaining,
                                    nbr_parts=nbr_parts * remaining)
        width = height = 50
        if self.prod.image_link:
            self.image_btt.setText("Zoom")
            width = 200
            height = 100

        self.info_box.setText(u"""<h2>{name}</h2>
            <h4>Quantité restante:</h4>
            <ul>{remaining}</ul>
            """.format(name=self.prod.name,
                       remaining=rest_by_store))
        self.image.setText("""<img src="{image}" width='{width}'
            height='{height}'>""".format(image=self.prod.image_link,
                                         width=width, height=height))
开发者ID:Ciwara,项目名称:gcommon,代码行数:42,代码来源:_product_detail.py

示例8: refresh_

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def refresh_(self, idd):

        self.prod = Product.get(id=idd)
        self.nameLabel.setText((u"<h4>Article:</h4>"))
        self.name.setText(u"<h6>{name}</h6>".format(name=self.prod.name.title()))
        rest_by_store = ""

        for store in Store.select():
            remaining, nbr_parts = store.get_remaining_and_nb_parts(self.prod)

            if remaining < 10:
                color_style = 'color: DarkGreen'
            if remaining <= 5:
                color_style = 'color: LightCoral'
            if remaining <= 2:
                color_style = 'color: red; text-decoration: blink'
            if remaining >= 10:
                color_style = 'color: LimeGreen;'
            color_style = color_style + "; border:3px solid green; font-size: 15px"

            rest_by_store += u"<div> {store}: <strong style='{color_style}'>" \
                             u" {remaining} </strong> ({nbr_parts} pièces)"\
                             u"</div>".format(store=store.name,
                                              color_style=color_style,
                                              remaining=remaining,
                                              nbr_parts=nbr_parts)

        self.store.setText(u"<h4><u>Quantité restante</u>:</h4> \
                           {remaining}</ul>".format(remaining=rest_by_store))

        self.imagelabel.setText(u"<b>Pas d'image<b>")
        self.image.setStyleSheet("")
        if self.prod.image_link:
            self.imagelabel.setText(u"<b><u>Image</u></b>")
            self.image.setStyleSheet("background: url({image})"
                                     " no-repeat scroll 20px 110px #CCCCCC;"
                                     "width: 55px".format(image=self.prod.image_link))
开发者ID:fadiga,项目名称:mstock,代码行数:39,代码来源:invoice_view.py

示例9: save_b

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def save_b(self):
        ''' add operation '''
        # entete de la facture
        print("save")
        if not self.is_valide():
            return
        invoice_date = unicode(self.invoice_date.text())
        num_invoice = int(self.num_invoice.text())
        invoice_type = self.liste_type_invoice[
            self.box_type_inv.currentIndex()]
        lis_error = []
        invoice = Invoice()
        try:
            self.owner = Owner.get(Owner.islog == True)
        except:
            lis_error.append("Aucun utilisateur est connecté <br/>")
        paid_amount = int(self.table_invoice.paid_amount_field.text())
        try:
            clt = ProviderOrClient.get_or_create(
                self.name_client, int(self.phone.replace(" ", "")), ProviderOrClient.CLT)
        except ValueError:
            field_error(
                self.name_client_field, "Nom, numéro de téléphone du client")
        invoice.number = num_invoice
        invoice.owner = self.owner
        invoice.client = clt
        invoice.location = "Bamako"
        invoice.type_ = invoice_type
        invoice.subject = ""
        invoice.paid_amount = paid_amount
        invoice.tax = False
        try:
            invoice.save()
            if int(paid_amount) != 0 or invoice_type == Invoice.TYPE_BON:
                Refund(type_=Refund.DT, owner=self.owner, amount=paid_amount,
                       date=date_to_datetime(invoice_date), provider_client=clt,
                       invoice=Invoice.get(number=num_invoice)).save()
        except Exception as e:
            invoice.deletes_data()
            lis_error.append(
                "Erreur sur l'enregistrement d'entête de facture<br/>")
            return False
        # Save invoiceitems
        invoice = Invoice.get(Invoice.number == num_invoice)
        for name, qty, price in self.table_invoice.get_table_items():
            rep = Report()
            product = Product.get(Product.name == name)
            rep.store = 1
            rep.product = product
            rep.invoice = invoice
            rep.type_ = Report.S
            rep.cost_buying = int(product.last_report.cost_buying)
            rep.date = date_to_datetime(invoice_date)
            rep.qty = int(qty)
            rep.selling_price = int(price)
            try:
                rep.save()
            except Exception as e:
                lis_error.append(e)
        if lis_error != []:
            invoice.delete_instance()
            self.parent.Notify(lis_error, "error")
            return False
        else:
            self.parent.Notify("Facture Enregistrée avec succès", "success")

            self.change_main_context(ShowInvoiceViewWidget,
                                     invoice_num=invoice.number)
开发者ID:Ciwara,项目名称:GCiss,代码行数:70,代码来源:invoice.py

示例10: set_data_for

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
    def set_data_for(self, main_date):

        reports = []
        self.totals = 0
        self.total_sum_d1 = 0
        self.total_sum_d2 = 0
        self.total_sum_d3 = 0
        self.total_sum_d4 = 0
        self.total_sum_d5 = 0
        self.total_sum_d6 = 0
        try:
            self.date_on, self.date_end = main_date.current.current
        except Exception as e:
            self.date_on, self.date_end = main_date.current
        products = [(Product.get(id=rpt.product_id).name) for rpt in
                    Report.select(fn.Distinct(Report.product)).where(
            Report.date >= self.date_on, Report.date <= self.date_end,
            Report.type_ == Report.S)]

        products = [(prod.name) for prod in Product.select().where(
            Product.name << products).order_by(Product.name.desc())]
        for prod_name in products:
            on = date_on_or_end(self.date_on)
            end = date_on_or_end(self.date_end, on=False)
            dict_store = {}
            repts = Report.select().where(Report.type_ == Report.S,
                                          Report.product == Product.get(
                                              name=prod_name))
            dict_store["product"] = prod_name

            dict_store["sum_week"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0

            self.totals += (dict_store["sum_week"])
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d1"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d1 += dict_store["sum_d1"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d2"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d2 += dict_store["sum_d2"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d3"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d3 += dict_store["sum_d3"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d4"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d4 += dict_store["sum_d4"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d5"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d5 += dict_store["sum_d5"]
            on += timedelta(1)
            end = on + timedelta(days=1, seconds=-1)
            dict_store["sum_d6"] = repts.select(
                peewee.fn.SUM(Report.qty)).where(Report.date >= on,
                                                 Report.date <= end).scalar() or 0
            self.total_sum_d6 += dict_store["sum_d6"]
            reports.append(dict_store)

        self.data = [(rep.get('product'), rep.get('sum_d1'),
                      rep.get('sum_d2'), rep.get('sum_d3'), rep.get('sum_d4'),
                      rep.get('sum_d5'), rep.get('sum_d6'),
                      rep.get('sum_week'), "") for rep in reports]
开发者ID:Ciwara,项目名称:GCiss,代码行数:78,代码来源:stats.py

示例11: purchase

# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import get [as 别名]
def purchase(request, id):
    return purchase_do(request, Product.get(id))
开发者ID:nicocrm,项目名称:Sailfish.Web,代码行数:4,代码来源:views.py


注:本文中的models.Product.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。