我有这个型号:
class paymentTerm(models.Model):
_inherit = 'account.payment.term'
dte_sii_code = fields.Selection((
('1', '1: Contado'),
('2', '2: Credito'),
('3', '3: Otro')), 'DTE Sii Code', )
我想从另一个模块中为这个选择添加一些字段,如下所示:
class paymentTerm(models.Model):
_inherit = 'account.payment.term'
dte_sii_code = fields.Selection(selection_add=[('1', 'COB1'),('2','COBRANZA'),('11','ACRED'),('12','CBOF'),('21','S/PAGO'),('32','ANTICIPO')])
但是当我尝试将此应用到我的模块时,Odoo服务器就把这个扔给我:
2016-11-25 02:04:06,338 13570 ERROR odoo_solti_ultima openerp.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/registry.py", line 386, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/loading.py", line 340, in load_modules
registry.setup_models(cr)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/registry.py", line 197, in setup_models
model._setup_base(cr, SUPERUSER_ID, partial)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 354, in old_api
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/models.py", line 3019, in _setup_base
self._add_field(name, field.new())
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/models.py", line 471, in _add_field
field.setup_base(self, name)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/fields.py", line 406, in setup_base
self._setup_attrs(model, name)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/fields.py", line 1498, in _setup_attrs
self.selection = OrderedDict(self.selection + selection_add).items()
TypeError: can only concatenate tuple (not "list") to tuple
有关于此的任何想法吗?
我认为这与原始模型有关,但我不太确定
我正在Odoo v9社区工作。
答案 0 :(得分:2)
选择数据类型采用元组列表。您已使用元组声明 dte_sii_code 。它应该是元组列表
尝试使用以下代码。
class paymentTerm(models.Model):
_inherit = 'account.payment.term'
dte_sii_code = fields.Selection([
('1', '1: Contado'),
('2', '2: Credito'),
('3', '3: Otro')], 'DTE Sii Code')
class paymentTerm(models.Model):
_inherit = 'account.payment.term'
dte_sii_code = fields.Selection(selection_add=[('4', 'COB1'),
('5','COBRANZA'),
('11','ACRED'),
('12','CBOF'),
('21','S/PAGO'),
('32','ANTICIPO')])
注:
我们应该关心关键。如果使用相同的键添加元组,则它将使用新定义覆盖。