Commits

Raimon Esteve (Zikzakmedia) committed 8d95a8b

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 sale_waiting module of the Tryton application platform.
-See __tryton__.py
 
 Installing
 ----------
 #This file is part sale_waiting 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 .sale import *
 
-from .sale import *
+
+def register():
+    Pool.register(
+        Sale,
+        module='sale_waiting', type_='model')

__tryton__.py

-#This file is part sale_waiting module for Tryton.
-#The COPYRIGHT file at the top level of this repository contains 
-#the full copyright notices and license terms.
-{
-    'name': 'Sale Waiting',
-    'name_ca_ES': 'Estat en espera a les vendes',
-    'name_es_ES': 'Estado en espera a las ventas',
-    'version': '2.4.0',
-    'author': 'Zikzakmedia',
-    'email': 'zikzak@zikzakmedia.com',
-    'website': 'http://www.zikzakmedia.com/',
-    'description': '''Add new option state in sale.sale: waiting.
-It also modifies the workflow of sale by adding a new step state.
-''',
-    'description_ca_ES': '''Afegeix una nova opció a comandes: waiting.
-Modifica el fluxe de les comandes afegint un nou pas en espera a la venta.
-''',
-    'description_es_ES': '''Añade una nueva opción a pedidos: waiting.
-Modifica el flujo de los pedidos añadiendo una nueva opción en espera a la venta.
-''',
-    'depends': [
-        'ir',
-        'res',
-        'sale',
-    ],
-    'xml': [
-        'sale.xml',
-    ],
-    'translation': [
-        'locale/ca_ES.po',
-        'locale/es_ES.po',
-    ]
-}
 #The COPYRIGHT file at the top level of this repository contains 
 #the full copyright notices and license terms.
 
-from trytond.model import Workflow, ModelView, ModelSQL, fields
-from trytond.pyson import Eval
-from trytond.transaction import Transaction
-from trytond.pool import Pool
+from trytond.model import Workflow, ModelView, fields
+from trytond.pyson import If, Eval
+from trytond.pool import PoolMeta
 
-class Sale(Workflow, ModelSQL, ModelView):
-    _name = 'sale.sale'
+__all__ = ['Sale']
+__metaclass__ = PoolMeta
+
+class Sale:
+    'Sale'
+    __name__ = 'sale.sale'
 
     state = fields.Selection([
         ('draft', 'Draft'),
         ('done', 'Done'),
         ('cancel', 'Canceled'),
         ('waiting', 'Waiting'),
-    ], 'State', readonly=True, required=True)
+    ], 'State', required=True, readonly=True)
+    sale_date = fields.Date('Sale Date',
+        states={
+            'readonly': ~Eval('state').in_(['draft', 'quotation']),
+            'required': ~Eval('state').in_(['draft', 'quotation', 'cancel','waiting']),
+            },
+        depends=['state'])
 
-    def __init__(self):
-        super(Sale, self).__init__()
-        self._transitions |= set((
+    @classmethod
+    def __setup__(cls):
+        super(Sale, cls).__setup__()
+        cls._transitions |= set((
                 ('draft', 'quotation'),
                 ('quotation', 'confirmed'),
                 ('confirmed', 'processing'),
                 ('waiting', 'draft'),
                 ('waiting', 'quotation'),
                 ))
-        self._buttons.update({
+        cls._buttons.update({
                 'draft': {
-                    'invisible': ~Eval('state').in_(['quotation', 'waiting']),
+                    'invisible': ~Eval('state').in_(['cancel', 'quotation', 'waiting']),
+                    'icon': If(Eval('state') == 'cancel', 'tryton-clear',
+                        'tryton-go-previous'),
                     },
                 'set_waiting': {
                     'invisible': Eval('state') != 'waiting',
                     },
                 })
 
+    @classmethod
     @ModelView.button
     @Workflow.transition('waiting')
-    def waiting(self, ids):
-        self.set_sale_date(ids)
+    def waiting(cls, sales):
         pass
 
-    @ModelView.button
-    def set_waiting(self, ids):
-        quotes = []
-        for sale in self.browse(ids):
+    @classmethod
+    def set_waiting(cls, sales):
+        for sale in sales:
             if sale.state == 'waiting':
-                quotes.append(sale.id)
-        self.write(quotes, {
+                cls.write([sale], {
                 'state': 'quotation',
                 })
-
-Sale()
                     <xpath
                         expr="/form/notebook/page[@id=&quot;sale&quot;]/group[@id=&quot;amount_buttons&quot;]/group[@id=&quot;buttons&quot;]/button[@name=&quot;draft&quot;]"
                         position="after">
-                        <button name="set_waiting" type="object" string="Approve Sale"
-                            icon="tryton-go-next"/>
+                        <button name="set_waiting" string="Approve Sale" icon="tryton-go-next"/>
                     </xpath>
                 </data>
                 ]]>
 
 setup(name='trytond_sale_waiting',
     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 new state in sales: wainting',
+    author='Zikzakmedia SL',
+    author_email='zikzak@zikzakmedia.com',
+    url='http://www.zikzakmedia.com',
     download_url="https://bitbucket.org/zikzakmedia/trytond-sale_waiting",
     package_dir={'trytond.modules.sale_waiting': '.'},
     packages=[
     ],
     package_data={
         'trytond.modules.sale_waiting': info.get('xml', []) \
-                + info.get('translation', []),
+            + ['tryton.cfg', 'locale/*.po'],
     },
     classifiers=[
         'Development Status :: 5 - Production/Stable',
+[tryton]
+version=2.6.0
+depends:
+    ir
+    res
+    sale
+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.