Rucha (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-account-move-line-context-imp-rpa into 
lp:openobject-addons.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-move-line-context-imp-rpa/+merge/90425

Made improvements for:
-----------------------------
in web client, you can't open anymore an account.move.line in form view, 
because it crashes due to line_id in context.
Giving the value of a o2m field in its own context is not supported, so we need 
to remove it.
it will work, but if we do so, we will loose a feature that we need to keep the 
encoding by line

so, in order to fix that without the loss of feature, we need to
* define a new field on account.move: balance
* on_change of the line_id field, we update the balance field
* in the views, we replace the line_id in context with the new balance field 
(which is hidden/invisible by default)
-----------------

Proposed improvements are working fine but not perfect, I think this still 
needed to be improved. Kindly review it and share your thoughts.

Thanks,
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-account-move-line-context-imp-rpa/+merge/90425
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-account-move-line-context-imp-rpa.
=== modified file 'account/account.py'
--- account/account.py	2012-01-24 12:40:21 +0000
+++ account/account.py	2012-01-27 12:58:29 +0000
@@ -1270,7 +1270,9 @@
         'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}, select=True),
         'narration':fields.text('Internal Note'),
         'company_id': fields.related('journal_id','company_id',type='many2one',relation='res.company',string='Company', store=True, readonly=True),
+        'balance': fields.text('balance'),
     }
+
     _defaults = {
         'name': '/',
         'state': 'draft',
@@ -1352,6 +1354,19 @@
                        'WHERE id IN %s', ('draft', tuple(ids),))
         return True
 
+    def onchange_line_id(self, cr, uid, ids, line_ids, context=None):
+        """ This function returns value of o2m move lines in new field which we pass to the context of o2m move lines,
+        because giving the value of a o2m field in its own context is not supported in web-client
+         @param self: The object pointer.
+         @param cr: A database cursor
+         @param uid: ID of the user currently logged in
+         @param ids: the ID or list of IDs
+         @param context: A standard dictionary
+
+         @return: dictionary of changed value
+        """
+        return {'value': {'balance': str(line_ids)}}
+
     def write(self, cr, uid, ids, vals, context=None):
         if context is None:
             context = {}

=== modified file 'account/account_move_line.py'
--- account/account_move_line.py	2011-12-31 07:57:20 +0000
+++ account/account_move_line.py	2012-01-27 12:58:29 +0000
@@ -228,9 +228,9 @@
         # Compute simple values
         data = super(account_move_line, self).default_get(cr, uid, fields, context=context)
         # Starts: Manual entry from account.move form
-        if context.get('lines',[]):
-            total_new = 0.00
-            for i in context['lines']:
+        if context.get('lines'):
+            total_new = 0.0
+            for i in eval(context['lines']):
                 if i[2]:
                     total_new += (i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00)
                     for item in i[2]:

=== modified file 'account/account_view.xml'
--- account/account_view.xml	2012-01-26 17:19:55 +0000
+++ account/account_view.xml	2012-01-27 12:58:29 +0000
@@ -1364,7 +1364,10 @@
                     </group>
                     <notebook colspan="4">
                         <page string="Journal Items">
-                            <field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list" context="{'lines':line_id ,'journal':journal_id }">
+                            <field name="balance" invisible="1"/>
+                            <field colspan="4" name="line_id" nolabel="1" height="250" widget="one2many_list" 
+                            on_change="onchange_line_id(line_id)"
+                            context="{'lines': balance , 'journal': journal_id }">
                                 <form string="Journal Item">
                                     <group col="6" colspan="4">
                                         <field name="name"/>

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to