本文整理汇总了Python中stoqlib.lib.dateutils.localtoday函数的典型用法代码示例。如果您正苦于以下问题:Python localtoday函数的具体用法?Python localtoday怎么用?Python localtoday使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了localtoday函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_show
def test_show(self, run_dialog):
optical = self.create_optical_work_order()
optical.medic = self.create_optical_medic()
sale = self.create_sale()
sale.identifier = 99413
workorder = optical.work_order
workorder.sale = sale
sellable = self.create_sellable()
sale_item = sale.add_sellable(sellable)
wo_item = self.create_work_order_item(order=workorder)
wo_item.sale_item = sale_item
self.add_payments(sale)
sale.order()
sale.confirm()
sale.open_date = localtoday()
sale.confirm_date = localtoday()
search = MedicSalesSearch(self.store)
search._date_filter.select(data=Any)
search.search.refresh()
self.check_search(search, 'optical-medic-sales-search')
search.results.select(search.results[0])
self.click(search.sale_details_button)
self.assertEquals(run_dialog.call_count, 1)
self.assertEquals(run_dialog.call_args[0][0], SaleDetailsDialog)
self.assertEquals(run_dialog.call_args[0][1], search)
self.assertEquals(run_dialog.call_args[0][2], self.store)
self.assertEquals(run_dialog.call_args[0][3].id, sale.id)
示例2: test_price
def test_price(self):
p1 = self.create_product()
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
self.failUnless(list(results))
pv = results[0]
self.assertEquals(pv.price, 10)
# Set a sale price
sellable = p1.sellable
sellable.on_sale_price = Decimal("5.55")
# And a interval that includes today
yesterday = localtoday() - datetime.timedelta(days=1)
tomorrow = localtoday() + datetime.timedelta(days=1)
sellable.on_sale_start_date = yesterday
sellable.on_sale_end_date = tomorrow
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, Decimal("5.55"))
# Testing with a sale price set, but in the past
date1 = localtoday() - datetime.timedelta(days=10)
date2 = localtoday() - datetime.timedelta(days=5)
sellable.on_sale_start_date = date1
sellable.on_sale_end_date = date2
results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, 10)
示例3: testPrice
def testPrice(self):
branch = self.create_branch()
p1 = self.create_product(branch=branch, stock=1, price=Decimal('10.15'))
results = SellableFullStockView.find_by_branch(self.store, branch).find(
SellableFullStockView.product_id == p1.id)
self.failUnless(list(results))
self.assertEquals(results[0].price, Decimal('10.15'))
# Set a sale price
sellable = p1.sellable
sellable.on_sale_price = Decimal('5.55')
# And a interval that includes today
yesterday = localtoday().date() - datetime.timedelta(days=1)
tomorrow = localtoday().date() + datetime.timedelta(days=1)
sellable.on_sale_start_date = yesterday
sellable.on_sale_end_date = tomorrow
results = SellableFullStockView.find_by_branch(self.store, branch).find(
SellableFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, Decimal('5.55'))
# Testing with a sale price set, but in the past
date1 = localtoday().date() - datetime.timedelta(days=10)
date2 = localtoday().date() - datetime.timedelta(days=5)
sellable.on_sale_start_date = date1
sellable.on_sale_end_date = date2
results = SellableFullStockView.find_by_branch(self.store, branch).find(
SellableFullStockView.product_id == p1.id)
self.assertEquals(results[0].price, Decimal('10.15'))
示例4: test_show
def test_show(self):
stock_transaction = self.create_stock_transaction_history()
entry = self.create_cost_center_entry(stock_transaction=stock_transaction)
cost_center = entry.cost_center
sale_item = self.create_sale_item()
sale = sale_item.sale
stock_decrease = self.create_stock_decrease()
# The decrease needs an item to be shown in the dialog
self.create_stock_decrease_item(stock_decrease=stock_decrease)
stock_transaction.type = StockTransactionHistory.TYPE_SELL
stock_transaction.object_id = sale_item.id
stock_transaction.date = localtoday().date()
stock_transaction.quantity = 5
stock_transaction.stock_cost = currency('10.50')
entry.stock_transaction = stock_transaction
sale.cost_center = cost_center
sale.identifier = 1234
sale.open_date = localtoday().date()
sale.total_amount = sale.get_total_sale_amount()
stock_decrease.cost_center = cost_center
stock_decrease.identifier = 5678
stock_decrease.confirm_date = localtoday().date()
dialog = CostCenterDialog(self.store, cost_center)
self.check_dialog(dialog, 'dialog-cost-center-details')
示例5: _create_payment
def _create_payment(self):
group = PaymentGroup()
group.payer = self.client.person
method = PaymentMethod.get_by_name(self.store, u'credit')
branch = api.get_current_branch(self.store)
if self.model.value < 0:
payment_type = Payment.TYPE_IN
else:
payment_type = Payment.TYPE_OUT
# Set status to PENDING now, to avoid calling set_pending on
# on_confirm for payments that shoud not have its status changed.
payment = Payment(open_date=localtoday(),
branch=branch,
status=Payment.STATUS_PENDING,
description=self.model.description,
value=abs(self.model.value),
base_value=abs(self.model.value),
due_date=localtoday(),
method=method,
group=group,
till=None,
category=None,
payment_type=payment_type,
bill_received=False)
payment.pay()
return payment
示例6: __init__
def __init__(self, source_branch):
self.items = []
self.open_date = localtoday().date()
self.receival_date = localtoday().date()
self.source_branch = source_branch
self.destination_branch = None
self.source_responsible = None
self.destination_responsible = None
示例7: test_get_days_late
def test_get_days_late(self):
payment = self.create_payment(payment_type=Payment.TYPE_IN)
view = self.store.find(InPaymentView, id=payment.id).one()
self.assertFalse(view.get_days_late())
payment.due_date = localtoday() + datetime.timedelta(-4)
view = self.store.find(InPaymentView, id=payment.id).one()
self.assertEquals(view.get_days_late(), 4)
payment.due_date = localtoday() + datetime.timedelta(+4)
view = self.store.find(InPaymentView, id=payment.id).one()
self.assertFalse(view.get_days_late())
示例8: on_close_date__validate
def on_close_date__validate(self, widget, date):
if sysparam(self.store).ALLOW_OUTDATED_OPERATIONS:
return
if date > localtoday().date() or date < self.model.open_date:
return ValidationError(_("Paid date must be between "
"%s and today") % (self.model.open_date, ))
示例9: on_estimated_start__validate
def on_estimated_start__validate(self, widget, value):
sysparam_ = api.sysparam(self.store)
if (value < localtoday().date() and
not sysparam_.ALLOW_OUTDATED_OPERATIONS):
return ValidationError(u"The start date cannot be on the past")
self.estimated_finish.validate(force=True)
示例10: _populate_date_filter
def _populate_date_filter(self, date_filter):
# The options we want to show to the users are the following:
# 'May 2007'
# 'June 2007'
# ...
# 'September 2008'
initial_date = self.store.find(SystemTable).min(
SystemTable.updated).date()
# Start is the first day of the month
# End is the last day of the month
start = initial_date + relativedelta(day=1)
end = localtoday().date() + relativedelta(day=31)
intervals = []
while start < end:
intervals.append((start, start + relativedelta(day=31)))
start = start + relativedelta(months=1)
# When we have the list of intervals, add them to the list and
# make sure that they are translated
month_names = get_month_names()
for start, end in intervals:
# Translators: Do not translate 'month' and 'year'. You can
# change it's positions. In the way it is,
# it will product for example 'December 2012'
name = _('{month} {year}').format(
month=month_names[start.month - 1],
year=start.year)
date_filter.add_option_fixed_interval(
name, start, end, position=0)
示例11: testChangeDueDateSale
def testChangeDueDateSale(self, warning):
sale = self.create_sale()
sale.client = self.create_client()
sale.identifier = 9123
payment = self.add_payments(sale, date=localdate(2001, 1, 1).date())[0]
editor = PaymentDueDateChangeDialog(self.store, payment, sale)
self.check_editor(editor, 'editor-payment-change-due-date-sale')
today = localtoday().date()
yesterday = today - relativedelta(days=1)
# By default, we cannot set a due date to the past
editor.due_date.update(yesterday)
self.assertNotSensitive(editor.main_dialog, ['ok_button'])
# Now we should be able to confirm the dialog
editor.due_date.update(today)
self.assertSensitive(editor.main_dialog, ['ok_button'])
# Ok button is enabled, but should show a warning
self.click(editor.main_dialog.ok_button)
warning.assert_called_once_with('You can not change the due date '
'without a reason!')
warning.reset_mock()
editor.change_reason.update('Just because')
self.click(editor.main_dialog.ok_button)
self.assertEquals(warning.call_count, 0)
self.assertEquals(payment.due_date.date(), today)
示例12: test_can_remove
def test_can_remove(self):
product = self.create_product()
test = ProductQualityTest(store=self.store, product=product)
# Test has never been used
self.assertTrue(test.can_remove())
order = self.create_production_order()
user = self.create_user()
item = ProductionProducedItem(product=product,
order=order,
produced_by=user,
produced_date=localtoday().date(),
serial_number=1,
store=self.store)
self.assertTrue(test.can_remove())
# Test has been used in a production
ProductionItemQualityResult(produced_item=item,
quality_test=test,
tested_by=user,
result_value=u'True',
test_passed=True,
store=self.store)
self.assertFalse(test.can_remove())
示例13: test_has_late_payments
def test_has_late_payments(self):
client = self.create_client()
today = localtoday().date()
method = PaymentMethod.get_by_name(self.store, u'bill')
# client does not have any payments
self.assertFalse(InPaymentView.has_late_payments(self.store,
client.person))
# client has payments that are not overdue
payment = self.create_payment(Payment.TYPE_IN,
today + relativedelta(days=1),
method=method)
payment.group = self.create_payment_group()
payment.group.payer = client.person
self.assertFalse(InPaymentView.has_late_payments(self.store,
client.person))
# client has overdue payments
payment = self.create_payment(Payment.TYPE_IN,
today - relativedelta(days=2),
method=method)
payment.status = Payment.STATUS_PENDING
payment.group = self.create_payment_group()
payment.group.payer = client.person
self.assertTrue(InPaymentView.has_late_payments(self.store,
client.person))
示例14: test_select_by_branch_data
def test_select_by_branch_data(self):
branch = get_current_branch(self.store)
sale = self.create_sale()
sale.branch = branch
sellable = self.add_product(sale)
sale.order()
self.add_payments(sale, method_type=u"money")
sale.confirm()
results = SoldItemView.find_by_branch_date(self.store, None, None)
self.assertFalse(results.is_empty())
results = SoldItemView.find_by_branch_date(self.store, branch, None)
self.assertFalse(results.is_empty())
results = SoldItemView.find_by_branch_date(self.store, branch, None).find(SoldItemView.id == sellable.id)
# FIXME: Storm does not support count() with group_by
# self.assertEquals(results.count(), 1)
self.assertEquals(len(list(results)), 1)
today = localtoday()
results = SoldItemView.find_by_branch_date(self.store, None, today).find(SoldItemView.id == sellable.id)
self.assertEquals(len(list(results)), 1)
yesterday = today - datetime.timedelta(days=1)
results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))
results = results.find(SoldItemView.id == sellable.id)
self.assertEquals(len(list(results)), 1)
yesterday = today - datetime.timedelta(days=1)
results = SoldItemView.find_by_branch_date(self.store, None, (yesterday, today))
self.assertFalse(results.is_empty())
示例15: testCreate
def testCreate(self):
person = self.create_person()
editor = CallsEditor(self.store, None, person, None)
self.assertTrue(isinstance(editor.model, Calls))
editor.date.update(localtoday().date())
self.check_editor(editor, 'editor-calls-create')