Reviewers: ,


Please review this at http://codereview.tryton.org/494002/

Affected files:
  M __init__.py
  M invoice.py


Index: __init__.py
===================================================================

--- a/__init__.py
+++ b/__init__.py
@@ -1,4 +1,12 @@
 #This file is part of 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 .invoice import *
+
+
+def register():
+    Pool.register(
+        Invoice,
+        InvoiceLine,
+        module='account_invoice_line_standalone', type_='model')

Index: invoice.py
===================================================================

--- a/invoice.py
+++ b/invoice.py
@@ -1,17 +1,19 @@
 #This file is part of Tryton.  The COPYRIGHT file at the top level of
 #this repository contains the full copyright notices and license terms.
-import copy
-from trytond.model import ModelView, ModelSQL
 from trytond.pyson import Eval
 from trytond.transaction import Transaction
+from trytond.pool import PoolMeta

+__all__ = ['Invoice', 'InvoiceLine']
+__metaclass__ = PoolMeta

-class Invoice(ModelSQL, ModelView):
-    _name = 'account.invoice'

-    def __init__(self):
-        super(Invoice, self).__init__()
-        self.lines = copy.copy(self.lines)
+class Invoice:
+    __name__ = 'account.invoice'
+
+    @classmethod
+    def __setup__(cls):
+        super(Invoice, cls).__setup__()
         add_remove = [
             ('invoice_type', '=', Eval('type')),
             ('party', '=', Eval('party')),
@@ -20,28 +22,23 @@
             ('invoice', '=', None),
         ]

-        if not self.lines.add_remove:
-            self.lines.add_remove = add_remove
+        if not cls.lines.add_remove:
+            cls.lines.add_remove = add_remove
         else:
-            self.lines.add_remove = copy.copy(self.lines.add_remove)
-            self.lines.add_remove = [
+            cls.lines.add_remove = [
                 add_remove,
-                self.lines.add_remove,
-            ]
-        self._reset_columns()
+                cls.lines.add_remove,
+                ]

-Invoice()

+class InvoiceLine:
+    __name__ = 'account.invoice.line'

-class InvoiceLine(ModelSQL, ModelView):
-    _name = 'account.invoice.line'
-
-    def _view_look_dom_arch(self, tree, type, field_children=None):
+    @classmethod
+    def _view_look_dom_arch(cls, tree, type, field_children=None):
         if type == 'form' and Transaction().context.get('standalone'):
             tree_root = tree.getroottree().getroot()
             if tree_root.get('cursor') == 'product':
                 tree_root.set('cursor', 'party')
-        return super(InvoiceLine, self)._view_look_dom_arch(tree, type,
+        return super(InvoiceLine, cls)._view_look_dom_arch(tree, type,
             field_children=field_children)
-
-InvoiceLine()



--
[email protected] mailing list

Reply via email to