product_template.py 981 B

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8 -*-
  2. # Copyright© 2016 ICTSTUDIO <http://www.ictstudio.eu>
  3. # License: AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
  4. import logging
  5. from openerp import models, fields, api, _
  6. _logger = logging.getLogger(__name__)
  7. class ProductTemplate(models.Model):
  8. _inherit = 'product.template'
  9. @api.one
  10. def _get_pricelists(self):
  11. self.pricelists = self.env['product.pricelist'].search(
  12. [
  13. ('show_on_products', '=', True)
  14. ]
  15. )
  16. def _set_pricelists(self):
  17. for pricelist in self.pricelists:
  18. if pricelist.product_price:
  19. _logger.debug("Updating Price: %s", pricelist.product_price)
  20. pricelist.price_set(self, pricelist.product_price)
  21. pricelists = fields.One2many(
  22. comodel_name="product.pricelist",
  23. string="Pricelists",
  24. compute="_get_pricelists",
  25. inverse="_set_pricelists"
  26. )