在我的模块中,我有以下many2one字段:
'xx_insurance_type': fields.many2one('xx.insurance.type', string='Insurance')
其中,xx.insurance.type
如下:
class InsuranceType(osv.Model):
_name='xx.insurance.type'
_columns = {
'name' : fields.char(size=128, string = 'Name'),
'sale_ids': fields.one2many('sale.order', 'xx_insurance_type', string = 'Sale orders'),
'insurance_percentage' : fields.float('Insurance cost in %')
}
Run Code Online (Sandbox Code Playgroud)
我知道many2one字段将名称字段作为其显示名称,但我希望它使用name
和insurance_percentage
的形式的组合name + " - " + insurance_percentage + "%"
我读过最好覆盖get_name
方法,所以我尝试了以下方法:
def get_name(self,cr, uid, ids, context=None):
if context is None:
context = {}
if isinstance(ids, (int, long)):
ids = [ids]
res = []
for record in self.browse(cr, uid, ids, …
Run Code Online (Sandbox Code Playgroud) 我正在寻找一个查询(lucene、fts-alfresco 或 ...)来返回所有具有特定子关联(不为空)的文档。
一些上下文:
类型的文档abc:document
有一个 child-association abc:linkedDocument
。并非所有文件都有其他文件链接到它们,有些文件没有,有些文件有一个或多个。
我需要一种快速简便的方法来概览所有至少有一个文档链接到它们的文档。
目前我有一个 webscript 可以满足我的需求,但不想拥有大量与业务无关的 webscript。
代码:
SearchParameters sp = new SearchParameters();
String query = "TYPE:\"abc:document\"";
StoreRef store = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
sp.addStore(store);
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQuery(query);
ResultSet rs = services.getSearchService().query(sp);
List<NodeRef> nodeRefs = rs.getNodeRefs();
for (NodeRef ref : nodeRefs) {
List<ChildAssociationRef> refs = services.getNodeService().getChildAssocs(ref);
for(ChildAssociationRef chref : refs){
if(chref.getQName().equals(AbcModel.ASSOC_LINKED_DOC)){
logger.debug("Document with linked doc: {}", ref);
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 嗨,我刚开始用C ++编程,从我的cpp文件的头文件访问变量时遇到问题。
在我的标头(Vector.h)中,
class Vector {
public:
double x, y, z;
Vector cross(const Vector & v);
}
Run Code Online (Sandbox Code Playgroud)
我的cpp文件(Vector.cpp)
#include "Vector.h"
Vector cross(const Vector & v){
double x2 = y*v.z-z*v.y;
double y2 = -x*v.z+z*v.x;
double z2 = x*v.y-y*v.x;
return Vector(x2, y2, z2);
}
Run Code Online (Sandbox Code Playgroud)
这给出了一个Symbol 'x' could not be resolved
错误(与y和z相同)。我如何分辨x,y,z是头文件中的变量?