Commits

Raimon Esteve (Zikzakmedia) committed 58e2319

Active Record

Comments (0)

Files changed (8)

+Version 2.6.0 - 2012-10-16
+* Active Record
+* Simplify module information with python configuration
+
 Version 2.4.0 - 2012-07-23
 * Initial release
 =========================
 
 The stock_origin_sale module of the Tryton application platform.
-See __tryton__.py
 
 Installing
 ----------
 #This file is part stock_origin_sale 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 .sale import *
+
+
+def register():
+    Pool.register(
+        Sale,
+        ShipmentOut,
+        module='stock_origin_sale', type_='model')

__tryton__.py

-#This file is part stock_origin_sale module for Tryton.
-#The COPYRIGHT file at the top level of this repository contains 
-#the full copyright notices and license terms.
-{
-    'name': 'Stock Origin Sale',
-    'name_ca_ES': 'Origen estoc de comanda de compra',
-    'name_es_ES': 'Origen stock de pedido de venta',
-    'version': '2.4.0',
-    'author': 'Zikzakmedia',
-    'email': 'zikzak@zikzakmedia.com',
-    'website': 'http://www.zikzakmedia.com/',
-    'description': '''Add origin of shipment: Sale''',
-    'description_ca_ES': '''Afegeix l'origen del albarà: comanda de venda''',
-    'description_es_ES': '''Añade el origen del albarán: pedido de venta''',
-    'depends': [
-        'ir',
-        'res',
-        'stock',
-        'stock_origin',
-        'sale',
-    ],
-    'xml': [
-    ],
-    'translation': [
-    ]
-}
 #This file is part stock_origin_purchase 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, PoolMeta
 
-from trytond.model import ModelView, ModelSQL, fields
-from trytond.transaction import Transaction
-from trytond.pool import Pool
+__all__ = ['Sale']
+__metaclass__ = PoolMeta
 
-class Sale(ModelSQL, ModelView):
-    _name = 'sale.sale'
+class Sale:
+    'Sale'
+    __name__ = 'sale.sale'
 
-    def create_shipment(self, sale, shipment_type):
-        shipments = super(Sale, self).create_shipment(sale, shipment_type)
+    def create_shipment(self, shipment_type):
+        shipments = super(Sale, self).create_shipment(shipment_type)
         if shipment_type == 'out':
-            shipment_obj = Pool().get('stock.shipment.out')
+            Shipment = Pool().get('stock.shipment.out')
         elif shipment_type == 'return':
-            shipment_obj = Pool().get('stock.shipment.out.return')
+            Shipment = Pool().get('stock.shipment.out.return')
         else:
             return None
 
         if shipments:
             for shipment in shipments:
                 values = {
-                    'origin': 'sale.sale,%s' % (sale.id),
+                    'origin': 'sale.sale,%s' % (self.id),
                 }
-                shipment_id = shipment_obj.write([shipment], values)
+                Shipment.write([shipment], values)
+        return shipments
 
-Sale()
 
 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_origin_sale',
     version=info.get('version', '0.0.1'),
-    description=info.get('description', ''),
-    author=info.get('author', 'Zikzakmedia'),
-    author_email=info.get('email', 'zikzak@zikzakmedia.com'),
-    url=info.get('website', 'http://www.zikzakmedia.com'),
+    description='Tryton module for sale stock origin',
+    author='Zikzakmedia SL',
+    author_email='zikzak@zikzakmedia.com',
+    url='http://www.zikzakmedia.com',
     download_url="https://bitbucket.org/zikzakmedia/trytond-stock_origin_sale",
     package_dir={'trytond.modules.stock_origin_sale': '.'},
     packages=[
     ],
     package_data={
         'trytond.modules.stock_origin_sale': info.get('xml', []) \
-                + info.get('translation', []),
+            + ['tryton.cfg'],
     },
     classifiers=[
         'Development Status :: 5 - Production/Stable',
 #This file is part stock_origin_sale 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, PoolMeta
 
-from trytond.model import ModelView, ModelSQL, fields
-from trytond.transaction import Transaction
-from trytond.pool import Pool
+__all__ = ['ShipmentOut']
+__metaclass__ = PoolMeta
 
-class ShipmentOut(ModelSQL, ModelView):
-    _name = 'stock.shipment.out'
+class ShipmentOut:
+    "Customer Shipment"
+    __name__ = 'stock.shipment.out'
 
-    def origin_get(self):
-        res = super(ShipmentOut, self).origin_get()
-        model_obj = Pool().get('ir.model')
-        model_ids = model_obj.search([
-            ('model', '=', 'sale.sale'),
-            ])
-        for model in model_obj.browse(model_ids):
-            res.append([model.model, model.name])
-        return res
-
-ShipmentOut()
+    @classmethod
+    def _get_origin(cls):
+        return super(ShipmentOut, cls)._get_origin() + ['sale.sale']
+[tryton]
+version=2.6.0
+depends:
+    ir
+    res
+    stock
+    stock_origin
+    sale
+xml: