【问题标题】:Add counter button in odoo to update field value by 1在odoo中添加计数器按钮以将字段值更新1
【发布时间】:2017-12-18 01:11:30
【问题描述】:

我想在报告中添加计数器。我的意思是,每次我点击打印按钮,报告都必须以+1的增量打印,写成Reprinted 1,Reprinted 2,Reprinted 3等等。你对解决这种技术有什么想法吗?如果不可能,我有另一个想法,但我也不知道该怎么做。那就是:在表单中添加一个字段,每次单击自定义打印按钮时,该字段值将增加 1。并且该更新的字段将打印在报告中。 我还是一个学习型的孩子。请举例回复。

我拥有的是: enter image description here

<record id="apple_view_form" model="ir.ui.view">
    <field name="name">Apple Form</field>
    <field name="model">se.apple</field>
    <field name="arch" type="xml">
        <form>
            <header>
                <button name="print_report" string="Print Apple" type="object"/>
            </header>
            <h1 class="dexter">This is Dexter</h1>
            <sheet>
                <group name="group_top">
                    <group name="group_left">
                        <field name="apple_name"/>
                    </group>
                    <group name="group_right">
                        <field name="apple_price"/>
                    </group>
                </group>
                <group name="group_bottom">
                    <field name="apple_description"/>
                    <field name="apple_remarks"/>
                </group>
                <templates id="template" xml:space="preserve">
                    <t t-name="custom_btn">
                        <button string="Custom Button">Custom Button</button>
                    </t>
                </templates>
            </sheet>
        </form>
    </field>
</record>

【问题讨论】:

    标签: javascript python openerp business-logic odoo-10


    【解决方案1】:

    就像您建议的那样,您可以在模型中创建一个不可见的字段。然后你继承 print 方法并让它增加那个不可见的字段。由于报表将提供整个对象,您只需访问报表中的不可见字段即可。

    【讨论】:

    • 你能给我举个例子吗
    猜你喜欢
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-21
    • 1970-01-01
    • 2012-09-26
    相关资源
    最近更新 更多