![](/img/trans.png)
[英]TypeError: cannot concatenate 'str' and 'function' objects - Odoo v10 community
[英]_constraints, cannot create refund invoice Odoo v10 community
我有这个约束:
_constraints = [
(_unique_invoice_per_partner,
_('The Document you have been entering for this Partner has already'
' been recorded'),
['Control Number (nro_ctrl)', 'Reference (reference)']),
]
关于这个领域:
nro_ctrl = fields.Char(
string='Control Number', size=32, readonly=True, required=True,
states={'draft': [('readonly', False)]},
help="Number used to manage pre-printed invoices, by law you will"
" need to put here this number to be able to declarate on"
" Fiscal reports correctly.")
如果创建发票,验证并付款(此字段在account.invoice
模型中),则此约束有效。
但是,如果我创建了退款,那么它说一个字段设置不正确:
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a record while other records still reference it
- creation/update: a mandatory field is not correctly set
[object with reference: nro_ctrl - nro.ctrl]
我也有这种方法,理论上应该允许“复制”或复制发票,其中包括以下字段:
@api.multi
def copy(self, default=None):
""" Allows you to duplicate a record,
child_ids, nro_ctrl and reference fields are
cleaned, because they must be unique
"""
# NOTE: Use argument name ids instead of id for fix the pylint error
# W0621 Redefining buil-in 'id'
#if default is None:
#default = {}
default = self._context.copy() #default.copy()
default.update({
'nro_ctrl': None,
'supplier_invoice_number': None,
'sin_cred': False,
# No cleaned in this copy because it is related to the previous
# document, if previous document says so this too
'date_document': False,
'invoice_printer': '',
'fiscal_printer': '',
# No cleaned in this copy because it is related to the previous
# document, if previous document says so this too
# loc_req':False,
'z_report': '',
})
return super(AccountInvoice, self).copy(default)
这是我正在从v8社区迁移到v10社区的结果。
我不知道是否需要这种copy
方法。
如何在考虑这一限制的情况下创建退款? 我的意思是,将nro_ctrl
字段与之对应。
有任何想法吗?
您已经创建了新字段nro_ctrl,并且已经在py文件中写入了required = True 。
当您在py文件中写入必填字段时,则在Database表中是必填字段 。
在复制方法中,您正在更新'nro_ctrl':无 。 因此,由于在必填字段中没有值,因此您在创建时会出错。
如果发票中需要nro_ctrl字段,那么您必须在退款的复制方法中提供唯一值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.