2017-01-13 3 views
0

so, soweit ich weiß, function Felder sind auf Odoo v9 veraltet.Übersetzen alte API Odoo Funktion Feld in Odoo v9 Gemeinschaft

Nehmen Sie dieses Beispiel:

state = fields.function(_state_get, type="selection", copy=False, 
     store={ 
      stock.picking = (lambda self, cr, uid, ids, ctx: ids, ['move_type', 'launch_pack_operations'], 20), 
      stock.move = (_get_pickings, ['state', 'picking_id', 'partially_available'], 20)}, 
     selection=[ 
      ('draft', 'Draft'), 
      ('cancel', 'Cancelled'), 
      ('waiting', 'Waiting Another Operation'), 
      ('confirmed', 'Waiting Availability'), 
      ('partially_available', 'Partially Available'), 
      ('assigned', 'Available'), 
      ('done', 'Done'), 
      ], string='Status', readonly=True, select=True, track_visibility='onchange', 
     help=""" 
      * Draft: not confirmed yet and will not be scheduled until confirmed\n 
      * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n 
      * Waiting Availability: still waiting for the availability of products\n 
      * Partially Available: some products are available and reserved\n 
      * Ready to Transfer: products reserved, simply waiting for confirmation.\n 
      * Transferred: has been processed, can't be modified or cancelled anymore\n 
      * Cancelled: has been cancelled, can't be confirmed anymore""" 
    ), 

Dies erfordert zwei Funktionen _state_get und _get_pickings

Die Funktionen arbeiten, wie sie auf v9 sind, aber wie erkläre ich, etwas Ähnliches zu diesem Bereich in die neue API?

Antwort

1

Sie können das Feld auf diese Weise in der neuen API deklarieren.

@api.depends('move_lines.state') 
def _state_get(self) 
    #your code 
    pass 

state = fields.Selection(compute=_state_get,store=True,copy=False,selection=[ 
      ('draft', 'Draft'), 
      ('cancel', 'Cancelled'), 
      ('waiting', 'Waiting Another Operation'), 
      ('confirmed', 'Waiting Availability'), 
      ('partially_available', 'Partially Available'), 
      ('assigned', 'Available'), 
      ('done', 'Done'), 
      ], string='Status', readonly=True, select=True, track_visibility='onchange', 
     help=""" 
      * Draft: not confirmed yet and will not be scheduled until confirmed\n 
      * Waiting Another Operation: waiting for another move to proceed before it becomes automatically available (e.g. in Make-To-Order flows)\n 
      * Waiting Availability: still waiting for the availability of products\n 
      * Partially Available: some products are available and reserved\n 
      * Ready to Transfer: products reserved, simply waiting for confirmation.\n 
      * Transferred: has been processed, can't be modified or cancelled anymore\n 
      * Cancelled: has been cancelled, can't be confirmed anymore""" 
    ) 
+0

Super super! Danke! – NeoVe

Verwandte Themen