odoo合同模块开发所需要方法
Posted 行走在云端
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了odoo合同模块开发所需要方法相关的知识,希望对你有一定的参考价值。
# 创建按钮
def action_view_sigining_contract(self, cr, uid, ids, context=None):
if not context:
context = {}
selfobj=self.browse(cr,uid,ids[0],context=context)
pickobj=self.pool(\'sigining.contract\')
传值
ctx={\'default_contract_type\':selfobj.lx_type,\'default_name\':selfobj.name.id,\'default_display_name\':selfobj.display_name.id}
mod_obj = self.pool.get(\'ir.model.data\')
form_res = mod_obj.get_object_reference(cr, uid, \'demo_contract\', \'view_sigining_contract_form\')
form_id = form_res and form_res[1] or False
return {
\'name\':u\'创建合同\',
\'type\': \'ir.actions.act_window\',
\'view_type\': \'form,tree\',
\'view_mode\': \'form,tree\',
\'res_model\': \'sigining.contract\',
\'views\': [(form_id, \'form\')],
\'view_id\':form_id,
\'context\':ctx,
}
<div class="oe_right oe_button_box" name="buttons">
<button class="oe_inline oe_stat_button" icon="fa-list" name="action_open_jiesuan_order" type="object">
<field string="结算清单" name="jiesuan_order_count" widget="statinfo" />
</button>
</div>
这是右边的页签:计算条数:
# 新加地方,要记录立项的条数,通过合同号来找到
def _get_lx_order_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
try:
lx_origin=self.browse(cr,uid,ids[0],context=context).lx_origin
obj=self.pool(\'demo.contract.lx\')
demo_contract_lx_ids=obj.search(cr,uid,[(\'lx_origin\',\'=\',lx_origin)])
res[ids[0]]=len(demo_contract_lx_ids)
except:
print u"err!"
finally:
return res
_columns = {
\'lx_order_count\':fields.function(_get_lx_order_count,string=\'立项单\'),
}
###############链接到立项页面tree视图
def action_open_lx_order(self, cr, uid, ids, context=None):
try:
act_obj = self.pool.get(\'ir.actions.act_window\')
mod_obj = self.pool.get(\'ir.model.data\')
obj=self.browse(cr,uid,ids[0],context=context)
lx_origin=obj.lx_origin
result = mod_obj.xmlid_to_res_id(cr, uid, \'demo_contract.action_demo_contract_lx\',raise_if_not_found=True) #查找出动作的ID
result = act_obj.read(cr, uid, [result], context=context)[0]
result[\'domain\'] = "[(\'lx_origin\',\'=\',\'" + lx_origin + "\')]"
except:
print u"err!"
finally:
return result
<record id="view_demo_contract_lx_form" model="ir.ui.view">
<field name="name">demo.contract.lx.form</field>
<field name="model">demo.contract.lx</field>
<field name="arch" type="xml">
<form striing="demo contract lx">
<header>
<button name="action_split_order" string="确认" type="object" states="draft"/>
<button name="action_cancel_order" string="取消" type="object" states="confirm"/>
<button name="action_view_sigining_contract" string="创立合同" type="object" states="confirm"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirm"/>
</header>
<sheet>
<div class="oe_right oe_button_box" name="buttons">
<button class="oe_inline oe_stat_button" icon="fa-list" name="action_open_lx_order" type="object">
<field string="立项单" name="lx_order_count" widget="statinfo" />
</button>
</div>
<h1>
<label string="立项"/>
<field name="lx_origin" class="oe_inline" readonly="1"/>
</h1>
以上是关于odoo合同模块开发所需要方法的主要内容,如果未能解决你的问题,请参考以下文章