cost_price = fields.Float('Cost Price', digits=(16, 4), states={ 'invisible': Or(~Eval('_parent_invoice', {}).get('type').in_(['out_credit_note']), Eval('type') != 'line'), 'required': And(Eval('_parent_invoice', {}).get('type').in_(['out_credit_note']), Eval('type') == 'line', Eval('_parent_invoice', {}).get('state', 'draft') != 'draft') }, depends=['invoice', 'type'])