Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
5508 Lượt xem

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("#########################################################")
Ảnh đại diện
Huỷ bỏ
Tác giả

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

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

Câu trả lời hay nhất

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 "("#########################################################")"
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 22
15271
2
thg 1 20
15272
16
thg 8 19
10224
1
thg 1 19
5484
5
thg 6 18
10885