You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
632 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Tecnativa - Jairo Llopis
  3. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
  4. from odoo import api, SUPERUSER_ID
  5. def post_init_hook(cr, registry):
  6. """Set default pricelists for existing POS configurations"""
  7. with api.Environment.manage():
  8. env = api.Environment(cr, SUPERUSER_ID, {})
  9. nopricelist = env["pos.config"].search([
  10. ("available_pricelist_ids", "=", False),
  11. ])
  12. for one in nopricelist:
  13. one.available_pricelist_ids = (one.pricelist_id or
  14. one._default_pricelist())