本文整理汇总了Python中trytond.pool.Pool.search方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.search方法的具体用法?Python Pool.search怎么用?Python Pool.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resumir_datos_clientes
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def resumir_datos_clientes(cls, facturadomes, facturadoanio):
Asociadas = Pool().get('party.party')
asociadas = Asociadas.search([('asociada', '=', True)])
CuotasAsociada = Pool().get('asociadas.cuota')
Tuplas_Asociadas = []
total_mes = 0
tipo_factura = ''
for asociada in asociadas:
if asociada.iva_condition == 'responsable_inscripto':
tipo_factura = 'A'
else:
tipo_factura = 'B'
#traigo cuota paga del mes seleccionado
cuota_paga = CuotasAsociada.search([('asociada', '=', asociada), ('mes', '=', facturadomes), ('anio', '=', facturadoanio), ('pagada', '=', True)])
if cuota_paga:
total_mes += cuota_paga[0].monto
Tuplas_Asociadas.append((asociada.name, str(asociada.monto_actual_cuota), tipo_factura, str(cuota_paga[0].monto)))
else:
Tuplas_Asociadas.append((asociada.name, str(asociada.monto_actual_cuota), tipo_factura, '0'))
return Tuplas_Asociadas
开发者ID:geneos-tryton-cooperar,项目名称:cooperar-informes,代码行数:29,代码来源:informeCuotaSostenimientoperiodo.py
示例2: get_sale_price
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def get_sale_price(self):
"""Estimates the shipment rate for the current shipment
The get_sale_price implementation by tryton's carrier module
returns a tuple of (value, currency_id)
:returns: A tuple of (value, currency_id which in this case is USD)
"""
Sale = Pool().get('sale.sale')
Shipment = Pool().get('stock.shipment.out')
Currency = Pool().get('currency.currency')
shipment = Transaction().context.get('shipment')
sale = Transaction().context.get('sale')
usd, = Currency.search([('code', '=', 'USD')]) # Default currency
if Transaction().context.get('ignore_carrier_computation'):
return Decimal('0'), usd.id
if not sale and not shipment:
return Decimal('0'), usd.id
if self.carrier_cost_method != 'endicia':
return super(Carrier, self).get_sale_price()
usd, = Currency.search([('code', '=', 'USD')])
if sale:
return Sale(sale).get_endicia_shipping_cost(), usd.id
if shipment:
return Shipment(shipment).get_endicia_shipping_cost(), usd.id
return Decimal('0'), usd.id
示例3: get_amount
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def get_amount(self, name):
"""
Returns authorzied, captured and available amount for the gift card
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
if name == 'amount_authorized':
return sum([t.amount for t in PaymentTransaction.search([
('state', '=', 'authorized'),
('gift_card', '=', self.id)
])])
if name == 'amount_captured':
return sum([t.amount for t in PaymentTransaction.search([
('state', 'in', ['posted', 'done']),
('gift_card', '=', self.id)
])])
if name == 'amount_available':
return self.amount - sum([
t.amount for t in PaymentTransaction.search([
('state', 'in', ['authorized', 'posted', 'done']),
('gift_card', '=', self.id)
])
])
示例4: find_or_create_using_magento_data
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def find_or_create_using_magento_data(cls, product_data):
"""
Find or create a product template using magento data provided.
This method looks for an existing template using the magento ID From
data provided. If found, it returns the template found, else creates
a new one and returns that
:param product_data: Product Data From Magento
:returns: Browse record of product found/created
"""
Product = Pool().get("product.product")
Listing = Pool().get("product.product.channel_listing")
Channel = Pool().get("sale.channel")
channel = Channel.get_current_magento_channel()
products = Product.search([("code", "=", product_data["sku"])])
listings = Listing.search([("product.code", "=", product_data["sku"]), ("channel", "=", channel)])
if not products:
product = Product.create_from(channel, product_data)
else:
product, = products
if not listings:
Listing.create_from(channel, product_data)
return product
示例5: crear_factura
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [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()
示例6: check_sled_period_closed
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def check_sled_period_closed(cls, lots):
Period = Pool().get('stock.period')
Move = Pool().get('stock.move')
periods = Period.search([
('state', '=', 'closed'),
], order=[('date', 'DESC')], limit=1)
if not periods:
return
period, = periods
for lots in grouped_slice(lots):
lot_ids = [l.id for l in lots]
moves = Move.search([
('lot', 'in', lot_ids),
['OR', [
('effective_date', '=', None),
('planned_date', '<=', period.date),
],
('effective_date', '<=', period.date),
]], limit=1)
if moves:
move, = moves
cls.raise_user_error('period_closed_expiration_dates', {
'lot': move.lot.rec_name,
'move': move.rec_name,
})
示例7: create_dataframe
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def create_dataframe(self):
"""create & save a R dataframe in dataframe field"""
if self.model is not None:
ModelField = Pool().get('ir.model.field')
model_fields = ModelField.search([('model', '=', self.model)])
model = Pool().get(self.model.model)
records = model.search([])
fields_info = [FieldInfo(field.name, field.ttype)
for field in model_fields]
df = dataframe(records, fields_info)
self.data = buffer(pickle.dumps(df))
self.save()
elif self.script is not None:
# clean R workspace
# robjects.r['source'] could be used instead of robjects.r
robjects.r("""rm(list = ls(all.names=TRUE))""")
try:
# run code uploaded by users
try:
robjects.r(self.script.code)
except RRuntimeError, err:
self.raise_user_error('r_error', (err,))
globalenv = robjects.r["globalenv"]()
try:
obj = globalenv['out']
except LookupError:
obj = None
if isinstance(obj, robjects.DataFrame):
self.data = buffer(pickle.dumps(obj))
else:
self.data = None
finally:
示例8: export_order_status_to_prestashop
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def export_order_status_to_prestashop(self):
"""Update the status of this order in prestashop based on the order
state in Tryton.
"""
ChannelOrderState = Pool().get("sale.channel.order_state")
client = self.channel.get_prestashop_client()
new_prestashop_state = None
if self.state == "cancel":
order_state, = ChannelOrderState.search([("channel", "=", self.id), ("name", "=", "Canceled")])
new_prestashop_state = order_state.code
elif self.state == "done":
# TODO: update shipping and invoice
order_state, = ChannelOrderState.search(
[
("channel", "=", self.id),
# XXX: Though final state in prestashop is delivered, but
# till we don't have provision to get delivery status, set
# it to shipped.
("name", "=", "Shipped"),
]
)
new_prestashop_state = order_state.code
if not new_prestashop_state:
return
order = client.orders.get(self.channel_identifier)
order.current_state = new_prestashop_state
result = client.orders.update(order.id, order)
return result.order
示例9: resumir_datos_subdiario_ventas
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def resumir_datos_subdiario_ventas(cls, desde, hasta):
Tuplas_Asientos = []
#Busco Journal de Ventas
Journal = Pool().get('account.journal')
#No es Ventas, es Ingresos
journal = Journal.search([('name', '=', 'Ingresos')])
if journal:
#Traigo las Invoice -> de ese Journal entre fechas (invoice_date)
Invoice = Pool().get('account.invoice')
invoices = Invoice.search([('invoice_date', '>=', desde),('invoice_date', '<=', hasta),('journal', '=', journal[0])], order=[('invoice_date', 'ASC')])
if invoices:
for invoice in invoices:
move_number = invoice.move.lines[0].id
#TODO: Tipo de Factura
subtotal_gravado_con_iva = cls.get_total_gravado_con_iva_por_factura(invoice)
subtotal_iva = cls.get_total_iva_por_factura(invoice)
Tuplas_Asientos.append((invoice.invoice_date, move_number, 'Factura',
invoice.number, invoice.invoice_date,
invoice.party.name, invoice.party.iva_condition, invoice.party.vat_number,
subtotal_gravado_con_iva, subtotal_iva, invoice.total_amount))
else:
#raise error: no hay movimientos para ese diario/periodo
#cls.raise_user_error('No hay movimientos para el diario VENTAS en el periodo seleccionado.')
return Tuplas_Asientos
else:
#raise error: no hay subdiario de ventas configurado
#cls.raise_user_error('No hay diario de ventas configurado en el sistema.')
return Tuplas_Asientos
return Tuplas_Asientos
示例10: resumir_datos_clientes
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def resumir_datos_clientes(cls, deudames, deudaanio):
Asociadas = Pool().get('party.party')
asociadas = Asociadas.search([('asociada', '=', True)])
CuotasAsociada = Pool().get('asociadas.cuota')
Tuplas_Asociadas = []
#import pudb;pu.db
for asociada in asociadas:
cuotas_adeudadas = 0
monto_adeudado = 0
ultima_cuota_paga = CuotasAsociada.search([('asociada', '=', asociada)], order=[('mes', 'ASC'), ('anio', 'ASC'),])
if ultima_cuota_paga:
if ultima_cuota_paga[0].anio == deudaanio:
cuotas_adeudadas = int(deudames) - int(ultima_cuota_paga[0].mes)
else:
anios_diferencia = int(deudaanio) - int(ultima_cuota_paga[0].anio)
cuotas_adeudadas = (anios_diferencia - 1) * 12
cuotas_adeudadas += deudames
cuotas_adeudadas += (12 - int(ultima_cuota_paga[0].mes))
Tuplas_Asociadas.append((asociada.name, asociada.monto_actual_cuota, str(ultima_cuota_paga[0].mes) + '/' + str(ultima_cuota_paga[0].anio), cuotas_adeudadas, float(cuotas_adeudadas) * float(asociada.monto_actual_cuota)))
else:
cuotas_adeudadas = 0
Tuplas_Asociadas.append((asociada.name, asociada.monto_actual_cuota, 'No se registran cuotas pagas', 'No se registran cuotas pagas', float(cuotas_adeudadas) * float(asociada.monto_actual_cuota)))
return Tuplas_Asociadas
示例11: update_order_status
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def update_order_status(self):
"Downstream implementation of order_status update"
Sale = Pool().get('sale.sale')
if self.source != 'magento':
return super(Channel, self).update_order_status()
sales = Sale.search([
('channel', '=', self.id),
('state', 'in', ('confirmed', 'processing')),
])
order_ids = [sale.reference for sale in sales]
for order_ids_batch in batch(order_ids, 50):
with magento.Order(
self.magento_url, self.magento_api_user, self.magento_api_key
) as order_api:
orders_data = order_api.info_multi(order_ids_batch)
for i, order_data in enumerate(orders_data):
if order_data.get('isFault'):
if order_data['faultCode'] == '100':
# 100: Requested order not exists.
# TODO: Remove order from channel or add some
# exception.
pass
logger.warning("Order %s: %s %s" % (
order_ids_batch[i], order_data['faultCode'],
order_data['faultMessage']
))
continue
sale, = Sale.search([
('reference', '=', order_data['increment_id'])
])
sale.update_order_status_from_magento(order_data=order_data)
示例12: __register__
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def __register__(cls, module_name):
Party = Pool().get('party.party')
Sale = Pool().get('sale.sale')
Model = Pool().get('ir.model')
ModelField = Pool().get('ir.model.field')
Property = Pool().get('ir.property')
TableHandler = backend.get('TableHandler')
cursor = Transaction().cursor
table = TableHandler(cursor, cls, module_name)
migration_needed = False
if not table.column_exist('credit_account'):
migration_needed = True
super(Payment, cls).__register__(module_name)
if migration_needed and not Pool.test:
# Migration
# Set party's receivable account as the credit_account on
# sale payments
payment = cls.__table__()
party = Party.__table__()
property = Property.__table__()
sale = Sale.__table__()
account_model, = Model.search([
('model', '=', 'party.party'),
])
account_receivable_field, = ModelField.search([
('model', '=', account_model.id),
('name', '=', 'account_receivable'),
('ttype', '=', 'many2one'),
])
update = payment.update(
columns=[payment.credit_account],
values=[
Trim(
Substring(property.value, ',.*'), 'LEADING', ','
).cast(cls.credit_account.sql_type().base)
],
from_=[sale, party, property],
where=(
payment.sale == sale.id
) & (
sale.party == party.id
) & (
property.res == Concat(Party.__name__ + ',', party.id)
) & (
property.field == account_receivable_field.id
) & (
property.company == sale.company
)
)
cursor.execute(*update)
示例13: get_endicia_shipping_rates
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def get_endicia_shipping_rates(self, silent=True):
"""
Call the rates service and get possible quotes for shipment for eligible
mail classes
"""
Carrier = Pool().get('carrier')
UOM = Pool().get('product.uom')
EndiciaConfiguration = Pool().get('endicia.configuration')
endicia_credentials = EndiciaConfiguration(1).get_endicia_credentials()
carrier, = Carrier.search(['carrier_cost_method', '=', 'endicia'])
from_address = self._get_ship_from_address()
mailclass_type = "Domestic" if self.shipment_address.country.code == 'US' \
else "International"
uom_oz = UOM.search([('symbol', '=', 'oz')])[0]
# Endicia only support 1 decimal place in weight
weight_oz = self._get_package_weight(uom_oz).quantize(
Decimal('.1'), rounding=ROUND_UP
)
to_zip = self.shipment_address.zip
if mailclass_type == 'Domestic':
to_zip = to_zip and to_zip[:5]
else:
# International
to_zip = to_zip and to_zip[:15]
postage_rates_request = PostageRatesAPI(
mailclass=mailclass_type,
weightoz=weight_oz,
from_postal_code=from_address.zip[:5],
to_postal_code=to_zip,
to_country_code=self.shipment_address.country.code,
accountid=endicia_credentials.account_id,
requesterid=endicia_credentials.requester_id,
passphrase=endicia_credentials.passphrase,
test=endicia_credentials.is_test,
)
# Logging.
logger.debug(
'Making Postage Rates Request for shipping rates of'
'Sale ID: {0} and Carrier ID: {1}'
.format(self.id, carrier.id)
)
logger.debug('--------POSTAGE RATES REQUEST--------')
logger.debug(str(postage_rates_request.to_xml()))
logger.debug('--------END REQUEST--------')
try:
response_xml = postage_rates_request.send_request()
response = objectify_response(response_xml)
except RequestError, e:
self.raise_user_error(unicode(e))
示例14: import_product
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def import_product(self, sku):
"""
Import specific product for this amazon channel
Downstream implementation for channel.import_product
:param sku: Product Seller SKU from Amazon
:returns: Active record of Product Created
"""
Product = Pool().get('product.product')
Listing = Pool().get('product.product.channel_listing')
if self.source != 'amazon_mws':
return super(SaleChannel, self).import_product(sku)
# Check if there is a poduct with the seller SKU
# The SKU on the product could be different from that of the
# listing. Say older SKUs or Amazon assigned SKUs.
exisiting_listings = Listing.search([
('product_identifier', '=', sku),
('channel', '=', self),
])
if exisiting_listings:
return exisiting_listings[0].product
products = Product.search([('code', '=', sku)])
product_api = self.get_amazon_product_api()
if not products:
# Create a product since there is no match for an existing
# product with the SKU.
product_data = product_api.get_matching_product_for_id(
self.amazon_marketplace_id, 'SellerSKU', [sku]
).parsed
products = [Product.create_from(self, product_data)]
product, = products
listings = Listing.search([
('product', '=', product),
('channel', '=', self),
])
if not listings:
product_data = product_api.get_matching_product_for_id(
self.amazon_marketplace_id, 'SellerSKU', [sku]
).parsed
Listing(
product=product,
channel=self,
product_identifier=sku,
asin=product_data['Products']['Product']['Identifiers']["MarketplaceASIN"]["ASIN"]["value"], # noqa
).save()
return product
示例15: import_product
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import search [as 别名]
def import_product(self, sku, product_data=None):
"""
Import specific product for this magento channel
Downstream implementation for channel.import_product
"""
Product = Pool().get('product.product')
Listing = Pool().get('product.product.channel_listing')
if self.source != 'magento':
return super(Channel, self).import_product(sku, product_data)
if not sku:
# SKU is required can not continue
return
# Sanitize SKU
sku = sku.strip()
products = Product.search([
('code', '=', sku),
])
listings = Listing.search([
('product.code', '=', sku),
('channel', '=', self)
])
if not products or not listings:
# Either way we need the product data from magento. Make that
# dreaded API call.
with magento.Product(
self.magento_url, self.magento_api_user,
self.magento_api_key
) as product_api:
product_data = product_api.info(sku, identifierType="sku")
# XXX: sanitize product_data, sometimes product sku may
# contain trailing spaces
product_data['sku'] = product_data['sku'].strip()
# Create a product since there is no match for an existing
# product with the SKU.
if not products:
product = Product.create_from(self, product_data)
else:
product, = products
if not listings:
Listing.create_from(self, product_data)
else:
product = products[0]
return product