Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
6114 Zobrazení

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

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
říj 22
4491
1
zář 17
4885
1
úno 16
4420
2
čvn 17
3797
5
kvě 17
5127