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.

23 lines
725 B

  1. import json
  2. from odoo import models, fields, api
  3. class ProductTemplate(models.Model):
  4. _inherit = 'product.template'
  5. # technical field used in POS frontend
  6. supplier_data_json = fields.Char(
  7. "Supplier data dict", readonly=True,
  8. compute="_compute_supplier_data_json")
  9. @api.multi
  10. def _compute_supplier_data_json(self):
  11. for t in self:
  12. res = []
  13. for s in t.seller_ids:
  14. res.append({
  15. 'supplier_name': s.name.display_name,
  16. 'supplier_product_code': s.product_code or '',
  17. 'supplier_product_name': s.product_name or '',
  18. })
  19. t.supplier_data_json = json.dumps(res)