1
votes

Inserting some fields values of one model to another model and showing all fields on one view. For example !

I am having a student model which basic information (first name, last name etc) and want to save it into res_partner table. This is because i don't want to show extra fields of res_partner on student registration form view. Just using custom form view having tabs and other fields.

2
You're not specific enough. Maybe you need related fields, but maybe you need to create a brand new view. How is your Student model defined? You cannot use res_partner view to display data from Student model. Tabs can be created with <notebook> tag in your form view.Juraj Bezručka
Or maybe delegation inheritance could be interesting here. There are some examples in Odoo for this inheritance: product.product, res.users and project.project.CZoellner

2 Answers

1
votes

Your question is not really clear but I guess you want to easily read/write some field on student model into partner model.

If a Student is always a partner I suggest you to use _inherits = {'res.partner': 'partner_id'}. Check docs and user/partner example. When you create a user you create a partner too. User model/table will hold only its fields. Another example for this is product.template+product.product.

If you don't need this and you have already a partner related to a student you can add some related fields, like:

fullname = fields.Many2one(related='partner_id.name')

If you don't set it as readonly you are going to write inside partner name.

Last but not least, if partner form is enough for you, just add new tab there, like this:

   <record id="partner_mytab_form" model="ir.ui.view">
        <field name="name">res.partner.mytab</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="//notebook[last()]" position="inside">
                <page string="My tab" name="mytab">
                    ...
                </page>
            </xpath>
0
votes

@api.multi def open_second_class(self): ac=self.env['ir.model.data'].xmlid_to_res_id('account.invoice_form',raise_if_not_found=True) write_obj = ac.create({'partner_id': self.name_id}) accountant = False for o in self: accountant = o.id result = { 'name': '2nd class', 'view_type': 'form', 'res_model': 'account.invoice', 'res_id': write_obj.id, 'view_id': False, 'context': {'default_id_tbl1': accountant}, 'type': 'ir.actions.act_window', 'view_mode': 'form', 'target': 'new', 'domain': '[]' } return result