Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
5181 Представления

where should i build a function which run on click of my custom button on inherited hr.payslip model

xml:

<record id="hr_payslip_form" model="ir.ui.view">
<field name="name">hr.payslip.form</field>
<field name="model">hr.payslip</field>
<field name="type">form</field>
<field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="my_button" string="Print2" class="oe_highlight"/>
</xpath>
</field>
</record>

models.py

class custom_hr_payslip(models.Model):
_name = 'custom.hr.payslip'
_inherit = 'hr.payslip'

@api.one
def my_button(self):
print("#########################################################")
Аватар
Отменить
Автор

hence this was my code but its not running/printing ,the ########

Odoo Module Customization Tutorials: https://learnopenerp.tumblr.com/

Лучший ответ

Give the attribute type = "object" on XML and define a function in the model as with exactly the name of your button


@api.multi
def my_button(self):
print "("#########################################################")"
Аватар
Отменить
Лучший ответ

Hi,

Can you give type="object".


 <button name="my_button" string="Print2" class="oe_highlight" type="object"/>


class CustomHRPayslip(models.Model):
_inherit = 'hr.payslip'

@api.one
def my_button(self):
print("#########################################################")


Thanks

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
авг. 22
14934
2
янв. 20
14763
16
авг. 19
9778
1
янв. 19
5142
5
июн. 18
10537