← Back to team overview

banking-addons-team team mailing list archive

lp:~akretion-team/banking-addons/bank-statement-reconcile-70-account-not-mandatory into lp:banking-addons/bank-statement-reconcile-7.0

 

Sébastien BEAU - http://www.akretion.com has proposed merging lp:~akretion-team/banking-addons/bank-statement-reconcile-70-account-not-mandatory into lp:banking-addons/bank-statement-reconcile-7.0.

Requested reviews:
  Frederic Clementi - Camptocamp (frederic-clementi)

For more details, see:
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-account-not-mandatory/+merge/197755

Hi
By default the account on the bank statement line is mandatory, but when yu import an bank statement from a csv file we don't have any idea of the correct account should be put in the line.
For now we put a default account_id but I think it's a bad behaviour, because the user can validate the bank statement with default value.

I think it's better to make this field optional BUT to check if this field is filled when validating the bank statement.

What do you think?
-- 
https://code.launchpad.net/~akretion-team/banking-addons/bank-statement-reconcile-70-account-not-mandatory/+merge/197755
Your team Banking Addons Core Editors is subscribed to branch lp:banking-addons/bank-statement-reconcile-7.0.
=== modified file 'account_statement_base_completion/statement.py'
--- account_statement_base_completion/statement.py	2013-10-16 08:58:12 +0000
+++ account_statement_base_completion/statement.py	2013-12-04 17:07:27 +0000
@@ -382,6 +382,23 @@
         res.update(st_vals)
         return res
 
+class AccountStatement(orm.Model):
+    _inherit = "account.bank.statement"
+
+    def button_confirm_bank(self, cr, uid, ids, context=None):
+        line_obj = self.pool['account.bank.statement.line']
+        for stat_id in ids:
+            line_without_account = line_obj.search(cr, uid, [
+                ['statement_id', '=', stat_id],
+                ['account_id', '=', False],
+                ], context=context)
+            if line_without_account:
+                stat = self.browse(cr, uid, stat_id, context=context)
+                raise osv.except_osv(_('User error'),
+                        _('You should fill all account on the line of the'
+                        ' statement %s')%stat.name)
+        return super(AccountStatement, self).button_confirm_bank(cr, uid, ids, context=context)
+
 
 class AccountStatementLine(orm.Model):
     """
@@ -393,6 +410,7 @@
     module to see how we've done it.
     """
     _inherit = "account.bank.statement.line"
+    _order = "already_completed desc, date asc"
 
     _columns = {
         'additionnal_bank_fields': fields.serialized(

=== modified file 'account_statement_base_import/statement.py'
--- account_statement_base_import/statement.py	2013-09-12 09:05:01 +0000
+++ account_statement_base_import/statement.py	2013-12-04 17:07:27 +0000
@@ -103,12 +103,6 @@
         statement_obj = self.pool.get('account.bank.statement')
         values = parser_vals
         values['statement_id'] = statement_id
-        values['account_id'] = statement_obj.get_account_for_counterpart(cr,
-                                                                         uid,
-                                                                         parser_vals['amount'],
-                                                                         account_receivable,
-                                                                         account_payable)
-
         date = values.get('date')
         period_memoizer = context.get('period_memoizer')
         if not period_memoizer:
@@ -214,3 +208,12 @@
             raise osv.except_osv(_("Statement import error"),
                                  _("The statement cannot be created: %s") % st)
         return statement_id
+        
+    
+class AccountBankStatementLine(orm.Model):
+    _inherit = "account.bank.statement.line"
+
+    _columns = { 
+        'account_id': fields.many2one('account.account','Account'),
+    }   
+ 

=== modified file 'account_statement_base_import/statement_view.xml'
--- account_statement_base_import/statement_view.xml	2013-06-12 17:54:18 +0000
+++ account_statement_base_import/statement_view.xml	2013-12-04 17:07:27 +0000
@@ -26,5 +26,22 @@
         </field>
     </record>
 
+
+   <record id="bank_statement_view_form" model="ir.ui.view">
+         <field name="name">account_bank_statement.bank_statement.view_form</field>
+         <field name="model">account.bank.statement</field>
+         <field name="inherit_id" ref="account_statement_base_completion.bank_statement_view_form" />
+         <field name="type">form</field>
+         <field eval="20" name="priority"/>
+         <field name="arch" type="xml">
+             <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='account_id']" position="attributes">
+                 <attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
+             </xpath>
+             <xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='account_id']" position="attributes">
+                 <attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
+             </xpath>
+         </field>
+     </record>
+
 </data>
 </openerp>


Follow ups