Forráskód Böngészése

[ADD] price per product

Gogs 7 éve
szülő
commit
cde8c93251
2 módosított fájl, 12 hozzáadás és 2 törlés
  1. 1 1
      __openerp__.py
  2. 11 1
      models/product_template.py

+ 1 - 1
__openerp__.py

@@ -4,7 +4,7 @@
     'author': "Robert Gauto",
     'category': 'Uncategorized',
     'version': '0.1',
-    'depends': ['base', 'sale', 'account', 'multi_store'],
+    'depends': ['base', 'sale', 'account', 'multi_store', 'pricelist_per_product'],
     'data': [
         'templates.xml'
     ]

+ 11 - 1
models/product_template.py

@@ -16,13 +16,21 @@ class ProductTemplate(models.Model):
             for variant in product.product_variant_ids:
                 if not variant.active:
                     continue
+
+                prices = []
                 attributes = []
 
+                for price in variant.product_tmpl_id.pricelist_item_ids.filtered(lambda x: x.product_id.id == variant.id):
+                    prices.append({
+                        'id': price.id,
+                        'price': price.price_surcharge
+                    })
+
                 # map product attribute
                 for attribute_value in variant.attribute_value_ids:
                     attributes.append({
                         'id': attribute_value.id,
-                        'name': attribute_value.name,
+                        'price': attribute_value.name,
                         'display_name': attribute_value.display_name
                     })
 
@@ -34,8 +42,10 @@ class ProductTemplate(models.Model):
                     'list_price': variant.list_price,
                     'name': variant.name,
                     'qty_available': variant.qty_available,
+                    'prices': prices,
                     'attributes': attributes
                 })
+
             products.append({
                 'id': product.id,
                 'display_name': product.display_name,