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


Python Pool.today方法代码示例

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


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

示例1: search_quantity

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def search_quantity(cls, name, domain=None):
        Date = Pool().get('ir.date')

        if not (Transaction().context.get('locations') and domain):
            return []

        context = {}
        if (name == 'quantity'
                and Transaction().context.get('stock_date_end')
                and Transaction().context.get('stock_date_end') >
                Date.today()):
            context['stock_date_end'] = Date.today()

        if name == 'forecast_quantity':
            context['forecast'] = True
            if not Transaction().context.get('stock_date_end'):
                context['stock_date_end'] = datetime.date.max

        with Transaction().set_context(context):
            pbl = cls.products_by_location(
                    location_ids=Transaction().context['locations'],
                    with_childs=True, skip_zero=False).iteritems()

        processed_lines = []
        for (location, product), quantity in pbl:
            processed_lines.append({
                    'location': location,  # XXX useful ?
                    'product': product,
                    name: quantity,
                    })

        res = [line['product'] for line in processed_lines
            if cls._search_quantity_eval_domain(line, domain)]
        return [('id', 'in', res)]
开发者ID:silpol,项目名称:tryton-bef,代码行数:36,代码来源:product.py

示例2: on_change_with_available_qty

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def on_change_with_available_qty(self, name=None):
        """
        Returns the available quantity
        """
        Date = Pool().get('ir.date')

        if not (self.product and self.from_location):
            return

        if self.from_location.type != 'storage':
            return

        date = self.planned_date or Date.today()
        date = max(date, Date.today())

        location = self.from_location

        with Transaction().set_context(
                locations=[location.id], stock_date_end=date,
                stock_assign=True):

            if date <= Date.today():
                return self.product.quantity
            else:
                return self.product.forecast_quantity
开发者ID:prakashpp,项目名称:trytond-sale-available-stock,代码行数:27,代码来源:stock.py

示例3: get_quantity

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def get_quantity(cls, products, name):
        Date = Pool().get('ir.date')

        quantities = dict((p.id, 0.0) for p in products)
        if not Transaction().context.get('locations'):
            return quantities

        context = {}
        if (name == 'quantity'
                and Transaction().context.get('stock_date_end')
                and Transaction().context.get('stock_date_end') >
                Date.today()):
            context['stock_date_end'] = Date.today()

        if name == 'forecast_quantity':
            context['forecast'] = True
            if not Transaction().context.get('stock_date_end'):
                context['stock_date_end'] = datetime.date.max
        with Transaction().set_context(context):
            pbl = cls.products_by_location(
                location_ids=Transaction().context['locations'],
                product_ids=quantities.keys(), with_childs=True)

        for location in Transaction().context['locations']:
            for product in products:
                quantities[product.id] += pbl.get((location, product.id), 0.0)
        return quantities
开发者ID:silpol,项目名称:tryton-bef,代码行数:29,代码来源:product.py

示例4: check_update_date

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def check_update_date(self):
        """Check if the sale_date is same as today
        If not then update the sale_date with today's date
        """
        Date = Pool().get("ir.date")
        Sale = Pool().get("sale.sale")

        if self.sale and self.sale.sale_date and self.sale.sale_date < Date.today():
            Sale.write([self.sale], {"sale_date": Date.today()})
开发者ID:shalabhaggarwal,项目名称:nereid-cart-b2c,代码行数:11,代码来源:cart.py

示例5: get_supply_dates

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def get_supply_dates(cls, product):
        """
        Return the minimal interval of earliest supply dates for a product.
        """
        Date = Pool().get('ir.date')

        min_date = None
        max_date = None
        today = Date.today()

        for product_supplier in product.product_suppliers:
            supply_date = product_supplier.compute_supply_date(date=today)
            # TODO next_day is by default today + 1 but should depends
            # on the CRON activity
            next_day = today + datetime.timedelta(1)
            next_supply_date = product_supplier.compute_supply_date(
                date=next_day)
            if (not min_date) or supply_date < min_date:
                min_date = supply_date
            if (not max_date):
                max_date = next_supply_date
            if supply_date > min_date and supply_date < max_date:
                max_date = supply_date
            if next_supply_date < max_date:
                max_date = next_supply_date

        if not min_date:
            min_date = datetime.date.max
            max_date = datetime.date.max

        return (min_date, max_date)
开发者ID:kret0s,项目名称:tryton3_8,代码行数:33,代码来源:purchase_request.py

