本文整理汇总了Python中stoqlib.lib.dateutils.localnow函数的典型用法代码示例。如果您正苦于以下问题:Python localnow函数的具体用法?Python localnow怎么用?Python localnow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了localnow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: on_object_changed
def on_object_changed(self, attr, old_value, value):
if attr == 'cost':
self.cost_last_updated = localnow()
if self.product:
self.product.update_product_cost(value)
elif attr == 'base_price':
self.price_last_updated = localnow()
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:sellable.py
示例2: test_sync
def test_sync(self):
results = self.store.find(BranchSynchronization,
branch=self.branch)
self.assertEqual(results.count(), 0)
t1 = localnow()
# Datetime columns doesn't store microseconds
t1 = t1.replace(microsecond=0)
obj = BranchSynchronization(branch=self.branch,
policy=u"shop",
sync_time=t1,
store=self.store)
results = self.store.find(BranchSynchronization,
branch=self.branch)
self.assertEqual(results.count(), 1)
self.assertEqual(results[0], obj)
# FIXME: Storm is not using the right resolution
self.assertEqual(obj.sync_time.date(), t1.date())
self.assertEqual(obj.policy, u"shop")
self.assertEqual(obj.branch, self.branch)
t2 = localnow()
# Datetime columns doesn't store microseconds
t2 = t2.replace(microsecond=0)
obj.sync_time = t2
results = self.store.find(BranchSynchronization,
branch=self.branch)
self.assertEqual(results.count(), 1)
self.assertEqual(results[0], obj)
# FIXME: Storm is not using the right resolution
self.assertEqual(obj.sync_time.date(), t2.date())
self.assertEqual(obj.policy, u"shop")
self.assertEqual(obj.branch, self.branch)
开发者ID:Guillon88,项目名称:stoq,代码行数:35,代码来源:test_synchronization.py
示例3: test_new
def test_new(self):
with self.assertRaises(TypeError):
Payment(due_date=localnow(),
branch=self.create_branch(),
payment_type=Payment.TYPE_OUT,
store=self.store)
payment = Payment(value=currency(10), due_date=localnow(),
branch=self.create_branch(),
method=None,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
self.failUnless(payment.status == Payment.STATUS_PREVIEW)
开发者ID:Guillon88,项目名称:stoq,代码行数:15,代码来源:test_payment.py
示例4: test_get_paid_date_string
def test_get_paid_date_string(self):
method = PaymentMethod.get_by_name(self.store, u'check')
payment = Payment(value=currency(100),
branch=self.create_branch(),
due_date=localnow(),
method=method,
group=None,
category=None,
payment_type=Payment.TYPE_OUT,
store=self.store)
today = localnow().strftime(u'%x')
self.failIf(payment.get_paid_date_string() == today)
payment.set_pending()
payment.pay()
self.failUnless(payment.get_paid_date_string() == today)
开发者ID:Guillon88,项目名称:stoq,代码行数:15,代码来源:test_payment.py
示例5: create_account_transaction
def create_account_transaction(self, account=None, value=1,
source=None, incoming=False):
from stoqlib.domain.account import AccountTransaction
if account is None:
account = self.create_account()
if source:
source_id = source.id
else:
source_id = sysparam.get_object_id('IMBALANCE_ACCOUNT')
if incoming:
operation_type = AccountTransaction.TYPE_IN
else:
operation_type = AccountTransaction.TYPE_OUT
return AccountTransaction(
description=u"Test Account Transaction",
code=u"Code",
date=localnow(),
value=value,
account=account,
source_account_id=source_id,
operation_type=operation_type,
store=self.store)
开发者ID:Joaldino,项目名称:stoq,代码行数:25,代码来源:exampledata.py
示例6: orm_get_random
def orm_get_random(column):
if isinstance(column, Reference):
return None
variable = column.variable_factory.func
if issubclass(variable, UnicodeVariable):
value = u''
elif issubclass(variable, RawStrVariable):
value = ''
elif issubclass(variable, DateTimeVariable):
value = localnow()
elif issubclass(variable, IntVariable):
value = None
elif issubclass(variable, PriceVariable):
value = currency(20)
elif issubclass(variable, BoolVariable):
value = False
elif isinstance(variable, QuantityVariable):
value = decimal.Decimal(1)
elif issubclass(variable, DecimalVariable):
value = decimal.Decimal(1)
else:
raise ValueError(column)
return value
开发者ID:rosalin,项目名称:stoq,代码行数:26,代码来源:test_domain.py
示例7: on_confirm
def on_confirm(self):
if self._is_default_salesperson_role():
if self.salesperson:
if not self.salesperson.is_active:
self.salesperson.activate()
else:
store = self.store
self.salesperson = SalesPerson(person=self.person,
store=store)
elif self.salesperson:
if self.salesperson.is_active:
self.salesperson.inactivate()
old_salary = self.employee.salary
self.employee.salary = self.model.salary
if (self.model.role is not self.employee.role
or old_salary != self.model.salary):
self.employee.role = self.model.role
if self.current_role_history:
self.current_role_history.salary = old_salary
self.current_role_history.ended = localnow()
self.current_role_history.is_active = False
else:
# XXX This will prevent problems when you can't update
# the connection.
self.store.remove(self.model)
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:26,代码来源:employeeslave.py
示例8: test_is_p_cred_sn_valid
def test_is_p_cred_sn_valid(self):
icms_template = self.create_product_icms_template()
self.assertTrue(icms_template.is_p_cred_sn_valid())
expire_date = localnow()
icms_template.p_cred_sn_valid_until = expire_date
self.assertTrue(icms_template.is_p_cred_sn_valid())
expire_date = localnow() + relativedelta(days=+1)
icms_template.p_cred_sn_valid_until = expire_date
self.assertTrue(icms_template.is_p_cred_sn_valid())
expire_date = localnow() + relativedelta(days=-1)
icms_template.p_cred_sn_valid_until = expire_date
self.assertFalse(icms_template.is_p_cred_sn_valid())
开发者ID:esosaja,项目名称:stoq,代码行数:16,代码来源:test_taxes.py
示例9: receive
def receive(self):
"""Receive the package on the :attr:`.destination_branch`
This will mark the package as received in the branch
to receive it there. Note that it's only possible to call this
on the same branch as :attr:`.destination_branch`.
When calling this, the work orders' :attr:`WorkOrder.current_branch`
will be set to :attr:`.destination_branch`, since receiving means
they got to their destination.
"""
assert self.can_receive()
if self.destination_branch != get_current_branch(self.store):
raise ValueError(
_("This package's destination branch is %s and you are in %s. "
"It's not possible to receive a package outside the "
"destination branch") % (
self.destination_branch, get_current_branch(self.store)))
for order in [item.order for item in self.package_items]:
assert order.current_branch is None
# The order is in destination branch now
order.current_branch = self.destination_branch
self.receive_date = localnow()
self.status = self.STATUS_RECEIVED
开发者ID:marianaanselmo,项目名称:stoq,代码行数:27,代码来源:workorder.py
示例10: send
def send(self):
"""Send the package to the :attr:`.destination_branch`
This will mark the package as sent. Note that it's only possible
to call this on the same branch as :attr:`.source_branch`.
When calling this, the work orders' :attr:`WorkOrder.current_branch`
will be ``None``, since they are on a package and not on any branch.
"""
assert self.can_send()
if self.source_branch != get_current_branch(self.store):
raise ValueError(
_("This package's source branch is %s and you are in %s. "
"It's not possible to send a package outside the "
"source branch") % (
self.source_branch, get_current_branch(self.store)))
workorders = [item.order for item in self.package_items]
if not len(workorders):
raise ValueError(_("There're no orders to send"))
for order in workorders:
assert order.current_branch == self.source_branch
# The order is going to leave the current_branch
order.current_branch = None
self.send_date = localnow()
self.status = self.STATUS_SENT
开发者ID:marianaanselmo,项目名称:stoq,代码行数:29,代码来源:workorder.py
示例11: createInPayments
def createInPayments(self, no=3):
sale = self.create_sale()
d = localnow()
method = PaymentMethod.get_by_name(self.store, self.method_type)
payments = method.create_payments(Payment.TYPE_IN, sale.group,
sale.branch, Decimal(100),
[d] * no)
return payments
开发者ID:pkaislan,项目名称:stoq,代码行数:8,代码来源:test_payment_method.py
示例12: price
def price(self):
if self.on_sale_price:
today = localnow()
start_date = self.on_sale_start_date
end_date = self.on_sale_end_date
if is_date_in_interval(today, start_date, end_date):
return self.on_sale_price
return self.base_price
开发者ID:barkinet,项目名称:stoq,代码行数:8,代码来源:sellable.py
示例13: __init__
def __init__(self, store):
self.open_date = localnow()
self.branch = api.get_current_branch(store)
self.branch_name = self.branch.get_description()
self.user = api.get_current_user(store)
self.product_manufacturer = None
self.product_brand = None
self.product_family = None
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:8,代码来源:inventoryeditor.py
示例14: createOutPayments
def createOutPayments(self, no=3):
purchase = self.create_purchase_order()
d = localnow()
method = PaymentMethod.get_by_name(self.store, self.method_type)
payments = method.create_payments(Payment.TYPE_OUT, purchase.group,
purchase.branch, Decimal(100),
[d] * no)
return payments
开发者ID:pkaislan,项目名称:stoq,代码行数:8,代码来源:test_payment_method.py
示例15: get_opening_date
def get_opening_date(self):
# self.till is None only in the special case that the user added the ECF
# to Stoq with a pending reduce Z, so we need to close the till on the
# ECF, but not on Stoq.
# Return a date in the past
if not self.till:
return localnow() - timedelta(1)
return self.till.opening_date
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:8,代码来源:tilleditor.py
示例16: test_calls
def test_calls(self):
person = self.create_person()
user = self.create_user()
self.assertEquals(len(list(person.calls)), 0)
call = Calls(store=self.store, date=localnow(),
description=u'', message=u'', person=person, attendant=user)
self.assertEquals(len(list(person.calls)), 1)
self.assertEquals(list(person.calls)[0], call)
开发者ID:rosalin,项目名称:stoq,代码行数:9,代码来源:test_person.py
示例17: approve
def approve(self):
"""Approves this work order
Approving means that the |client| has accepted the
work's quote and it's cost and it can now start.
"""
assert self.can_approve()
self.approve_date = localnow()
self.status = self.STATUS_APPROVED
开发者ID:marianaanselmo,项目名称:stoq,代码行数:9,代码来源:workorder.py
示例18: test_needs_closing
def test_needs_closing(self):
till = Till(station=self.create_station(), store=self.store)
self.failIf(till.needs_closing())
till.open_till()
self.failIf(till.needs_closing())
till.opening_date = localnow() - datetime.timedelta(1)
self.failUnless(till.needs_closing())
till.close_till()
self.failIf(till.needs_closing())
开发者ID:rg3915,项目名称:stoq,代码行数:9,代码来源:test_till.py
示例19: confirm
def confirm(self, login_user):
"""Receive the returned_sale_items from a pending |returned_sale|
:param user: the |login_user| that received the pending returned sale
"""
assert self.status == self.STATUS_PENDING
self._return_items()
self.status = self.STATUS_CONFIRMED
self.confirm_responsible = login_user
self.confirm_date = localnow()
开发者ID:barkinet,项目名称:stoq,代码行数:10,代码来源:returnedsale.py
示例20: cancel
def cancel(self, responsible, cancel_date=None):
"""Cancel a transfer order"""
assert self.can_cancel()
for item in self.get_items():
item.cancel()
self.cancel_date = cancel_date or localnow()
self.cancel_responsible_id = responsible.id
self.status = self.STATUS_CANCELLED
开发者ID:Guillon88,项目名称:stoq,代码行数:10,代码来源:transfer.py
注:本文中的stoqlib.lib.dateutils.localnow函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论