本文整理汇总了Python中trytond.pool.Pool.post方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.post方法的具体用法?Python Pool.post怎么用?Python Pool.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trytond.pool.Pool
的用法示例。
在下文中一共展示了Pool.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_move
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def create_move(self, date=None):
"""
Create the account move for the payment
:param date: Optional date for the account move
:return: Active record of the created move
"""
Currency = Pool().get('currency.currency')
Period = Pool().get('account.period')
Move = Pool().get('account.move')
journal = self.gateway.journal
date = date or self.date
if not journal.debit_account:
self.raise_user_error('missing_debit_account', (journal.rec_name,))
period_id = Period.find(self.company.id, date=date)
amount_second_currency = second_currency = None
amount = self.amount
if self.currency != self.company.currency:
amount = Currency.compute(
self.currency, self.amount, self.company.currency
)
amount_second_currency = self.amount
second_currency = self.currency
lines = [{
'description': self.rec_name,
'account': self.credit_account.id,
'party': self.party.id,
'debit': Decimal('0.0'),
'credit': amount,
'amount_second_currency': amount_second_currency,
'second_currency': second_currency,
}, {
'description': self.rec_name,
'account': journal.debit_account.id,
'debit': amount,
'credit': Decimal('0.0'),
'amount_second_currency': amount_second_currency,
'second_currency': second_currency,
}]
move, = Move.create([{
'journal': journal.id,
'period': period_id,
'date': date,
'lines': [('create', lines)],
'origin': '%s,%d' % (self.__name__, self.id),
}])
Move.post([move])
# Set the move as the move of this transaction
self.move = move
self.save()
return move
示例2: transition_pay_
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def transition_pay_(self):
result = super(WizardSalePayment, self).transition_pay_()
Sale = Pool().get('sale.sale')
sale = Sale(Transaction().context['active_id'])
Invoice = Pool().get('account.invoice')
AFIP_Transaction = Pool().get('account_invoice_ar.afip_transaction')
if sale.invoices:
for invoice in sale.invoices:
if invoice.state == 'draft':
invoice.description = sale.reference
invoice.reference = sale.reference
invoice_id = invoice.id
Invoice.post([invoice])
#afip_transaction = AFIP_Transactions.search(['invoice','=',invoice_id])
#with Transaction().new_cursor():
#for transaction in afip_transaction:
#transaction.sale = sale.id
#Transaction().cursor.commit()
for payment in sale.payments:
invoice = sale.invoices[0]
payment.invoice = invoice.id
if payment.party != invoice.party:
payment.party = invoice.party
payment.save()
Sale.workflow_to_end([sale])
return result
示例3: transition_create_move
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def transition_create_move(self):
Move = Pool().get('account.move')
if self.show_move.counterpart == self.show_move.stock_account:
self.raise_user_error('same_account')
move = self.get_move()
move.save()
Move.post([move])
return 'update_price'
示例4: paid
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def paid(cls, recibos):
Move = Pool().get('account.move')
moves = []
for recibo in recibos:
moves.append(recibo.create_paid_move())
cls.write(recibos, {
'state': 'paid',
})
Move.post(moves)
示例5: confirmed
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def confirmed(cls, recibos):
Move = Pool().get('account.move')
moves = []
for recibo in recibos:
recibo.set_number()
moves.append(recibo.create_confirmed_move())
cls.write(recibos, {
'state': 'confirmed',
})
Move.post(moves)
示例6: post
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def post(cls, invoices):
Move = Pool().get('account.move')
moves = []
for invoice in invoices:
if invoice.type == u'out_invoice' or invoice.type == u'out_credit_note':
if not invoice.invoice_type:
invoice.raise_user_error('not_invoice_type')
invoice.set_number()
moves.append(invoice.create_move())
cls.write(invoices, {'state': 'posted',})
Move.post(moves)
for invoice in invoices:
if invoice.type in ('out_invoice', 'out_credit_note'):
invoice.print_invoice()
示例7: confirmed
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def confirmed(cls, recibos):
Move = Pool().get('account.move')
moves = []
for recibo in recibos:
recibo.journal = Pool().get('account.journal').search([('code','=','EXP')])[0]
recibo.save()
recibo.set_number()
moves.append(recibo.create_confirmed_move())
cls.write(recibos, {
'state': 'confirmed',
})
Move.post(moves)
示例8: transition_debit
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def transition_debit(self):
IssuedCheck = Pool().get('account.issued.check')
Move = Pool().get('account.move')
MoveLine = Pool().get('account.move.line')
period_id = Pool().get('account.period').find(1,
date=self.start.date)
for check in IssuedCheck.browse(Transaction().context.get(
'active_ids')):
if check.state != 'issued':
self.raise_user_error('check_not_issued',
error_args=(check.name,))
if not self.start.bank_account.journal.issued_check_account:
self.raise_user_error('no_journal_check_account',
error_args=(self.start.bank_account.journal.name,))
move, = Move.create([{
'journal': self.start.bank_account.journal.id,
'period': period_id,
'date': self.start.date,
}])
lines = []
lines.append({
'debit': check.amount,
'credit': Decimal('0.00'),
'account':
self.start.bank_account.journal.issued_check_account.id,
'move': move.id,
'journal': self.start.bank_account.journal.id,
'period': period_id,
'party': check.receiving_party.id,
})
lines.append({
'account': self.start.bank_account.journal.debit_account.id,
'debit': Decimal('0.00'),
'credit': check.amount,
'move': move.id,
'journal': self.start.bank_account.journal.id,
'period': period_id,
'date': self.start.date,
'party': check.receiving_party.id
})
MoveLine.create(lines)
IssuedCheck.write([check], {'state': 'debited'})
Move.post([move])
return 'end'
示例9: close
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def close(cls, assets, account=None):
"""
Close the assets.
If account is provided, it will be used instead of the expense account.
"""
Move = Pool().get('account.move')
cls.clear_lines(assets)
moves = []
for asset in assets:
move = asset.get_closing_move(account)
move.save()
moves.append(move)
cls.write([asset], {
'move': move.id,
})
Move.post(moves)
示例10: post
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def post(cls, invoices):
Move = Pool().get('account.move')
cls.set_number(invoices)
moves = []
for invoice in invoices:
move = invoice.get_move()
if move != invoice.move:
invoice.move = move
moves.append(move)
if invoice.state != 'posted':
invoice.state = 'posted'
#invoice.state = invoice.update_invoice_status()
if moves:
Move.save(moves)
cls.save(invoices)
Move.post([i.move for i in invoices if i.move.state != 'posted'])
示例11: create_invoice
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def create_invoice(self, invoice_type):
"""
Sale creates draft invoices. But if the invoices are created from
shipments, then they should be automatically opened
"""
Invoice = Pool().get('account.invoice')
invoice = super(Sale, self).create_invoice(invoice_type)
if not invoice:
return invoice
if self.invoice_method == 'shipment' and invoice_type == 'out_invoice':
# Invoices created from shipment can be automatically opened
# for payment.
Invoice.post([invoice])
return invoice
示例12: post
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def post(cls, invoices):
Move = Pool().get('account.move')
moves = []
for invoice in invoices:
if invoice.type == u'out_invoice' or invoice.type == u'out_credit_note':
invoice.check_invoice_type()
if invoice.pos:
if invoice.pos.pos_type == 'electronic':
invoice.do_pyafipws_request_cae()
if not invoice.pyafipws_cae:
invoice.raise_user_error('not_cae')
invoice.set_number()
moves.append(invoice.create_move())
cls.write(invoices, {
'state': 'posted',
})
Move.post(moves)
示例13: transition_held
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def transition_held(self):
ThirdCheck = Pool().get('account.third.check')
Move = Pool().get('account.move')
MoveLine = Pool().get('account.move.line')
Date = Pool().get('ir.date')
date = Date.today()
period_id = Pool().get('account.period').find(1, date)
for check in ThirdCheck.browse(
Transaction().context.get('active_ids')):
if check.state != 'draft':
self.raise_user_error('check_not_draft',
error_args=(check.name,))
else:
move, = Move.create([{
'journal': self.start.journal.id,
'period': period_id,
'date': date,
}])
lines = []
lines.append({
'account': self.start.journal.third_check_account.id,
'move': move.id,
'journal': self.start.journal.id,
'period': period_id,
'debit': check.amount,
'credit': Decimal('0.0'),
'date': date,
'maturity_date': check.date,
})
lines.append({
'account': self.start.journal.credit_account.id,
'move': move.id,
'journal': self.start.journal.id,
'period': period_id,
'debit': Decimal('0.0'),
'credit': check.amount,
'date': date,
})
MoveLine.create(lines)
ThirdCheck.write([check], {'state': 'held'})
Move.post([move])
return 'end'
示例14: do_pay
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def do_pay(self, action):
Line = Pool().get('account.move.line')
Move = Pool().get('account.move')
sort_key = lambda line: (line.party, line.account)
# Sorted by party after removing lines without party
move_lines = sorted(
filter(
lambda line: line.party,
Line.browse(Transaction().context['active_ids'])
),
key=sort_key
)
moves = []
for party_account, lines in groupby(move_lines, key=sort_key):
lines = list(lines)
move = self.get_move(lines, *party_account)
move.save()
moves.append(move)
# Reconcile the lines
Line.reconcile(
lines + [line for line in move.lines if line.party]
)
move_ids = map(int, moves)
self.start.moves = moves
# Post all the moves
Move.post(moves)
# Assign Check Number to all moves
Move.assign_check_number(moves)
data = {
'moves': move_ids,
'journal': self.start.journal.id,
}
return action, data
示例15: _create_account_stock_move
# 需要导入模块: from trytond.pool import Pool [as 别名]
# 或者: from trytond.pool.Pool import post [as 别名]
def _create_account_stock_move(self):
'''
Create account move for stock move
'''
AccountMove = Pool().get('account.move')
if self.product.type != 'goods':
return
type_ = self._get_account_stock_move_type()
if not type_:
return
assert not self.account_move, 'account move field not empty'
if type_ == 'supplier_customer':
account_move_lines = self._get_account_stock_move_lines(
'in_supplier')
account_move_lines.extend(self._get_account_stock_move_lines(
'out_customer'))
elif type_ == 'customer_supplier':
account_move_lines = self._get_account_stock_move_lines(
'in_customer')
account_move_lines.extend(self._get_account_stock_move_lines(
'out_supplier'))
else:
account_move_lines = self._get_account_stock_move_lines(type_)
amount = Decimal('0.0')
for line in account_move_lines:
amount += line.debit - line.credit
move_line = self._get_account_stock_move_line(amount)
if move_line:
account_move_lines.append(move_line)
account_move = self._get_account_stock_move(account_move_lines)
account_move.save()
with Transaction().set_user(0, set_context=True):
AccountMove.post([account_move])
self.write([self], {
'account_move': account_move.id,
})
return account_move