Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
2683 Переглядів

I made a button to change status in form view.

in xml

<record id="eric_product_attribute_form_view" model="ir.ui.view">
<field name="model">product.attribute</field>
<field name="view_type">form</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<header>
<button name="change_attribute_status" states="confirmed" string="Confirm" type="object" class="btn-primary" attrs="{'invisible': [('state', '!=', 'saved')]}"/>
       </header>
    </field>
</record>


  1. and Action

class ProductAttribute(models.Model):
_name = "product.attribute"
_inherit = "product.attribute"

state = fields.Char("Status")

@api.multi
def change_attribute_status(self):
_logger.info("====================================456========================================")
But I cannot get any log

Please help

Аватар
Відмінити

Your xml code is wrong.

Its not necessary to add _name="same.name" for inheriting models

Найкраща відповідь

you have to inheri the form view too 

add <field name=”inherit_id” ref=”module_name.id_of view”/>

then use xpath to add a button

here is a simple example to inherit sale order form view :

<record model=”ir.ui.view” id=”sale_order_custom_field”>
    <field name=”name”>sale.order.form</field>
    <field name=”model”>sale.order</field>
    <field name=”inherit_id” ref=”sale.view_order_form”/>
    <field name=”arch” type=”xml”>
        <xpath expr=”//field[@name='partner_id']” position=”after”>
            <field name=”your_field”/>
        </xpath>
</field>
</record>

Аватар
Відмінити
Найкраща відповідь

To change state you can use self.write({'field name':'value'}) in this function.

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
квіт. 17
5257
2
бер. 19
3106
1
бер. 15
3606
1
серп. 25
620
0
серп. 25
356