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

I want to create a new object type that inherits from res.partner and have the same formatting in the form view but my inherited view appears all on one page with no notebooks or pages.

in my county.py :

class county_citizen(osv.osv):
_name = 'county.citizen'
_description = 'County Citizen'
_inherit = 'res.partner'
_columns = {
  'citizen_id' : fields.char('Identification No',size=15,required=True,help="The National ID of the Citizen"),
  'citizen_passport_id': fields.char('Passport No',size=64),
  'citizen_otherid': fields.char('Other Id', size=64),
  'citizen_gender' : fields.selection([('male','Male'),('female','Female')], 'Gender',required=True),
  'citizen_photo': fields.binary('Photo',help="Upload a Citizen's Passport Image"),
  'citizen_work': fields.char('Occupation',size=32,required=True),
  'citizen_notes': fields.text('Notes',help="Comments of citizen's role,work or duty in the county.")
  }
def _get_photo(self,cr,uid,context=None):
  photo_path = addons.get_module_resource('county','images','photo.png')
  return open(photo_path,'rb').read().encode('base64')
_defaults = {
  'citizen_photo': _get_photo
  }
sql_constraints = [('id_unique','unique (citizen_id)','The citizen identification is unique')]
#end of class

county_citizen()

and in my county_view.xml :

 <record id="view_citizen_form" model="ir.ui.view">
        <field name="name">Citizens</field>
        <field name="model">county.citizen</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="County Citizen">
                    <group colspan="2" col="1">
                        <field name="citizen_photo" widget='image' width="100" height="100" nolabel="1"/>
                    </group>
                    </page>
                    <page string="Personal Information">
                        <group col="2" colspan="2" >
                            <separator colspan="2" string="Social IDs"/>
                            <field name="citizen_id"/>
                            <field name="citizen_passport_id"/>
                            <field name="citizen_otherid"/>
                        </group>
                        <group col="2" colspan="2">
                            <separator colspan="2" string="Gender"/>
                            <field name="citizen_gender"/>
                        </group>
                        <group col="2" colspan="2">
                            <separator colspan="2" string="Job Information"/>
                            <field name="citizen_work"/>
                        </group>
                    </page>
                    <page string="Petitions">
                        <group col="2" colspan="2">

                        </group>
                    </page>
                    <page string="Permits"></page>
                    <page string="Complaints"></page>
                    <page string="Notes" groups="">
                        <field colspan="4" nolabel="1" name="citizen_notes"/>
                    </page>
                </notebook>
        </field>
    </record>

Kindly Help it is Urgent. Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

If you are inheriting a model and creating a new model with it you can't inherit the XML view too, if you want to add fields to res.partner this is valid but when you are creating a new model with it you have to create your own view. If you want it copy all the XML code from res.partner and add your fields there.

Ảnh đại diện
Huỷ bỏ

it is not necessary to give a name to the inherited model, please remove that line of code and see that changes

Tác giả

thank you guys

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 3 15
8559
3
thg 10 20
5638
2
thg 3 23
3352
View inheritance Đã xử lý
1
thg 3 20
3327
12
thg 12 18
34540