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

class SaleOrder(models.Model):

    _inherit = "sale.order"

    ...

    picking_state = fields.Selection(string="Picking State", related="picking_id.state")

    # this are a states from "stock.picking" model


    warehouse_id = fields.Many2one(

        'stock.warehouse', string='Warehouse',

        required=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},

        default=_default_warehouse_id)

# at the moment the "readonly" of warehouse_id depends on states from "sale.order"


How to include condition:   readonly=True   when     picking_state == "done"  ?

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

Hi,
You can make the field 'warehouse_id' readonly based on 'picking_state' in the xml part  

<field name="warehouse_id" attrs="{'readonly': [('picking_state', '=', 'done')]}"/>

Regards

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أكتوبر 22
4486
1
سبتمبر 17
4885
1
فبراير 16
4418
2
يونيو 17
3795
5
مايو 17
5126