models.py 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class ProductProduct(models.Model):
  4. _inherit = 'product.product'
  5. @api.model
  6. def getProductProduct(self,domain):
  7. # import web_pdb; web_pdb.set_trace()
  8. ProductProduct = self.env['product.product'].search(domain)
  9. values = []
  10. for product in ProductProduct:
  11. # import web_pdb; web_pdb.set_trace()
  12. attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
  13. attributeIDS = []
  14. for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
  15. attributeIDS.append(arttIds.attribute_id.id)
  16. values.append({
  17. 'id': product.id,
  18. 'name': product.name,
  19. 'standard_price': product.standard_price,
  20. 'ean13': product.ean13,
  21. 'categ_id': {
  22. 'id': product.categ_id.id,
  23. 'name': product.categ_id.name,
  24. 'complete_name': product.categ_id.complete_name,
  25. },
  26. 'atribute_value_ids': attributeValuesLines,
  27. 'attribute_ids': attributeIDS
  28. })
  29. return values