- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这两种方法:
@api.multi
def new_open_window(self, list_ids, xml_id, module):
""" Generate new window at view form or tree
"""
mod_obj = self.env['ir.model.data']
act_obj = self.env['ir.actions.act_window']
result = mod_obj._get_id(module, xml_id)
imd_id = mod_obj.browse(result, ['res_id'])
result = act_obj.browse(imd_id)
result['res_id'] = list_ids
return result
@api.multi
def create_invoice(self):
""" Create a invoice refund
"""
#context = context or {}
wizard_brw = self.browse()
inv_id = self._context.get('active_id')
for wizard in wizard_brw:
if not wizard.sure:
raise UserError(
_("Validation error!"),
_("Please confirm that you know what you're doing by"
" checking the option bellow!"))
if (wizard.invoice_id and wizard.invoice_id.company_id.jour_id and
wizard.invoice_id and wizard.invoice_id.company_id.acc_id):
inv_id = self.action_invoice_create(wizard,
wizard.invoice_id)
else:
raise UserError(
_('Validation error!'),
_("You must go to the company form and configure a journal"
" and an account for damaged invoices"))
return self.new_open_window([inv_id],
'action_invoice_tree1', 'account')
这些方法最初是这样的(在 v8 上):
def new_open_window(self, cr, uid, ids, list_ids, xml_id, module,
context=None):
""" Generate new window at view form or tree
"""
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, module, xml_id)
imd_id = mod_obj.read(cr, uid, result, ['res_id'])['res_id']
result = act_obj.read(cr, uid, imd_id)
result['res_id'] = list_ids
return result
def create_invoice(self, cr, uid, ids, context=None):
""" Create a invoice refund
"""
context = context or {}
wizard_brw = self.browse(cr, uid, ids, context=context)
inv_id = context.get('active_id')
for wizard in wizard_brw:
if not wizard.sure:
raise osv.except_osv(
_("Validation error!"),
_("Please confirm that you know what you're doing by"
" checking the option bellow!"))
if (wizard.invoice_id and wizard.invoice_id.company_id.jour_id and
wizard.invoice_id and wizard.invoice_id.company_id.acc_id):
inv_id = self.action_invoice_create(cr, uid, ids, wizard,
wizard.invoice_id, context)
else:
raise osv.except_osv(
_('Validation error!'),
_("You must go to the company form and configure a journal"
" and an account for damaged invoices"))
return self.new_open_window(cr, uid, ids, [inv_id],
'action_invoice_tree1', 'account')
这些方法应读取发票(之前在弹出窗口中选择),然后单击按钮,将此发票重写为已取消的发票,发票名称上带有“PAPEL ANULADO”。 create_invoice
方法调用另一个名为 action_invoice_create
的方法。
这是迁移后的方法:
@api.multi
def action_invoice_create(self, wizard_brw, inv_brw): #cr, uid, ids, wizard_brw, inv_brw, context=None
"""
If the invoice has control number, this function is responsible for
passing the bill to damaged paper
@param wizard_brw: nothing for now
@param inv_brw: damaged paper
"""
invoice_line_obj = self.env['account.invoice.line']
invoice_obj = self.env['account.invoice']
acc_mv_obj = self.env['account.move']
acc_mv_l_obj = self.env['account.move.line']
tax_obj = self.env['account.invoice.tax']
invoice = {}
if inv_brw.nro_ctrl:
invoice.update({
'name': 'PAPELANULADO_NRO_CTRL_%s' % (
inv_brw.nro_ctrl and inv_brw.nro_ctrl or ''),
'state': 'paid',
'tax_line': [],
})
else:
raise UserError(
_('Validation error!'),
_("You can run this process just if the invoice have Control"
" Number, please verify the invoice and try again."))
invoice_obj.write([inv_brw.id], invoice) #cr, uid, [inv_brw.id], invoice, context=context
for line in inv_brw.invoice_line:
invoice_line_obj.write(
[line.id],
{'quantity': 0.0, 'invoice_line_tax_id': [],
'price_unit': 0.0}) #cr, uid, context=context
tax_ids = self.env['account.tax'].search([]) # cr, uid, [], context=context
tax = tax_obj.search([('invoice_id', '=', inv_brw and inv_brw.id)]) # cr, uid, contet=context
if tax:
tax_obj.write(tax[0], {'invoice_id': []}) #cr, uid, tax[0], {'invoice_id': []}, context=context
tax_obj.create({
'name': 'SDCF',
'tax_id': tax_ids and tax_ids[0],
'amount': 0.00,
'tax_amount': 0.00,
'base': 0.00,
'account_id': inv_brw.company_id.acc_id.id,
'invoice_id': inv_brw and inv_brw.id}, {}) #cr ,uid, was first
move_id = inv_brw.move_id and inv_brw.move_id.id
if move_id:
acc_mv_obj.button_cancel([inv_brw.move_id.id]) #cr, uid, [inv_brw.move_id.id], context=context
acc_mv_obj.write([inv_brw.move_id.id],{'ref': 'Damanged Paper'}) #cr, uid, [inv_brw.move_id.id],{'ref': 'Damanged Paper'}, context=context
acc_mv_l_obj.unlink([i.id for i in inv_brw.move_id.line_id]) #cr, uid was first
return inv_brw.id
我实际上不太确定这是否应该是@api.multi
我认为它应该是@api.model
虽然我不太确定。
无论如何,当我单击 create_invoice
方法时,它会抛出以下错误:
Traceback (most recent call last):
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 638, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 675, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 331, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 324, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 933, in __call__
return self.method(*args, **kw)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 504, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 866, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/web/controllers/main.py", line 854, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 681, in call_kw
return call_kw_multi(method, model, args, kwargs)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/api.py", line 672, in call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_invoice_nro_ctrl.py", line 134, in create_invoice
'action_invoice_tree1', 'account')
File "/home/kristian/odoov10/gilda/l10n_ve_fiscal_requirements/wizard/wizard_invoice_nro_ctrl.py", line 106, in new_open_window
imd_id = mod_obj.browse(result, ['res_id'])
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 4755, in browse
return self._browse(ids, self.env, prefetch)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/models.py", line 4742, in _browse
prefetch[cls._name].update(ids)
TypeError: list indices must be integers, not str
错误出现在这一行imd_id = mod_obj.browse(result, ['res_id'])
,而这一行return self.new_open_window([inv_id], 'action_invoice_tree1', '帐户')
之前,imd_id
使用的是read()
,我已将其更改为browse()
,但仍然出现同样的错误。
我希望我已经解释清楚了。
如果您需要更多信息,请告诉我。
有什么想法吗?
最佳答案
当您使用浏览记录时,您不会传递您希望获取的字段。
ids = [6]
rec = self.env['your.model'].browse(ids)['field_name']
关于python - TypeError : list indices must be integers, not str - Odoo v8 到 Odoo v10 社区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42965467/
我正在尝试执行 JavaPairRDD 和 JavaPairRDD 的 leftOuterJoin> 并且函数签名返回类型是 JavaPairRDD>>> 这里可选的是 com.google.comm
我正在尝试按元素的频率对元素进行排序 import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt
这个问题已经有答案了: Is List a subclass of List? Why are Java generics not implicitly polymorphic? (19 个回答) 已
编辑:问题已解决:请参阅 Karim SNOUSSI 的答案和我在下面的评论。 这是我在堆栈溢出时遇到的第一个问题,所以我可能不会一开始就把所有事情都做对。对此感到抱歉。此外,我对 Java 和一般
#include #include using namespace std; class Integer { public: int i; Integer (int ll
我不明白: ArrayList list = new ArrayList(); Collection list1 = new ArrayList(); 类 ArrayList扩展实现接口(interf
我编写了:。它成功了。我不知道为什么?
我编写了:。它成功了。我不知道为什么
我编写了:。它成功了。我不知道为什么?
Collectors.counting()返回 long此方法中每个键的值: private static Map countDuplicates(HashSet cards) { retur
我正在尝试通过搜索旧元素并将其替换为新元素来更新节点的元素。但是有一个我不明白的错误。是什么导致我的代码出现该错误,我该如何解决?错误; The method update(Integer, Inte
我有一个称为 client 的表,其中有一列称为created_time ,所以实际上我想绘制一个 map ,以便我可以知道在哪一年和哪一个月添加了多少客户?现在的要求是假设在 2018 年 11 月
这个问题已经有答案了: Is Java "pass-by-reference" or "pass-by-value"? (91 个回答) 已关闭 8 年前。 我对 ArrayList Collecti
我意识到下面的代码是正确的 Integer.MIN_VALUE == -Integer.MIN_VALUE == Math.abs(Integer.MIN_VALUE) 这是因为当我们取反-21474
我有以下类 AccountWebappGridRow,它扩展了 AccountGridRow: public class AccountWebappGridRow extends AccountGri
我正在学习 Haskell 并看到了函数组合。 尝试复合 map和 foldl mapd = (map.foldl) 比 test = (mapd (\x y -> x + y ) [1,2,3,4]
我有两个相同大小的数组和两个方法。 public class Client { private static int[] ints; private static final int
我喜欢 Java 8 中的 Streams 概念。现在我想借助 Java Streams 将 Java 中的 Map 转换为排序列表。我只想显示列表而不将其存储在任何地方。我希望在结果列表中有这个输出
我有一个数据库表,其中包含电视节目类型列表和关联的 ARGB 颜色值,用于在显示电视指南时突出显示 Android ListView 中的电视节目。流派表看起来像这样... id genre
我有一个 Integer 类,它应该模拟一个整数 mod n。因此,它具有如下构造函数: Integer::Integer(int x) : m(x), n(0) { } Integer::I
我是一名优秀的程序员,十分优秀!