我正在使用我正在改编的Odoo v9模块,以获得借记/贷记通知。
我正在修复它的错误,到目前为止,我现在有这个问题,关于这个功能:
def compute_refund(self, cr, uid, ids, mode='refund', context=None):
"""@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: the account invoice refund’s ID or list of IDs
"""
inv_obj = self.pool.get('account.invoice')
reconcile_obj = self.pool.get('account.move.reconcile')
account_m_line_obj = self.pool.get('account.move.line')
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
inv_tax_obj = self.pool.get('account.invoice.tax')
inv_line_obj = self.pool.get('account.invoice.line')
res_users_obj = self.pool.get('res.users')
if context is None:
context = {}
for form in self.browse(cr, uid, ids, context=context):
created_inv = []
date = False
period = False
description = False
company = res_users_obj.browse(
cr, uid, uid, context=context).company_id
journal_id = form.journal_id.id
for inv in inv_obj.browse(cr, uid, context.get('active_ids'),
context=context):
if inv.state in ['draft', 'proforma2', 'cancel']:
raise osv.except_osv(_('Error!'), _(
'Cannot %s draft/proforma/cancel invoice.') % (mode))
if inv.reconciled and mode in ('cancel', 'modify'):
raise osv.except_osv(_('Error!'), _(
'Cannot %s invoice which is already reconciled, '
'invoice should be unreconciled first. You can only '
'refund this invoice.') % (mode))
if form.period.id:
period = form.period.id
else:
period = inv.period_id and inv.period_id.id or False
if not journal_id:
journal_id = inv.journal_id.id
if form.date:
date = form.date
if not form.period.id:
cr.execute("select name from ir_model_fields \
where model = 'account.period' \
and name = 'company_id'")
result_query = cr.fetchone()
if result_query:
cr.execute("""select p.id from account_fiscalyear y
, account_period p
where y.id=p.fiscalyear_id \
and date(%s) between p.date_start AND
p.date_stop and y.company_id = %s limit 1""",
(date, company.id,))
else:
cr.execute("""SELECT id
from account_period where date(%s)
between date_start AND date_stop \
limit 1 """, (date,))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
if form.description:
description = form.description
else:
description = inv.name
if not period:
raise osv.except_osv(_('Insufficient Data!'),
_('No period found on the invoice.'))
refund_id = inv_obj.refund(cr, uid, [
inv.id], date, period,
description, journal_id,
context=context)
refund = inv_obj.browse(cr, uid, refund_id[0], context=context)
# Add parent invoice
inv_obj.write(cr, uid, [refund.id],
{'date_due': date,
'check_total': inv.check_total,
'parent_id': inv.id})
inv_obj.button_compute(cr, uid, refund_id)
created_inv.append(refund_id[0])
if mode in ('cancel', 'modify'):
movelines = inv.move_id.line_id
to_reconcile_ids = {}
for line in movelines:
if line.account_id.id == inv.account_id.id:
to_reconcile_ids[line.account_id.id] = [line.id]
if type(line.reconcile_id) != osv.orm.browse_null:
reconcile_obj.unlink(cr, uid, line.reconcile_id.id)
refund.signal_workflow('invoice_open')
#wf_service.trg_validate(uid, 'account.invoice',
#refund.id, 'invoice_open', cr)
refund = inv_obj.browse(
cr, uid, refund_id[0], context=context)
for tmpline in refund.move_id.line_id:
if tmpline.account_id.id == inv.account_id.id:
to_reconcile_ids[
tmpline.account_id.id].append(tmpline.id)
for account in to_reconcile_ids:
account_m_line_obj.reconcile(
cr, uid, to_reconcile_ids[account],
writeoff_period_id=period,
writeoff_journal_id=inv.journal_id.id,
writeoff_acc_id=inv.account_id.id
)
if mode == 'modify':
invoice = inv_obj.read(cr, uid, [inv.id],
['name', 'type', 'number',
'reference', 'comment',
'date_due', 'partner_id',
'partner_insite',
'partner_contact',
'partner_ref', 'payment_term',
'account_id', 'currency_id',
'invoice_line', 'tax_line',
'journal_id', 'period_id'],
context=context)
invoice = invoice[0]
del invoice['id']
invoice_lines = inv_line_obj.browse(
cr, uid, invoice['invoice_line'], context=context)
invoice_lines = inv_obj._refund_cleanup_lines(
cr, uid, invoice_lines, context=context)
tax_lines = inv_tax_obj.browse(
cr, uid, invoice['tax_line'], context=context)
tax_lines = inv_obj._refund_cleanup_lines(
cr, uid, tax_lines, context=context)
invoice.update({
'type': inv.type,
'date_invoice': date,
'state': 'draft',
'number': False,
'invoice_line': invoice_lines,
'tax_line': tax_lines,
'period_id': period,
'name': description,
'origin': self._get_orig(cr, uid, inv, context={}),
})
for field in (
'partner_id', 'account_id', 'currency_id',
'payment_term', 'journal_id'):
invoice[field] = invoice[
field] and invoice[field][0]
inv_id = inv_obj.create(cr, uid, invoice, {})
if inv.payment_term.id:
data = inv_obj.onchange_payment_term_date_invoice(
cr, uid, [inv_id], inv.payment_term.id, date)
if 'value' in data and data['value']:
inv_obj.write(cr, uid, [inv_id], data['value'])
created_inv.append(inv_id)
xml_id = (inv.type == 'out_refund') and 'action_invoice_tree1' or \
(inv.type == 'in_refund') and 'action_invoice_tree2' or \
(inv.type == 'out_invoice') and 'action_invoice_tree3' or \
(inv.type == 'in_invoice') and 'action_invoice_tree4'
result = mod_obj.get_object_reference(cr, uid, 'account', xml_id)
id = result and result[1] or False
result = act_obj.read(cr, uid, id, context=context)
invoice_domain = eval(result['domain'])
invoice_domain.append(('id', 'in', created_inv))
result['domain'] = invoice_domain
return result
每当我尝试退款发票时,都会抛出此错误:
Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 646, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 319, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 312, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 962, in __call__
return self.method(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/http.py", line 512, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/web/controllers/main.py", line 901, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/web/controllers/main.py", line 889, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/debit_credit_note/wizard/account_invoice_refund.py", line 280, in invoice_refund
return self.compute_refund(cr, uid, ids, data_refund, context=context)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20160712/openerp/addons/debit_credit_note/wizard/account_invoice_refund.py", line 130, in compute_refund
journal_id = form.journal_id.id
AttributeError: 'account.invoice.refund' object has no attribute 'journal_id'
我在journal_obj = self.pool.get('account.journal')
之后将此行添加到逻辑res_users_obj = self.pool.get('res.users')
但仍然得到相同的错误,我想我需要为此操作加载account.jounal对象,但是使用此行我仍然做不到。
有人可以对此有所了解吗?
如果您需要更多信息,请告诉我。
提前致谢!
答案 0 :(得分:2)
激活开发者模式,转到设置 - >技术 - >数据库结构 - >模型和搜索account.invoice.refund
然后检查此模型是否有任何名为journal_id
的字段。我可以看到这个字段存在于v8上,但在v9上不存在。
您可以在runbot.odoo.com admin / admin
上查看此内容