Commits

Raimon Esteve (Zikzakmedia) committed 782b70c

Active Record

Comments (0)

Files changed (7)

+Version 2.6.0 - 2012-10-16
+* Active Record
+* Simplify module information with python configuration
+
 Version 2.4.0 - 2012-07-17
 * Initial release
 
 ===========================
 
 Add delivery note report valued on shipment out of Tryton.
-See __tryton__.py
 
 Installing
 ----------
 #This file is part stock_valued_report module for Tryton.
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
+from trytond.pool import Pool
+from .shipment import *
 
-from .shipment import *
+
+def register():
+    Pool.register(
+        DeliveryValued,
+        module='stock_valued_report', type_='report')

__tryton__.py

-#This file is part stock_valued_report module for Tryton.
-#The COPYRIGHT file at the top level of this repository contains 
-#the full copyright notices and license terms.
-{
-    'name': 'Stock Valued Report',
-    'name_ca_ES': 'Informe alabarans valorats',
-    'name_es_ES': 'Informe albaranes valorados',
-    'version': '2.4.0',
-    'author': 'Zikzakmedia',
-    'email': 'zikzak@zikzakmedia.com',
-    'website': 'http://www.zikzakmedia.com/',
-    'description': '''Report Stock Valued.
-In Delivery Note Report, you can add group permisions:
-- Stock
-- Stock Price 
-    ''',
-    'description_ca_ES': '''Informe albarans valorats.
-A la configuració del informe Albarà d'entrega', pot afegir els grups:
-- Estoc
-- Preus estoc
-    ''',
-    'description_es_ES': '''Informe albaranes valorados.
-A la configuración del informe Albarán de entrega, puede añadir los grupos:
-- Stock
-- Precios stock
-''',
-    'depends': [
-        'company',
-        'stock',
-        'stock_valued',
-        'res',
-        'ir',
-        'currency',
-        'product',
-        ],
-    'xml': [
-        'shipment.xml',
-        ],
-    'translation': [
-        'locale/ca_ES.po',
-        'locale/es_ES.po',
-    ],
-}
 
 from setuptools import setup
 import re
+import os
+import ConfigParser
 
-info = eval(open('__tryton__.py').read())
+config = ConfigParser.ConfigParser()
+config.readfp(open('tryton.cfg'))
+info = dict(config.items('tryton'))
+for key in ('depends', 'extras_depend', 'xml'):
+    if key in info:
+        info[key] = info[key].strip().splitlines()
 major_version, minor_version, _ = info.get('version', '0.0.1').split('.', 2)
 major_version = int(major_version)
 minor_version = int(minor_version)
 
 setup(name='trytond_stock_valued_report',
     version=info.get('version', '0.0.1'),
-    description=info.get('description', ''),
-    author=info.get('author', ''),
-    author_email=info.get('email', ''),
-    url=info.get('website', ''),
+    description='Tryton module for stock valued discount report',
+    author='Zikzakmedia SL',
+    author_email='zikzak@zikzakmedia.com',
+    url='http://www.zikzakmedia.com',
     download_url="https://bitbucket.org/zikzakmedia/trytond-stock_valued_report",
     package_dir={'trytond.modules.stock_valued_report': '.'},
     packages=[
     ],
     package_data={
         'trytond.modules.stock_valued_report': info.get('xml', []) \
-                + info.get('translation', []) \
-                + ['delivery_note.odt',],
+            + ['tryton.cfg', 'locale/*.po', '*.odt'],
     },
     classifiers=[
         'Development Status :: 5 - Production/Stable',
 from trytond.pool import Pool
 from trytond.modules.company import CompanyReport
 
+__all__ = ['DeliveryValued']
+
 class DeliveryValued(CompanyReport):
-    _name = 'stock.shipment.out.delivery_valued'
+    'Stock Delivery Report Valued'
+    __name__ = 'stock.shipment.out.delivery_valued'
 
-    def parse(self, report, objects, datas, localcontext):
+    @classmethod
+    def parse(cls, report, objects, data, localcontext):
         localcontext['product_name'] = lambda product_id, language: \
-                self.product_name(product_id, language)
-        return super(DeliveryValued, self).parse(report, objects, datas,
+                cls.product_name(product_id, language)
+        return super(DeliveryValued, cls).parse(report, objects, data,
                 localcontext)
 
-    def product_name(self, product_id, language):
-        product_obj = Pool().get('product.product')
+    @classmethod
+    def product_name(cls, product_id, language):
+        Product = Pool().get('product.product')
         with Transaction().set_context(language=language):
-            return product_obj.browse(product_id).rec_name
-
-DeliveryValued()
+            return Product(product_id).rec_name
+[tryton]
+version=2.6.0
+depends:
+    company
+    stock
+    stock_valued
+    res
+    ir
+    currency
+    product
+xml:
+    shipment.xml