跳至內容
選單
此問題已被標幟
1 回覆
6481 瀏覽次數

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
10月 22
4937
1
9月 17
5245
1
2月 16
4722
2
6月 17
4162
5
5月 17
5449