SHARE
TWEET

Untitled

a guest Aug 10th, 2013 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf8 -*-
  3.        
  4. from proteus import config, Model
  5. from decimal import Decimal
  6.  
  7. config = config.set_xmlrpc('https://admin:admin@demo2.4.tryton.org:8069/demo2.4')      
  8.  
  9. Sale = Model.get('sale.sale')
  10. SaleLine = Model.get('sale.line')
  11.  
  12.  
  13. sale = Sale()
  14.  
  15. Party = Model.get('party.party')
  16. supplier = Party(name='Supplier')
  17. supplier.save()
  18. customer = Party(name='Customer')
  19. customer.save()
  20. sale.party = customer
  21.  
  22. PaymentTerm = Model.get('account.invoice.payment_term')
  23. PaymentTermLine = Model.get('account.invoice.payment_term.line')
  24. payment_term = PaymentTerm(name='Direct')
  25. payment_term_line = PaymentTermLine(type='remainder', days=0)
  26. payment_term.lines.append(payment_term_line)
  27. payment_term.save()
  28. sale.payment_term = payment_term
  29.  
  30. sale.invoice_method = 'order'
  31. sale_line = SaleLine()
  32. sale.lines.append(sale_line)
  33.  
  34. ProductUom = Model.get('product.uom')
  35. unit, = ProductUom.find([('name', '=', 'Unit')])
  36. Product = Model.get('product.product')
  37. product = Product()
  38. product.name = 'product'
  39. product.default_uom = unit
  40. product.type = 'goods'
  41. product.purchasable = True
  42. product.salable = True
  43. product.list_price = Decimal('10')
  44. product.cost_price = Decimal('5')
  45. product.cost_price_method = 'fixed'
  46. product.save()
  47.  
  48. sale_line.product = product
  49. sale_line.quantity = 2.0
  50. sale.save()
  51. Sale.quote([sale.id], config.context)
  52. Sale.confirm([sale.id], config.context)
  53. Sale.process([sale.id], config.context)
  54. sale.state
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top