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

Hello,

I have to create new custom_module that add fields to the hr_employees view.

One of the fields I have to view, is the private mobile number of the employee, which is exist now in the related res_partner model.

How can I get it in the new custom module? 


I tried to write like taht, but got the error:

Field `mobile` does not exist


model.py file:  

from odoo import models, fields, api


class hr_employees_custom(models.Model):
    _inherit = ['hr.employee']

    mobile = fields.Char(related='address_home_id.phone'related_sudo=False,
                         string="Private Mobile"groups="hr.group_hr_user")

views.xml file: 

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <record id="view_employee_form_custom_inherit" model="ir.ui.view" >
            <field name="name">hr.employee.custom.form.inherit</field>
            <field name="model">hr.employee</field>
            <field name="inherit_id" ref="hr.view_employee_form"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@name='personal_information']" position="inside">
                    <group string="Phone">
                        <field name="phone" class="o_force_ltr" groups="hr.group_hr_user" string="Phone"/>
                        <field name="mobile" class="o_force_ltr" groups="hr.group_hr_user" string="Mobile"/>
                    </group>
                </group>
            </xpath>
        </field>
    </record>
</data>
아바타
취소
베스트 답변

Hi,

So whats the issue that you are facing ? new field wont be able to add to the employee form view? or you are looking to get the value of the mobile number from the partner(linked to the user) ?


If the case is the first one, make sure that the module is installed, python files are called in the init and xml file is added in the manifest, once these are done the newly added field will be visible in the user interface.


If the case is the second one, ie, you need to get the mobile number value from partner, you can try with the related field in odoo: related='user_id.partner_id.mobile'


1. https://www.youtube.com/watch?v=z1Tx7EGkPy0

2. Related Field: https://www.youtube.com/watch?v=pD6byjEvIx8


Thanks

아바타
취소
관련 게시물 답글 화면 활동
4
2월 25
2735
1
8월 24
2244
2
11월 24
3397
3
10월 23
14924
2
2월 23
2519