0
votes

Lets assume the following model

class visit(osv.Model):
_name = "visit"
_order = "date desc"
_rec_name = "date"
_columns = {
    'date': fields.datetime('Date/Time', required=True),
    'res_partner_id': fields.many2one('res.partner', 'Client', required=True),
}

And we have the following view:

<record id="visit_form_view" model="ir.ui.view">
  <field name="name">visit.form.view</field>
  <field name="view_type">form</field>
  <field name="model">visit</field>
  <field name="arch" type="xml">
    <form string="Visit">
      <field name="date" />
      <field name="res_partner_id" />
    </form>      
  </field>
</record>

I have extended the res.partner to display a list of visits within a notebook page. When I Add an Item to the visits page within the customer, how do I set the default value of the res_partner_id combobox to the current customer?

2
First, thank you. As said, I extended the res.partner model and added the visit model above, so I can log the visits of each visitor/partner/client. When I open a client's form, from within that I open the visit form, I get a one2many_list widget that gives me options to select a visitor (partner object). What I want is not to have to select the partner from within the visit form. Rather, set the default to the current partner I can remove the res_partner_id field from the view. However I don't want to sacrifice having the option to set the partner from another separate formMustafa

2 Answers

2
votes

After reading your question and comment, I would suggest you to use one2many relation between two objects and keep one2many list view inside partner, from where one can create the record , does not need to select the partner and record is created only for that partner.

Cheers, Parthiv

0
votes

Google OpenERP _defaults (a dictionary) and default_get (a method).