This question has been flagged
6 Replies
37711 Views

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
Discard
Best Answer

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
Discard
Author Best Answer

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
Discard

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}"

Best Answer

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
Discard
Best Answer

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
Discard
Best Answer

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

Avatar
Discard