product_pricelist.py 604 B

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_pricelist_id(currency_id):
  4. if not currency_id:
  5. return None
  6. domain = [
  7. ('active', '=', True),
  8. ('type', '=', 'sale')
  9. ]
  10. pricelist = r.env['product.pricelist'].search(domain)
  11. if not True in pricelist.mapped(lambda p: p.currency_id.id == currency_id):
  12. pricelist = pricelist[0].copy()
  13. pricelist.write({
  14. 'currency_id': currency_id
  15. })
  16. else:
  17. pricelist = pricelist.filtered(lambda p: p.currency_id.id == currency_id)
  18. return pricelist.id