本文整理汇总了Python中trytond.pool.Pool.process方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.process方法的具体用法?Python Pool.process怎么用?Python Pool.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.process方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_state_using_ps_data
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process_state_using_ps_data(self, order_state):
"""Process Sale state as per the current state
:param order_state: Site order state corresponding to ps order state
"""
Sale = Pool().get('sale.sale')
# Do not process sale if sale has exception
if self.has_channel_exception:
return
self.channel.get_prestashop_client()
# Cancel the order if its cancelled on prestashop
if order_state.order_state == 'sale.cancel':
Sale.cancel([self])
return
# Confirm and process the order in any other case
Sale.quote([self])
Sale.confirm([self])
if order_state.order_state != 'sale.confirmed':
# XXX: To mark sale as Done, sale must be in Processing state
# as marking sale as Done is part of transition workflow now,
# which allows only processed sale to be marked as Done.
# But not sure if calling proceed before process is the right
# way to do.
Sale.proceed([self])
Sale.process([self])
示例2: process_to_channel_state
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process_to_channel_state(self, channel_state):
"""
Process the sale in tryton based on the state of order
when its imported from channel
:param channel_state: State on external channel the order was imported
"""
Sale = Pool().get('sale.sale')
Shipment = Pool().get('stock.shipment.out')
data = self.channel.get_tryton_action(channel_state)
if data['action'] in ['process_manually', 'process_automatically']:
Sale.quote([self])
Sale.confirm([self])
if data['action'] == 'process_automatically':
Sale.process([self])
for shipment in self.shipments:
if shipment.state == 'draft':
Shipment.wait([shipment])
if shipment.state == 'waiting':
Shipment.assign_try([shipment])
if data['action'] == 'import_as_past':
# XXX: mark past orders as completed
self.state = 'done'
self.save()
示例3: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def delete(cls, reconciliations):
Invoice = Pool().get('account.invoice')
move_ids = set(l.move.id for r in reconciliations for l in r.lines)
invoices = Invoice.search([
('move', 'in', list(move_ids)),
])
super(Reconciliation, cls).delete(reconciliations)
Invoice.process(invoices)
示例4: create
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def create(cls, vlist):
Invoice = Pool().get('account.invoice')
reconciliations = super(Reconciliation, cls).create(vlist)
move_ids = set()
for reconciliation in reconciliations:
move_ids |= set(l.move.id for l in reconciliation.lines)
invoices = Invoice.search([
('move', 'in', list(move_ids)),
])
Invoice.process(invoices)
return reconciliations
示例5: _process_payment
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def _process_payment(cls, sale, form):
"""Process the payment
:param sale: Browse Record of Sale Order
:param form: Instance of validated form
"""
PaymentGateway = Pool().get("nereid.payment.gateway")
return PaymentGateway.process(sale, form.payment_method.data)
示例6: process_sale_using_magento_state
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process_sale_using_magento_state(self, magento_state):
"""
Process the sale in tryton based on the state of order
when its imported from magento
:param magento_state: State on magento the order was imported in
"""
Sale = Pool().get('sale.sale')
data = self.channel.get_tryton_action(magento_state)
if data['action'] in ['process_manually', 'process_automatically']:
Sale.quote([self])
Sale.confirm([self])
if data['action'] == 'process_automatically':
Sale.process([self])
示例7: transition_handle
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def transition_handle(self):
Purchase = Pool().get('purchase.purchase')
state = super(HandleInvoiceException, self).transition_handle()
purchase = Purchase(Transaction().context['active_id'])
invoice_lines = []
for invoice_line in purchase.invoice_lines:
if (invoice_line.invoice
and invoice_line.invoice.state == 'cancel'):
invoice_lines.append(invoice_line.id)
if invoice_lines:
Purchase.write([purchase], {
'invoice_lines_ignored': [('add', invoice_lines)],
})
Purchase.process([purchase])
return state
示例8: process_fba_order
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process_fba_order(self):
"""
Process FBA Orders as they are imported as past orders
and handle their shipments.
"""
Sale = Pool().get('sale.sale')
Shipment = Pool().get('stock.shipment.out')
Sale.quote([self])
Sale.confirm([self])
Sale.process([self])
for shipment in self.shipments:
if shipment.state == 'draft':
Shipment.wait([shipment])
if shipment.state == 'waiting':
Shipment.assign([shipment])
if shipment.state == 'assigned':
Shipment.pack([shipment])
if shipment.state == 'packed':
Shipment.done([shipment])
示例9: process_sale_using_magento_state
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process_sale_using_magento_state(self, magento_state):
"""
Process the sale in tryton based on the state of order
when its imported from magento
:param magento_state: State on magento the order was imported in
"""
Sale = Pool().get('sale.sale')
data = MagentoOrderState.get_tryton_state(magento_state)
# If order is canceled, just cancel it
if data['tryton_state'] == 'sale.cancel':
Sale.cancel([self])
return
# Order is not canceled, move it to quotation
Sale.quote([self])
Sale.confirm([self])
if data['tryton_state'] not in ['sale.quotation', 'sale.confirmed']:
Sale.process([self])
示例10: process
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def process(self, transaction):
"""
Given an amount this gateway should begin processing the payment.
Downstream modules can subclass the model and implemented different
payment gateway. If the payment requires the user to be redirected
to another site, then return a HTTP response object like the one
returned by redirect() function.
:param transaction: Active Record of the payment transaction
"""
PaymentTransaction = Pool().get('payment_gateway.transaction')
if self.method == 'manual':
return PaymentTransaction.process([transaction])
raise Exception('Not Implemented %s' % self.method)
示例11: model_copy
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import process [as 别名]
def model_copy(cls, subscription_id):
Cron = Pool().get('ir.cron')
History = Pool().get('training.subscription.history')
Invoice = Pool().get('account.invoice')
Sale = Pool().get('sale.sale')
SaleInvoice = Pool().get('sale.sale-account.invoice')
subscription = cls(subscription_id)
logger = logging.getLogger('training_subscription')
number_calls = subscription.number_calls
remaining = Cron.browse([subscription.cron.id])[0].number_calls
actual = number_calls - remaining + 1
model_id = subscription.model_source and subscription.model_source.id \
or False
if model_id:
Model = Pool().get(subscription.model_source.__name__)
default = {'state':'draft'}
#default['subscription_code'] = subscription.model_source.subscription_code + ' ' +str(actual)
default['subscription_code'] = subscription.model_source.subscription_code
try:
model = Model.copy([subscription.model_source], default)
except:
history_vals = {
'log': cls.raise_user_error(
error='error_creating',
error_args=subscription.model_source.__name__,
raise_exception=False)
}
else:
history_vals = {
'log': cls.raise_user_error(
error='created_successfully',
error_args=subscription.model_source.__name__,
raise_exception=False)
}
history_vals['document'] = (subscription.model_source.__name__,
model[0].id)
History.create([history_vals])
sales = Sale.search([
('id','=',model[0].id)
])
for sale in sales:
Sale.quote([sale])
Sale.confirm([sale])
Sale.process([sale])
saleinvoices = SaleInvoice.search([
('sale', '=', sale.id),
])
invoices = Invoice.search( [
('id','=',saleinvoices[0].invoice.id)
])
Invoice.write(invoices, {
'reference': sale.subscription_code,
'invoice_date': sale.sale_date,
})
Invoice.post(invoices)
if invoices:
for invoice in invoices:
cls.write([subscription],
{'sales': [('add', [sale.id])],
'invoices': [('add', [invoice.id])]
})
# If it is the last cron execution, set the state of the
# subscription to done
if remaining == 1:
subscription.write([subscription], {'state': 'done'})
else:
logger.error('Document in subscription %s not found.\n' % \
subscription.code)