美文网首页odoo
odoo添加多个弹框表单2018-07-24

odoo添加多个弹框表单2018-07-24

作者: 小尤root | 来源:发表于2018-07-24 15:59 被阅读0次

很多时候,我们想为同一个model添加多个form表单,这时候可以为不同的表单添加不同的优先级,默认的优先级是16,优先级的数字越小,表示优先级越高。

如下,我设该表单的优先级为15

  <record id="view_loan_after_form" model="ir.ui.view">
        <field name="name">loan.count.view.from</field>
        <field name="model">loan.record</field>
        <field name="priority">15</field>
        <field name="arch" type="xml">

在该表单中,添加几个button,通过点击button弹出制定的表单,这些表单同时对应loan.record,编辑后保存即可,其作用在于使view_loan_after_form只具有显示作用,view_loan_after_form中的字段全部设置为readonly="1",编辑的表单与显示的表单分开。如下

<form string="贷后基础数据">
                <header>
                </header>
                <sheet>
                    <div class="oe_title" style="float: left;">
                            <label for="apply_id" class="oe_edit_only"/>
                            <h3>
                                <field name="customer_name" readonly="1"/>
                                <!--<field name="name" invisible="1"/>-->
                            </h3>
                            <field name="order" readonly="1"/>
                    </div>
                    <div class="oe_button_box" name="button_box" style="float: right;">
                        <button name="action_edit_finance" type="object"
                                    class="oe_stat_button" icon="fa-archive" string="财务资料补充"/>
                        <button name="action_edit_bank_num" type="object"
                                    class="oe_stat_button" icon="fa-archive" string="银行卡信息补录"/>
                        <button name="action_edit_pledge_case" type="object"
                                    class="oe_stat_button" icon="fa-archive" string="抵押确认"/>
                        <button name="action_edit_original_record" type="object"
                                    class="oe_stat_button" icon="fa-archive" string="原件记录"/>
                        <button name="action_edit_copies_record" type="object"
                                    class="oe_stat_button" icon="fa-archive" string="扫描件记录"/>
                        <button class="oe_stat_button" name="attachment_tree_view" type="object" icon="fa-archive">
                            <div class="o_stat_info">
                                <span class="o_stat_text">附件数量</span>
                                <field name="doc_count" />
                            </div>
                         </button>
                    </div>
                    <group >
                        <group name="left">
                            <field name="credit_id" readonly="1"/>
                            <field name="loan_id"/>
                            <field name="borrower_id" invisible="1"/>
                        </group>
                        <group name="right">
                            <field name="partner_id"  readonly="1"/>
                            <field name="product_id" readonly="1"/>
                            <field name="finance_name" readonly="1" invisible="1"/>
                            <field name="finance_id" readonly="1"/>

例如name="action_edit_finance"的按钮,点击该按钮时触发model中对应的函数,这里只做简单的演示,没有传入上下文及其他参数,这里选择multi装饰器,这里不解释装饰器的作用,self.ensure_one()保证是一个单条记录,有防止连续点击的影响(个人猜测),这里可不用src_model属性,当改变前后model不一致时,需要使用src_model属性,指向操作前的model,view_id属性指定视图,后面为视图id,可以为form视图,也可以为列表视图,这里指向form视图,target=new为弹框显示,其原理和HTML中a标签target=_blank类似,封装解释不同,效果也不同。id为当前操作任务id,这里没有多条id操作,以后应该会补。

    @api.multi
    def action_edit_finance(self):
        self.ensure_one()
        return {
            'name': '财务资料补充',
            'res_model': 'loan.record',
            'type': 'ir.actions.act_window',
            'src_model' :'loan.record',
            'res_id': self.id,
            'view_id': self.env.ref('loan_after.edit_loan_record_finance_form').id,
            'view_mode': 'form',
            'view_type': 'form',
            'target': 'new',
        }

在loan_after目录下创建form表单

  <record id="edit_loan_record_finance_form" model="ir.ui.view">
        <field name="name">Loan Edit Finance</field>
        <field name="model">loan.record</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group>
                        <group>
                            <field name="order" readonly="1"/>
                            <field name="apply_id"/>
                            <field name="identity"/>
                        </group>
                        <group>
                            <field name="saler_id"/>
                            <field name="product_id"/>
                            <field name="finance_id" readonly="1"/>
                            <field name="finance_name"/>
                        </group>
                        <!--<group>-->
                            <!--<field name="cardholder"/>-->
                            <!--<field name="pay_account"/>-->
                            <!--<field name="bank_card" widget="image" class="oe_avatar"/>-->
                        <!--</group>-->
                    </group>
                    <group>
                        <group>
                            <!--<field name="total_amount" readonly="1"/>-->
                            <!--<field name="loans" />-->
                            <!--<field name="contract_euribor"/>-->
                            <!--<field name="or_loansinterest"/>-->
                            <field name="loansinterest"/>
                            <field name="bank_date"/>
                            <field name="pay_client"/>
                        </group>
                        <group>

                            <field name="advance_payment"/>
                            <field name="advance_date"/>
                            <field name="security_cost"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

相关文章

  • odoo添加多个弹框表单2018-07-24

    很多时候,我们想为同一个model添加多个form表单,这时候可以为不同的表单添加不同的优先级,默认的优先级是16...

  • vue中禁止遮罩底层页面滑动

    方法一:在点击事件(弹出弹框)时,添加 在隐藏弹框时 方法二:在点击事件(弹出弹框)时,添加 在隐藏弹框方法中,添加

  • 系统之多选表格弹框--(2)

    想要在form表单填写的一项中添加多选弹框,实现多选事件和向父页面传递值。 这里在前端使用layer弹框插件,非常...

  • 关于element循环表单校验不生效问题

    项目中有如下需求: 可以添加一个列表 => 添加弹框 => 里面可以添加多个产品(产品里面可以添加多个对接人跟政策...

  • elementui的el-form在初始状态清除校验提示

    问题描述: 第一次点击弹框编辑表单的时候,编辑框的输入不符合验证规则出现了提示,然后关闭弹框,再次打开弹框,提示就...

  • 悬浮按钮

    只需要一段代码就能轻松使用 创建多个TamSuspenModel对象加入数组即可添加多个弹框【目前只支持向上弹出】...

  • flask中怎么控制两个按钮

    表单添加多个提交按钮 在某些情况下,可能需要为一个表单添加多个提交按钮。比如在创建文章的表单中添加发布按钮和存草稿...

  • elementUI中渲染多个popover弹框组件popover

    解决在做elementUI项目引用多个弹框popover时,点击弹框内按钮,弹框不隐藏的问题;解决思路:在组件外写...

  • Axure8.0之弹框组件

    弹框组件主要的实现思路是利用动态面板可以在多个状态下切换的原理,在一个状态下添加弹框内容,另一个状态下不添加任何内...

  • Flutter 弹框6种

    1、Flutter 项目默认升级弹框和自定义升级弹框 注:在pubspec.yaml中添加 插件 #版本更新对话框...

网友评论

    本文标题:odoo添加多个弹框表单2018-07-24

    本文链接:https://www.haomeiwen.com/subject/lyqymftx.html