本文整理匯總了Python中autonomie.models.tva.Tva.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Tva.get方法的具體用法?Python Tva.get怎麽用?Python Tva.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類autonomie.models.tva.Tva
的用法示例。
在下文中一共展示了Tva.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: submit_success
# 需要導入模塊: from autonomie.models.tva import Tva [as 別名]
# 或者: from autonomie.models.tva.Tva import get [as 別名]
def submit_success(self, appstruct):
"""
fired on submit success, set Tvas
"""
# First we disable the elements that are no longer part of the
# configuration
self.disable_elements(Product, self.get_remaining_prod_ids(appstruct))
self.disable_elements(Tva, self.get_remaining_tva_ids(appstruct))
self.dbsession.flush()
for data in appstruct['tvas']:
products = data.pop('products')
if 'id' in data:
tva = Tva.get(data['id'])
merge_session_with_post(tva, data)
tva = self.dbsession.merge(tva)
else:
tva = Tva()
merge_session_with_post(tva, data)
self.dbsession.add(tva)
for prod in products:
if 'id' in prod:
product = Product.get(prod['id'])
product.tva = tva
merge_session_with_post(product, prod)
self.dbsession.merge(product)
else:
product = Product()
merge_session_with_post(product, prod)
product.tva = tva
self.dbsession.add(product)
self.request.session.flash(self.validation_msg)
return HTTPFound(self.request.route_path("admin_tva"))
示例2: validate_amount_by_tva
# 需要導入模塊: from autonomie.models.tva import Tva [as 別名]
# 或者: from autonomie.models.tva.Tva import get [as 別名]
def validate_amount_by_tva(values):
tva_id = values.get('tva_id')
tva = Tva.get(tva_id)
if tva is None:
return u"Tva inconnue"
amount = values.get('amount')
# Fix #433 : encaissement et tva multiples
# Add a tolerance for 5 € of difference
if amount > tva_parts[tva.value] + PAYMENT_EPSILON:
return u"Le montant de l'encaissement doit être inférieur à la \
part de cette Tva dans la facture"
return True
示例3: tva_product_validator
# 需要導入模塊: from autonomie.models.tva import Tva [as 別名]
# 或者: from autonomie.models.tva.Tva import get [as 別名]
def tva_product_validator(node, value):
"""
Validator checking that tva and product_id matches
"""
product_id = value.get('product_id')
if product_id is not None:
tva_id = value.get('tva_id')
if tva_id is not None:
tva = Tva.get(tva_id)
if product_id not in [p.id for p in tva.products]:
exc = colander.Invalid(
node,
u"Ce produit ne correspond pas à la TVA configurée"
)
exc['product_id'] = u"Le code produit doit correspondre à la \
TVA configurée pour cette prestation"
raise exc