İçereği Atla
Menü
Bu soru işaretlendi
5 Cevaplar
13517 Görünümler

Hi all,

I am trying to make a one2many field act as per the "bank_id" field on the customer form on Odoo v12 but unable to do it.

On the Customer Form | Invoicing tab | Bank accounts, there's a one2many relationship field that user may choose the bank account directly from here (no new forms open unless user chooses the option "Create and Edit").


I am trying to obtain the same result on another one2many relation field for my module but when user clicks on the "Add a line", Odoo is openning a new window requesting user to create a new record...


I don't want this pop-up window to appear.

I need to do exactly as the "bank account" one2many field on the ,customers form...

Can you please help?

Thank you in advance

Avatar
Vazgeç
En İyi Yanıt

Hello

In your one2many tree view add editable='bottom', so you can able to edit here it self(instead of pop-up) 

Avatar
Vazgeç

this is possible to many2many field? I mean after click on create edit option of many2many field default form view is open. I dont want to open default form view instead it will display other custom form view or point to other field of form view where many2many field is available. Please can you tell me is it possible or not. if yes hows it possible. if no any other alternative way is available?

En İyi Yanıt

Try this one

<notebook>
<page string="Detail">
<field name="one2many_field">
<tree editable="top">
<field name="field1" />
<field name="field2"/>
<field name="field3">
</field>
</tree>
</field>
</page>
</notebook>



Avatar
Vazgeç
En İyi Yanıt

@Paulo Matos did you ever solve this?

I'm trying to do the same thing as you with no success thus far.

I don't have enough karma to comment so I had to make a new answer

Avatar
Vazgeç

I found an alternative solution by using widget="many2many".

It's not the same, but it works (Odoo 13)

En İyi Yanıt

Hello plz help ,

I'd like to change the type of section when I click in 'add section' in sale.order in field order_line field in odoo 12, It's a Char field and I'd like to change it to Many2one field

Avatar
Vazgeç
Üretici En İyi Yanıt

I am writing a new "answer" because I need to refer both @subbarao and @sehrish.

Thank you guys.

I have tried as you said but unfortunately I could not get the complete workflow as desired.

Using the "<tree editable ="bottom"> (or top), now I am able to edit the record on the same form without the "pop-up" window... but...

I am still unable to "choose the record from a list of existing records" and cannot see the (Create and Edit option).

@subbarao says that I should add this "editable = "bottom" to the tree view of my "one2many" field.

Do you mean add it to the "model" where I have the relation to the Many2one field?  

These are my classes:

class mymodule_director(models.Model):   
    _name = 'mymodule.director'   
    name = fields.Char('Name', size=50, required=True)   
    phone = fields.Char('Phone', size=17, default="00244 ")   
    email = fields.Char('Email')   
    location_id = fields.Many2one('mymodule.locations','Location', required=True)   
    customer_ids = fields.Many2one('mymodule.customers','director_ids')


class mymodule.customers(models.Model):   
     _name='mymodule.customers'   
     name=fields.Char('Name', required=True)   
    address = fields.Char('Address')   
    city = fields.Char('City')   
    province=fields.Char('Province')   
    email=fields.Char('Email')   
    director_ids = fields.One2many('mymodule.director','customer_ids', string="Director")


Tree view:

- mymodule.director model

<record id="mymodule_director_tree_view" model="ir.ui.view">
    <field name="name">Director List View</field>
    <field name="model">mymodule.director</field>
    <field name="arch" type="xml">
      <tree editable="bottom">    ------->>>>> ADDED AS PER INSTRUCTIONS
         <field name="name"/>
         <field name="phone"/>
         <field name="email"/>
         <field name="location_id"/>
         <field name="customer_ids" string="Customer"/>
      </tree>
    </field>
  </record>


- mymodule.customers model FORM view (where the relation should appear on form view)

  <record id="mymodule_customers_form_view" model="ir.ui.view">
    <field name="name">mymodule.customers.form.view</field>
    <field name="model">mymodule.customers</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
      <sheet>
        <form>
          <group>
            <field name="name"/>
            <field name="address"/>
            <field name="city"/>
            <field name="province"/>
            <field name="email"/>
          </group>
            <notebook>                        ----------------->>>>>> TRIED TO ADD "editable = "bottom" FROM THIS POINT WITH NO SUCESS
              <page string="Directors">
                  <field name="director_ids"/>
              </page>
            </notebook>
      </form>
      </sheet>
    </field>
  </record> 


Adding it to the "tree view" above, I can get "almost" what I want. The problem is that existing records are not shown on the form...


 Thank you once again


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 25
2363
4
May 24
7712
1
Tem 23
2616
3
Haz 23
3638
2
Eyl 22
10046