Guest User

Untitled

a guest
Jul 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import wizard
  2. import pooler
  3. from osv import osv, fields
  4.  
  5.  
  6. qty1_form = '''<?xml version="1.0"?>
  7. <form string="Offer Builder">
  8. <field name="customer_name" />
  9. <field name="address_invoice" colspan="2" />
  10. <field name="pricelist" colspan="2" />
  11.  
  12. </form>'''
  13. qty1_fields = {
  14. 'customer_name' : {'string' : 'Customer Name', 'type' : 'many2one', 'relation' : 'res.partner', 'required':True },
  15. 'address_invoice': {'string':'Address', 'type':'many2one', 'relation' : 'res.partner.address'},
  16. 'pricelist': {'string':'Pricelist', 'type':'many2one', 'relation' : 'product.pricelist'},
  17. }
  18.  
  19.  
  20. def _onchange_partner_id(obj, cursor, user, data, context): #working in log but not returning value to field in form
  21. pool = pooler.get_pool(cursor.dbname)
  22. part = data['form']['customer_name']
  23. print part
  24.  
  25. if not part:
  26. return {'value':{'adresss_invoice': False}}
  27. addr = pool.get('res.partner').address_get(cursor, user, [part], ['default'])
  28. part = pool.get('res.partner').browse(cursor, user, part)
  29. print addr['default']
  30. return {'value':{'adresss_invoice': addr['default']}}
  31.  
  32. class wizard_offer(wizard.interface):
  33.  
  34. states = {
  35. 'init': {
  36. 'actions': [],
  37. 'result': {'type':'form', 'arch':qty1_form, 'fields':qty1_fields, 'state':[('customer','Continue')]}
  38. },
  39.  
  40. 'customer': {
  41. 'actions': [_onchange_partner_id],
  42. 'result': {'type':'form', 'arch':qty1_form, 'fields':qty1_fields, 'state':[('end','Cancel'),('offer','Print')]}
  43. },
  44.  
  45. 'offer': {
  46. 'actions': [],
  47. 'result': {'type':'print', 'report':'product.product', 'state':'end'}
  48. }
  49.  
  50. }
  51. wizard_offer('product.offer_gen')
Add Comment
Please, Sign In to add comment