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.

24 lines
702 B

  1. import json
  2. from odoo import models, fields, api
  3. class Product(models.Model):
  4. _inherit = 'product.product'
  5. # technical field used in POS frontend
  6. price_ids_json = fields.Char(
  7. "Multi price data dict", readonly=True,
  8. compute="_compute_price_ids_json")
  9. @api.multi
  10. def _compute_price_ids_json(self):
  11. for p in self:
  12. res = []
  13. for price in p.price_ids:
  14. res.append({
  15. 'id': price.id,
  16. 'price_name': price.name.name or '',
  17. 'price_id': price.name.id or '',
  18. 'price': price.price,
  19. })
  20. p.price_ids_json = json.dumps(res)