Advertisement
Guest User

ShipmentIn replace create method

a guest
Jun 21st, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. from trytond.model import Workflow, ModelView, ModelSQL, fields
  4. from trytond.pyson import Eval, Or, Bool, And, Not,Equal
  5. from trytond.transaction import Transaction
  6. from trytond.pool import Pool
  7.  
  8.  
  9. __all__ = ['ShipmentIn']
  10.  
  11. class ShipmentIn(Workflow, ModelSQL, ModelView):
  12.     "Supplier Shipment"
  13.     __name__ = 'stock.shipment.in'
  14.    
  15.     is_donation = fields.Boolean('By donation',
  16.         help='Check if the shipment is a donation')
  17.    
  18.    
  19.     @classmethod
  20.     def create(cls, vlist):
  21.         pool = Pool()
  22.         Sequence = pool.get('ir.sequence')
  23.         Config = pool.get('stock.configuration')
  24.  
  25.         vlist = [x.copy() for x in vlist]
  26.         config = Config(1)
  27.         for values in vlist:
  28.             if values['is_donation']:
  29.                 values['code'] = Sequence.get_id(config.shipment_in_donation_sequence)
  30.             else:
  31.                 values['code'] = Sequence.get_id(config.shipment_in_sequence)
  32.        
  33.         shipments = super(ShipmentIn, cls).create(vlist)
  34.         cls._set_move_planned_date(shipments)
  35.         return shipments
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement