Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
6 Відповіді
45482 Переглядів

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?


Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Автор Найкраща відповідь

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...


 

Аватар
Відмінити

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

Найкраща відповідь

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>
Аватар
Відмінити
Найкраща відповідь

Just replace attrs to options like below

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

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
4
груд. 23
19766
1
серп. 23
1968
0
вер. 19
5059
1
лип. 19
6959
1
бер. 16
5643