示例6: get_move

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def get_move(self, lines, party, account):
        Move = Pool().get('account.move')
        Line = Pool().get('account.move.line')
        Date = Pool().get('ir.date')

        total_debit = sum(line.debit for line in lines)
        total_credit = sum(line.credit for line in lines)
        payment_amount = total_credit - total_debit

        return Move(
            journal=self.start.journal,
            date=Date.today(),
            lines=[
                # Credit the journal
                Line(
                    account=self.start.journal.credit_account,
                    credit=payment_amount,
                ),
                # Debit the payable account
                Line(
                    account=account,
                    debit=payment_amount,
                    party=party,
                )
            ]
        )
开发者ID:openlabs,项目名称:trytond-check,代码行数:28,代码来源:check.py

示例7: crear_factura

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
def crear_factura(suscrip,cant,desc):
    date = Pool().get('ir.date')
    sale = Pool().get('sale.sale')
    producto = Pool().get('product.product')
    pay_term = Pool().get('account.invoice.payment_term')
    p = producto.search([('name','=','Diario Impreso')])[0]
    p_term = pay_term.search([('name','=','Cuenta Corriente')])[0]
    #calculo del invoice address
    invoice_address = suscrip.cliente.address_get(type='invoice')
    shipment_address = suscrip.cliente.address_get(type='delivery')
    nueva = sale.create([{
                'party':suscrip.cliente,
                'payment_term': p_term,
                'suscripcion':suscrip,
                'invoice_address' : invoice_address,
                'shipment_address' : shipment_address,
                'sale_date' :date.today(),
                }])[0]
    nueva.save()
    crear_linea_producto(nueva,p,cant,desc)
    nueva.state = 'processing'
    nueva.save()
    #crea factura
    nueva.create_invoice('out_invoice')
    nueva.create_invoice('out_credit_note')
    nueva.set_invoice_state()
    nueva.create_shipment('out')
    nueva.create_shipment('return')
    nueva.set_shipment_state()
开发者ID:it10,项目名称:tryton-dypra,代码行数:31,代码来源:suscripcion.py

示例8: get_rate

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def get_rate(currencies, name):
        '''
        Return the rate at the date from the context or the current date
        '''
        Rate = Pool().get('currency.currency.rate')
        Date = Pool().get('ir.date')

        res = {}
        date = Transaction().context.get('date', Date.today())
        for currency in currencies:
            rates = Rate.search([
                    ('currency', '=', currency.id),
                    ('date', '<=', date),
                    ], limit=1, order=[('date', 'DESC')])
            if rates:
                res[currency.id] = rates[0].id
            else:
                res[currency.id] = 0
        rate_ids = [x for x in res.values() if x]
        rates = Rate.browse(rate_ids)
        id2rate = {}
        for rate in rates:
            id2rate[rate.id] = rate
        for currency_id in res.keys():
            if res[currency_id]:
                res[currency_id] = id2rate[res[currency_id]].rate
        return res
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:29,代码来源:currency.py

示例9: convert

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
 def convert(cls, opportunities):
     Date = Pool().get('ir.date')
     cls.write(opportunities, {
             'end_date': Date.today(),
             })
     for opportunity in opportunities:
         opportunity.create_sale()
开发者ID:silpol,项目名称:tryton-bef,代码行数:9,代码来源:opportunity.py

示例10: compute

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def compute(cls, from_currency, amount, to_currency, round=True):
        '''
        Take a currency and an amount
        Return the amount to the new currency
        Use the rate of the date of the context or the current date
        '''
        Date = Pool().get('ir.date')
        Lang = Pool().get('ir.lang')
        from_currency = cls(from_currency.id)
        to_currency = cls(to_currency.id)

        if to_currency == from_currency:
            if round:
                return to_currency.round(amount)
            else:
                return amount
        if (not from_currency.rate) or (not to_currency.rate):
            date = Transaction().context.get('date', Date.today())
            if not from_currency.rate:
                name = from_currency.name
            else:
                name = to_currency.name

            languages = Lang.search([
                    ('code', '=', Transaction().language),
                    ])
            cls.raise_user_error('no_rate', {
                    'currency': name,
                    'date': datetime_strftime(date, str(languages[0].date))
                    })
        if round:
            return to_currency.round(
                amount * to_currency.rate / from_currency.rate)
        else:
            return amount * to_currency.rate / from_currency.rate
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:37,代码来源:currency.py

