product_pricelist.py 559 B

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