Ir al contenido
Menú
Se marcó esta pregunta
6 Respuestas
44263 Vistas

Hello there,

On a sale order creation, I want to hide the 'create. option of the field partner_shipping_id. But I want to keep the 'create and edit' option.Is it possible?

So the user will have to edit his new partner on creation.

How to achieve this?


Actual code in my custom inherited view :

<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
    <attribute name="domain">['&amp;',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
    <attribute name="attrs">{'no_create': True}</attribute>
</xpath>


Image :



EDIT #1

The real problem is :

I have a new field on res.partner

partner_territory = fields.Many2one(comodel_name='res.territory', string='Partner\'s territory', required=True)

With the 'Create' option, a new shipping address (partner) is created without respecting the 'required=True' of my new field. The partner is created and the field partner_territory stays empty. Isn't it weird?

With the  'Create and Edit...', a new window opens and the user must fill the field parnter_territory. Fine.


What do you think about this?


Avatar
Descartar
Mejor respuesta

Many2one widget (default)

Options : Other possible options you can use with this widget.

  • no_quick_create - It will remove Create and edit... option.
  • no_create_edit - It will remove Create "entered text" option.
  • no_create - no_quick_create and no_create_edit combined.
  • no_open - in read mode: do not render as a link.

Example:

<field name="field_name" options="{'no_quick_create': True, 'no_create_edit' : True}"/>

You can refer it from  Here

Avatar
Descartar
Autor Mejor respuesta

I have found the right way to write it. With this, the 'Create' option is invisible. The 'Create and edit...' is still there.

<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
    <attribute name="domain">['&amp;',('parent_id','=',partner_id),('type','=','delivery')]</attribute>
     <attribute name="options">{'no_quick_create':True}</attribute>
</xpath>


But it doesn't explain to me why the 'Create' option can create a new partner WITHOUT respecting 'Required=True' of a field declaration...


 

Avatar
Descartar

I have the same problem. "quick_create" can pass the required field defined in the model!

Maybe if you defined the required attribute in form xml like: <field name="name_of_field attrs="{'required':True}"

Mejor respuesta

Hi Pascal !

You can write attributes to avoid create and create and edit fields in many2one fields with this code:

Regards,

<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="options">{'no_quick_create':True,'no_create_edit':True}</attribute>
</xpath>
Avatar
Descartar
Mejor respuesta

Just replace attrs to options like below

<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
    <attribute name="options">{'no_create': True}</attribute>
</xpath>

Avatar
Descartar
Mejor respuesta

<xpath expr="//field[@name='partner_shipping_id']" position="attributes">
    <attribute name="options">{'no_create': True}</attribute>
</xpath>

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
4
dic 23
19477
1
ago 23
1552
0
sept 19
4536
1
jul 19
6581
1
mar 16
5343