示例11: parse

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def parse(self, report, objects, data, localcontext):
        pool = Pool()
        invoice_obj = pool.get('account.invoice')
        patient_obj = pool.get('gnuhealth.patient')
        date_obj = Pool().get('ir.date')
        
        invoices = invoice_obj.browse(Transaction().context.get('active_ids'))
        patient = patient_obj.browse(patient_obj.search([('name' , '=', invoices[0].party)]))[0]
        localcontext['invoice'] = invoices[0]
        localcontext['patient'] = patient
        localcontext['today'] = date_obj.today().strftime("%d/%m/%Y")
        localcontext['untaxed_amount'] = sum((x['untaxed_amount'] for x in invoices))
        localcontext['tax_amount'] = sum((x['tax_amount'] for x in invoices))
        localcontext['service_fee'] = sum((x['service_fee'] for x in invoices))
        localcontext['discount'] = sum((x['discount'] for x in invoices))
        localcontext['total_amount'] = sum((x['total_amount'] for x in invoices))

        objects = [{
            'ref': invoice.reference,
            'date': invoice.invoice_date.strftime("(%d/%m/%Y)") if invoice.invoice_date else None,
            'lines': invoice.lines,
            'total': invoice.untaxed_amount,
            } for invoice in invoices]

        return super(PatientBillReport, self).parse(report, objects, data, 
                    localcontext)
开发者ID:russelmahmud,项目名称:IDSHealth,代码行数:28,代码来源:health.py

示例12: crear_factura

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def crear_factura(cls,publ):
        date = Pool().get('ir.date')
        sale = Pool().get('sale.sale')

        #calculo del invoice address
        invoice_address = publ.cliente.address_get(type='invoice')
        shipment_address = publ.cliente.address_get(type='delivery')
        nueva = sale.create([{
                    'party':publ.cliente,
                    'payment_term': publ.termino_pago,
                    'invoice_address' : invoice_address,
                    'shipment_address' : shipment_address,
                    'sale_date' :date.today(),
                    }])[0]
        nueva.save()

        publ.linea.sale = nueva
        publ.linea.save()
        nueva.state = 'processing'
        nueva.save()
        #crea factura
        nueva.create_invoice('out_invoice')
        nueva.create_invoice('out_credit_note')
        nueva.set_invoice_state()
        nueva.create_shipment('out')
        nueva.create_shipment('return')
        nueva.set_shipment_state()
开发者ID:lucianoit10,项目名称:tryton_el_independiente,代码行数:29,代码来源:edicion.py

示例13: compute

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def compute(self, amount, currency, date=None):
        """Calculate payment terms and return a list of tuples
        with (date, amount) for each payment term line.

        amount must be a Decimal used for the calculation.
        If specified, date will be used as the start date, otherwise current
        date will be used.
        """
        # TODO implement business_days
        # http://pypi.python.org/pypi/BusinessHours/
        Date = Pool().get("ir.date")

        sign = 1 if amount >= Decimal("0.0") else -1
        res = []
        if date is None:
            date = Date.today()
        remainder = amount
        for line in self.lines:
            value = line.get_value(remainder, amount, currency)
            value_date = line.get_date(date)
            if not value or not value_date:
                if (not remainder) and line.amount:
                    self.raise_user_error("invalid_line", {"line": line.rec_name, "term": self.rec_name})
                else:
                    continue
            if ((remainder - value) * sign) < Decimal("0.0"):
                res.append((value_date, remainder))
                break
            res.append((value_date, value))
            remainder -= value

        if not currency.is_zero(remainder):
            self.raise_user_error("missing_remainder", (self.rec_name,))
        return res
开发者ID:silpol,项目名称:tryton-bef,代码行数:36,代码来源:payment_term.py

示例14: generate

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def generate(cls, samples):
        Date = Pool().get('ir.date')
        for sample in samples:
            cls.write([sample], {
                    'date_generate': Date.today(),
                    })

        pass
开发者ID:bala4901,项目名称:demo_trytond,代码行数:10,代码来源:sample_module.py

示例15: compute_purchase_date

# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import today [as 别名]
    def compute_purchase_date(self, date):
        '''
        Compute the purchase date for the Product Supplier at the given date
        '''
        Date = Pool().get('ir.date')

        if self.delivery_time is None:
            return Date.today()
        return date - datetime.timedelta(self.delivery_time)
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:11,代码来源:product.py


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