Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
5424 มุมมอง

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
15206
2
ม.ค. 20
15213
16
ส.ค. 19
10177
1
ม.ค. 19
5420
5
มิ.ย. 18
10834