1. zikzakmedia
  2. trytond-party_event

Commits

Raimon Esteve  committed 950d8df

Active Record

  • Participants
  • Parent commits b982419
  • Branches default

Comments (0)

Files changed (9)

File CHANGELOG

View file
  • Ignore whitespace
+Version 2.6.0 - 2012-10-11
+* Active Record
+* Simplify module information with python configuration
+
 Version 2.4.0 - 2012-09-06
 * Initial release

File MANIFEST.in

View file
  • Ignore whitespace
 include COPYRIGHT
 include LICENSE
 include *.xml
-include *.odt
 include locale/*.po
 include doc/*

File README

View file
  • Ignore whitespace
 ===================
 
 The party_event module of the Tryton application platform.
-See __tryton__.py
 
 Installing
 ----------

File __init__.py

View file
  • Ignore whitespace
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
 
+from trytond.pool import Pool
 from .party_event import *
 from .party import *
+
+def register():
+    Pool.register(
+        PartyEvent,
+        Party,
+        module='party_event', type_='model')

File __tryton__.py

  • Ignore whitespace
-#This file is part party_event module for Tryton.
-#The COPYRIGHT file at the top level of this repository contains 
-#the full copyright notices and license terms.
-{
-    'name': 'Party Event',
-    'name_ca_ES': 'Historial de tercers',
-    'name_es_ES': 'Historial de terceros',
-    'version': '2.4.0',
-    'author': 'Zikzakmedia',
-    'email': 'zikzak@zikzakmedia.com',
-    'website': 'http://www.zikzakmedia.com/',
-    'description': '''History party communication. Extra modules add events''',
-    'description_ca_ES': '''Historial de comunicació de tercers. Moduls extres afegeixen els esdeveniments''',
-    'description_es_ES': '''Historial de comunicación de terceros. Módulos externos añaden los eventos''',
-    'depends': [
-        'ir',
-        'res',
-        'party',
-    ],
-    'xml': [
-        'party_event.xml',
-        'party.xml',
-    ],
-    'translation': [
-        'locale/ca_ES.po',
-        'locale/es_ES.po',
-    ]
-}

File party.py

View file
  • Ignore whitespace
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
 
-from trytond.model import Model, fields
+from trytond.model import fields
+from trytond.pool import PoolMeta
 
-class Party(Model):
-    _name = 'party.party'
+__all__ = ['Party']
+__metaclass__ = PoolMeta
+
+class Party:
+    __name__ = 'party.party'
 
     events = fields.One2Many('party.event', 'party', 'Events')
 
-Party()

File party_event.py

View file
  • Ignore whitespace
 
 import datetime
 
+__all__ = ['PartyEvent']
+
 _TYPES = [
     ('phone', 'Phone'),
     ('mobile', 'Mobile'),
 
 class PartyEvent(ModelSQL, ModelView):
     'Party Event'
-    _name = 'party.event'
-    _description = __doc__
+    __name__ = 'party.event'
     _order_name = 'date'
 
     type = fields.Selection(_TYPES, 'Type', required=True, sort=False)
     resource = fields.Reference('Resource', selection='get_resource')
     user = fields.Many2One('res.user', 'User', required=True)
 
-    def __init__(self):
-        super(PartyEvent, self).__init__()
-        self._order.insert(0, ('event_date', 'DESC'))
-        self._error_messages.update({
+    @classmethod
+    def __setup__(cls):
+        super(PartyEvent, cls).__setup__()
+        cls._order.insert(0, ('event_date', 'DESC'))
+        cls._error_messages.update({
             'no_subject': 'No subject',
         })
 
-    def default_type(self):
+    @staticmethod
+    def default_type():
         return 'email'
 
-    def default_event_date(self):
+    @staticmethod
+    def default_event_date():
         return datetime.datetime.now()
 
-    def default_user(self):
+    @staticmethod
+    def default_user():
         return Transaction().user
 
-    def get_resource(self):
+    @classmethod
+    def get_resource(cls):
         '''Get Resources. Rewrite this method to add new resource references'''
         res = []
         return res
 
-    def get_rec_name(self, ids, name):
-        if not ids:
+    @classmethod
+    def get_rec_name(cls, records, name):
+        if not records:
             return {}
         res = {}
-        for mail in self.browse(ids):
+        for mail in records:
             res[mail.id] = mail.subject
         return res
 
         except:
             pass
         return True
-
-PartyEvent()

File setup.py

View file
  • Ignore whitespace
 
 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_party_event',
     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 to add Party Events',
+    author='Zikzakmedia SL',
+    author_email='zikzak@zikzakmedia.com',
+    url='http://www.zikzakmedia.com',
     download_url="https://bitbucket.org/zikzakmedia/trytond-party_event",
     package_dir={'trytond.modules.party_event': '.'},
     packages=[
     ],
     package_data={
         'trytond.modules.party_event': info.get('xml', []) \
-                + info.get('translation', []),
+            + ['tryton.cfg', 'locale/*.po'],
     },
     classifiers=[
         'Development Status :: 5 - Production/Stable',

File tryton.cfg

View file
  • Ignore whitespace
+[tryton]
+version=2.6.0
+depends:
+    ir
+    res
+    party
+xml:
+    party_event.xml
+    party.xml