1.在全局声明变量code=''
函数要写return,把经过计算的值返回出来
def parse_code(self, vals, model, key, state=None):
"""解析客商编号"""
cus_partner_code = self.env['ir.sequence'].sudo().next_by_code(model)
location_code = self.env['res.country.state'].sudo().browse(vals.get('state_id'))
code = ''
if state:
code = '.' + state.code + '.'
elif location_code:
code = '.' + location_code.code + '.'
vals[key] = cus_partner_code.replace('.', code)
return vals
2.field 标签中name参数写在开头
options='{"no_quick_create":True, "no_create_edit":True}'
让下拉框中的创建并编辑选项消失
<field name="state_id" options='{"no_open": True, "no_quick_create":True, "no_create_edit": True}' placeholder="省"/>
3.如果有值就改为可读状态
<field name="customer" attrs="{'readonly':[('customer_code','!=',False)]}"/>
4.git相关
提交代码前,先pull,再推上去
git checkout -b optimize 切换分支到optimize
git rm -r --cached 文件名
search():搜索视图中调用
search_count():视图中计算记录数时调用
name_search():many2one字段搜索时调用
search_read():many2one点开搜索更多时调用
read_group():搜索视图分组时调用
网友评论