تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
1449 أدوات العرض

i faced this problem because attrs-> required didn't work

الصورة الرمزية
إهمال
أفضل إجابة

Hi 

You can use required=True in the py file where the field is defined, otherwise in the XML View 

<field name="field_name" required="1"</field>


if it is an inherited view use the position attributes 

<attribute name="required">1</attribute>




Regards

الصورة الرمزية
إهمال
أفضل إجابة

try this way:
example:

  1. Make sure that in your model, the field amount_total has the attribute required=True:


from odoo import models, fields


class MyModel(models.Model):

_name = 'my.model'


amount_total = fields.Monetary(string='Total Amount', required=True)

# Other fields and methods

  1. In your view's XML definition, ensure that the required attribute is correctly set for the field:

field name="amount_total" required="1"/>




الصورة الرمزية
إهمال
الكاتب أفضل إجابة

i make it in python and in xml but still didn't work 

الصورة الرمزية
إهمال

You can use api constrains to check if the value in the monetary field as greater than 0.0 or not

الكاتب


it's work ,
thanks Bella James
for your answer