本文整理汇总了Python中trytond.pool.Pool.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.delete方法的具体用法?Python Pool.delete怎么用?Python Pool.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, registrations):
Event = Pool().get('calendar.event')
for inpatient_registration in registrations:
if inpatient_registration.event:
Event.delete([inpatient_registration.event])
return super(InpatientRegistration, cls).delete(registrations)
示例2: round_down_total
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def round_down_total(cls, records):
'''
Round down total order price and add remaining amount as new sale line
'''
SaleLine = Pool().get('sale.line')
sale_lines = []
for record in records:
# Check if there's already a roundoff line, remove and create new
# if there is.
round_off_line = SaleLine.search([
('sale', '=', record.id),
('is_round_off', '=', True),
])
if round_off_line:
SaleLine.delete(round_off_line)
floored_total = floor(record.total_amount)
amount_diff = record.total_amount - Decimal(floored_total)
sale_lines.append({
'sale': record,
'is_round_off': True,
'type': 'line',
'quantity': -1,
'unit_price': amount_diff,
'description': 'Round Off'
})
SaleLine.create(
[line for line in sale_lines if line['unit_price']]
)
示例3: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, document_types):
"Delete records and remove associated triggers"
Trigger = Pool().get('ir.trigger')
triggers_to_delete = [dt.trigger for dt in document_types]
super(DocumentType, cls).delete(document_types)
Trigger.delete(triggers_to_delete)
示例4: cancel_move
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def cancel_move(cls, lines):
Move = Pool().get('stock.move')
Move.cancel([l.move for l in lines if l.move])
Move.delete([l.move for l in lines if l.move])
cls.write([l for l in lines if l.move], {
'move': None,
})
示例5: set_shares
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def set_shares(self, ids, name, value):
share_obj = Pool().get('webdav.share')
if not value:
return
attachments = self.browse(ids)
for action in value:
if action[0] == 'create':
for attachment in attachments:
action[1]['path'] = attachment.path
share_obj.create(action[1])
elif action[0] == 'write':
share_obj.write(action[1], action[2])
elif action[0] == 'delete':
share_obj.delete(action[1])
elif action[0] == 'delete_all':
paths = [a.path for a in attachments]
share_ids = share_obj.search([
('path', 'in', paths),
])
share_obj.delete(share_ids)
elif action[0] == 'unlink':
pass
elif action[0] == 'add':
pass
elif action[0] == 'unlink_all':
pass
elif action[0] == 'set':
pass
else:
raise Exception('Bad arguments')
示例6: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, appointments):
Event = Pool().get('calendar.event')
for appointment in appointments:
if appointment.event:
Event.delete([appointment.event])
return super(Appointment, cls).delete(appointments)
示例7: element
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def element(model, record_id):
"""
GET: Retrieve a representation of the member
PUT: Write to the record
DELETE: Delete the record
:param model: name of the model
:param record_id: ID of the record
"""
model = Pool().get(model, type='model')
record = model(record_id)
if request.method == 'GET':
# Return a dictionary of the read record
fields_names = request.args.getlist('fields_names')
return jsonify(
model.read([record.id], fields_names)[0]
)
elif request.method == 'PUT':
# Write to the record and return the updated record
model.write([record], request.json)
fields_names = request.args.getlist('fields_names')
return jsonify(
model.read([record.id], fields_names)[0]
)
elif request.method == 'DELETE':
model.delete([record])
return jsonify({}), 205
示例8: delete_from_cart
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete_from_cart(cls, line):
"""
Delete a line from the cart. The required argument in POST is:
line_id : ID of the line
Response: 'OK' if X-HTTPRequest else redirect to shopping cart
"""
SaleLine = Pool().get('sale.line')
cart = cls.open_cart()
if not cart.sale:
abort(404)
try:
sale_line, = SaleLine.search([
('id', '=', line),
('sale', '=', cart.sale.id),
])
except ValueError:
message = 'Looks like the item is already deleted.'
else:
SaleLine.delete([sale_line])
message = 'The order item has been successfully removed.'
flash(_(message))
if request.is_xhr:
return jsonify(message=message)
return redirect(url_for('nereid.cart.view_cart'))
示例9: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, records):
Event = Pool().get('calendar.event')
for record in records:
if record.event:
Event.delete([record.event_id])
return super(TransportRequest, cls).delete(records)
示例10: _borrar_productos_temporales
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def _borrar_productos_temporales(self, id_wizard_start='0'):
CalcularPapelProducto = Pool().get('sale_printery_budget.calcular_papel.producto')
productos_a_borrar = CalcularPapelProducto.search([('id_wizard', '=',
id_wizard_start)])
with Transaction().new_transaction() as transaction:
CalcularPapelProducto.delete(productos_a_borrar)
transaction.commit()
示例11: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, project_works):
TimesheetWork = Pool().get('timesheet.work')
# Get the timesheet works linked to the project works
timesheet_works = [pw.work for pw in project_works]
super(Work, cls).delete(project_works)
TimesheetWork.delete(timesheet_works)
示例12: clear_lines
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def clear_lines(cls, assets):
Line = Pool().get('account.asset.line')
lines_to_delete = []
for asset in assets:
for line in asset.lines:
if not line.move or line.move.state != 'posted':
lines_to_delete.append(line)
Line.delete(lines_to_delete)
示例13: cancelada
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def cancelada(cls, publ):
line = Pool().get('sale.line')
for p in publ:
try:
linea = p.linea
p.linea=None
p.save()
line.delete([linea])
except:
pass
示例14: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, lines):
Selection = Pool().get('analytic_account.account.selection')
selections = []
for line in lines:
if line.analytic_accounts:
selections.append(line.analytic_accounts)
super(SaleLine, cls).delete(lines)
Selection.delete(selections)
示例15: delete
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import delete [as 别名]
def delete(cls, lines):
Selection = Pool().get('analytic_account.account.selection')
selection_ids = []
for line in lines:
if line.analytic_accounts:
selection_ids.append(line.analytic_accounts.id)
super(InvoiceLine, cls).delete(lines)
Selection.delete(Selection.browse(selection_ids))