콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
5430 화면

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

아바타
취소
관련 게시물 답글 화면 활동
1
8월 22
15207
2
1월 20
15217
16
8월 19
10178
1
1월 19
5426
5
6월 18
10836