Raimon Esteve (Zikzakmedia) avatar Raimon Esteve (Zikzakmedia) committed 7b0be4e

Active Record

Comments (0)

Files changed (14)

+Version 2.6.0 - 2012-10-08
+* Simplify module information with python configuration
+* Active Record
+
 Version 2.4.0 - 2012-06-18
 * Initial release
 include COPYRIGHT
 include LICENSE
 include *.xml
-include *.odt
 include locale/*.po
 include doc/*
 ============================
 
 The product_manufacturer module of the Tryton application platform.
-See __tryton__.py
 
 Installing
 ----------
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
 
+from trytond.pool import Pool
 from .move import *
 from .party import *
 from .product import *
 from .purchase import *
 from .sale import *
+
+
+def register():
+    Pool.register(
+        Move,
+        Party,
+        ProductTemplate,
+        ProductProduct,
+        PurchaseLine,
+        SaleLine,
+        module='product_manufacturer', type_='model')

__tryton__.py

-#This file is part product_manufacturer module for Tryton.
-#The COPYRIGHT file at the top level of this repository contains 
-#the full copyright notices and license terms.
-{
-    'name': 'Product Manufactuer',
-    'name_ca_ES': 'Fabricant del producte',
-    'name_es_ES': 'Fabricante del producto',
-    'version': '2.4.0',
-    'author': 'Zikzakmedia',
-    'email': 'zikzak@zikzakmedia.com',
-    'website': 'http://www.zikzakmedia.com/',
-    'description': '''Add manufactruer information: manufacturer, name and code
-''',
-    'description_ca_ES': '''Afegeix informació del fabricant al producte: fabricant, nom i codi
-''',
-    'description_es_ES': '''Añade información del fabricante al producto: fabricante, nombre y código
-''',
-    'depends': [
-        'ir',
-        'res',
-        'product',
-        'purchase',
-        'sale',
-        'stock',
-    ],
-    'xml': [
-        'move.xml',
-        'party.xml',
-        'product.xml',
-        'purchase.xml',
-        'sale.xml',
-    ],
-    'translation': [
-        'locale/ca_ES.po',
-        'locale/es_ES.po',
-    ]
-}
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.tools import safe_eval, datetime_strftime
 from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 
-class Move(ModelSQL, ModelView):
+__all__ = ['Move']
+__metaclass__ = PoolMeta
+
+class Move:
     "Stock Move"
-    _name = 'stock.move'
+    __name__ = 'stock.move'
 
     manufacturer = fields.Function(
         fields.Many2One('party.party', 'Manufacturer',
-            on_change=['product']),
-        'get_manufacturer')
+            on_change=['product']), 'get_manufacturer')
 
-    def get_manufacturer(self, ids, name):
+    @classmethod
+    def get_manufacturer(cls, records, name):
         result = {}
-        for line in self.browse(ids):
+        for line in records:
             result[line.id] = line.product.manufacturer.id
         return result
 
-    def on_change_product(self, values):
+    def on_change_product(self):
         """When change product, get manufacturer value"""
         product_obj = Pool().get('product.product')
-        res = super(Move, self).on_change_product(values)
-        product = values.get('product', False)
+        res = super(Move, self).on_change_product()
+        product = self.product or  False
         res['manufacturer'] = None
-        if values.get('product'):
-            product = product_obj.browse(values['product'])
+        if self.product:
+            product = self.product
             res['manufacturer'] = product.manufacturer and \
                     product.manufacturer.id or None
         return res
-
-Move()
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.tools import safe_eval, datetime_strftime
 from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 
-class Party(ModelSQL, ModelView):
+__all__ = ['Party']
+__metaclass__ = PoolMeta
+
+class Party:
     """Party"""
-    _name = 'party.party'
-    _description = __doc__
+    __name__ = 'party.party'
 
     manufacturer = fields.Boolean('Manufacturer',
         help="Check this box if the partner is a manufacturer.")
-
-Party()
-
-
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.tools import safe_eval, datetime_strftime
 from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval
 
-class ProductTemplate(ModelSQL, ModelView):
+__all__ = ['ProductTemplate', 'ProductProduct']
+__metaclass__ = PoolMeta
+
+class ProductTemplate:
     'Product Template'
-    _name = 'product.template'
-    _description = __doc__
+    __name__ = 'product.template'
 
     manufacturer = fields.Many2One('party.party', 'Manufacturer',
         domain=[('manufacturer', '=', True)])
 
-ProductTemplate()
-
-class ProductProduct(ModelSQL, ModelView):
+class ProductProduct:
     'Product Product'
-    _name = 'product.product'
-    _description = __doc__
+    __name__ = 'product.product'
 
     manufacturer_name =  fields.Char('Manufacturer Name')
     manufacturer_code =  fields.Char('Manufacturer Code')
-
-ProductProduct()
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.tools import safe_eval, datetime_strftime
 from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 
-class PurchaseLine(ModelSQL, ModelView):
+__all__ = ['PurchaseLine']
+__metaclass__ = PoolMeta
+
+class PurchaseLine:
     'Purchase Line'
-    _name = 'purchase.line'
-    _description = __doc__
+    __name__ = 'purchase.line'
 
     manufacturer = fields.Function(
         fields.Many2One('party.party', 'Manufacturer',
             on_change=['product']),
         'get_manufacturer')
 
-    def get_manufacturer(self, ids, name):
+    @classmethod
+    def get_manufacturer(cls, records, name):
         result = {}
-        for line in self.browse(ids):
+        for line in records:
             result[line.id] = line.product.manufacturer.id
         return result
 
-    def on_change_product(self, values):
+    def on_change_product(self):
         """When change product, get manufacturer value"""
         product_obj = Pool().get('product.product')
-        res = super(PurchaseLine, self).on_change_product(values)
-        product = values.get('product', False)
+        res = super(PurchaseLine, self).on_change_product()
+        product = self.product or  False
         res['manufacturer'] = None
-        if values.get('product'):
-            product = product_obj.browse(values['product'])
+        if self.product:
+            product = self.product
             res['manufacturer'] = product.manufacturer and \
                     product.manufacturer.id or None
         return res
 
-PurchaseLine()
                         expr="/form/notebook/page[@id="general"]/field[@name="product"]"
                         position="after">
                         <label name="manufacturer"/>
-                        <field name="manufacturer" xexpand="0" width="25"/>
+                        <field name="manufacturer"/>
                     </xpath>
                 </data>
                 ]]>
 from trytond.model import ModelView, ModelSQL, fields
 from trytond.tools import safe_eval, datetime_strftime
 from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.pool import Pool, PoolMeta
 
-class SaleLine(ModelSQL, ModelView):
+__all__ = ['SaleLine']
+__metaclass__ = PoolMeta
+
+class SaleLine:
     'Sale Line'
-    _name = 'sale.line'
-    _description = __doc__
+    __name__ = 'sale.line'
 
     manufacturer = fields.Function(
         fields.Many2One('party.party', 'Manufacturer',
             on_change=['product']),
         'get_manufacturer')
 
-    def get_manufacturer(self, ids, name):
+    @classmethod
+    def get_manufacturer(cls, records, name):
         result = {}
-        for line in self.browse(ids):
+        for line in records:
             result[line.id] = line.product.manufacturer.id
         return result
 
-    def on_change_product(self, values):
+    def on_change_product(self):
         """When change product, get manufacturer value"""
         product_obj = Pool().get('product.product')
-        res = super(SaleLine, self).on_change_product(values)
-        product = values.get('product', False)
+        res = super(SaleLine, self).on_change_product()
+        product = self.product or  False
         res['manufacturer'] = None
-        if values.get('product'):
-            product = product_obj.browse(values['product'])
+        if self.product:
+            product = self.product
             res['manufacturer'] = product.manufacturer and \
                     product.manufacturer.id or None
         return res
 
-SaleLine()
                         expr="/form/notebook/page[@id=&quot;general&quot;]/field[@name=&quot;product&quot;]"
                         position="after">
                         <label name="manufacturer"/>
-                        <field name="manufacturer" xexpand="0" width="25"/>
+                        <field name="manufacturer"/>
                     </xpath>
                 </data>
                 ]]>
 
 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_product_manufacturer',
     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 add Manufacturer Product',
+    author='Zikzakmedia SL',
+    author_email='zikzak@zikzakmedia.com',
+    url='http://www.zikzakmedia.com',
     download_url="https://bitbucket.org/zikzakmedia/trytond-product_manufacturer",
     package_dir={'trytond.modules.product_manufacturer': '.'},
     packages=[
     ],
     package_data={
         'trytond.modules.product_manufacturer': info.get('xml', []) \
-                + info.get('translation', []) \
-                + ['icons/*.svg'],
+            + ['tryton.cfg', 'locale/*.po'],
     },
     classifiers=[
         'Development Status :: 5 - Production/Stable',
+[tryton]
+version=2.6.0
+depends:
+    ir
+    res
+    product
+    purchase
+    sale
+    stock
+xml:
+    move.xml
+    party.xml
+    product.xml
+    purchase.xml
+    sale.xml
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.