Comment 5 for bug 1313689

Revision history for this message
Laurent Mignon (Acsone) (lmi) wrote : Re: [Bug 1313689] Re: [7.0] account_statement_base_import: default account_id to false (mp:197755) breaks import of line without account_id

Hi Joël,

You're right.

Thanks for the changes,

Regards,

lmi

On Wed, May 7, 2014 at 11:55 AM, Joël Grand-Guillaume @ camptocamp <
<email address hidden>> wrote:

> Hi Laurent,
>
>
> Thanks for the feedback here ! For the second point, I think it's not
> necessary to have such a "default" rules. My args are:
>
> * First, a profil will at least have one rule to compute the account
> (and/or partner) so in any case the completion will provide one, even
> after this modification
>
> * If it is not the case anyway, why a rule must set the account_id on
> completion ? We have a default value for account_id through the
> _defaults = {'account_id': _get_default_account,} that call the
> get_values_for_line. The completion will only do the same a second time.
>
> * Entering the line manually will call the on_change of the
> bank_statement_ext and provide an account_id
>
> So in the following use cases, I see no trouble,:
>
> * Entering a statement line manually with *_base_completion installed or
> not will set a default account_id
> * Importing lines with *_base_import installed and no account provided,
> the account_id will be set on completion following the rules as all of them
> at least give the account_id.
>
> Do I miss one ?
>
>
> Regards,
>
> Joël
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1313689
>
> Title:
> [7.0] account_statement_base_import: default account_id to false
> (mp:197755) breaks import of line without account_id
>
> Status in OpenERP Banking Addons:
> Confirmed
>
> Bug description:
> For performance reasons, the creation of lines in the
> account_statement_base_import is done by bypassing the ORM . (method
> _insert_lines defined in
> account_base_completion.statement.AccountStatementLine). The method
> _insert_lines must be called with a list of values (as dict) used to
> build a plain batch SQL insert 'INSERT INTO
> account_bank_statement_line (%s) VALUES (%s)'
>
> The problem with the mp:197755 (https://code.launchpad.net/~akretion-
> team/banking-addons/bank-statement-reconcile-70-account-not-
> mandatory/+merge/197755) is that if no value is provided for the
> account_id by the parser, the default value is added by the call to
> "statement_line_obj._add_missing_default_values(cr, uid, values,
> context)" at line 130 in account_statement_base_import.statement.py.
> (values = [.... {..., 'account_id':False, ..} ... ] )
>
> As these values are used to build a plain SQL insert (" Insert into
> .... (..., account_id) values ((...,False )) the method fails with the
> exception: except_osv:
> (u'Statement import error', u'The statement cannot be created: Error:
> except_osv\nDescription: (u\'ORM bypass error\', \'ERROR: column
> "account_id" is of type integer but expression is of type boolean\\nLINE 1:
> ...note, period_id, ref, statement_id, type) VALUES (false, \\\'{"...\\n
> ^\\nHINT: You
> will need to rewrite or cast the expression.\\n\')\nTraceback: File
> "/home/lmi/projects/openerp/openerp-deldrive-multi-company/addons-banking/account_statement_base_import/statement.py",
> line 195, in statement_import\n statement_line_obj._insert_lines(cr,
> uid, statement_store, context=context)\n File
> "/home/lmi/projects/openerp/openerp-deldrive-multi-company/addons-banking/account_statement_base_completion/statement.py",
> line 479, in _insert_lines\n sql_err.pgerror)\n')
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/banking-addons/+bug/1313689/+subscriptions
>

--
*Laurent Mignon*
*Senior Software Engineer*

*Tel : +352 20 21 10 20 32*
*Fax : +352 20 21 10 21*
*Gsm : +352 691 506 009*
*Email: <email address hidden> <email address hidden>*

*Acsone SA, Succursale de Luxembourg*
*22, Zone industrielle*
*L-8287 Kehlen, Luxembourg*
*www.acsone.eu <http://www.acsone.eu>*