Minor import fixes plus a couple of other small changes to allow trunk install. Changed method get_default_pay_receive_accounts of account_statement_ext to use orm built in get. Is actually an improvement as get ensures the result is the most specific property whereas the original method gave no such guarentee in a multicompany environment.

Without this this method will fail on trunk and am surprised if it worked on 7.0, however the change is backward compatible with 7.0 and more efficient and less code.
This commit is contained in:
unknown
2014-05-14 17:45:12 +02:00
committed by Yannick Vaucher
9 changed files with 36 additions and 49 deletions

View File

@@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement base completion", {'name': "Bank statement base completion",
'version': '1.0.2', 'version': '1.0.3',
'author': 'Camptocamp', 'author': 'Camptocamp',
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',

View File

@@ -20,7 +20,7 @@
################################################################################# #################################################################################
from openerp.osv.orm import Model from openerp.osv.orm import Model
from openerp.osv import fields, osv from openerp.osv import fields
class res_partner(Model): class res_partner(Model):
@@ -32,7 +32,7 @@ class res_partner(Model):
_columns = { _columns = {
'bank_statement_label': fields.char('Bank Statement Label', size=100, 'bank_statement_label': fields.char('Bank Statement Label', size=100,
help="Enter the various label found on your bank statement separated by a ; If \ help="Enter the various label found on your bank statement separated by a ; If "
one of this label is include in the bank statement line, the partner will be automatically \ "one of this label is include in the bank statement line, the partner will be automatically "
filled (as long as you use this method/rules in your statement profile)."), "filled (as long as you use this method/rules in your statement profile)."),
} }

View File

@@ -24,16 +24,17 @@ import sys
import logging import logging
import simplejson import simplejson
import inspect import inspect
import datetime
import psycopg2 import psycopg2
from collections import defaultdict from collections import defaultdict
import re import re
from tools.translate import _ from openerp.tools.translate import _
from openerp.osv import osv, orm, fields from openerp.osv import osv, orm, fields
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from operator import attrgetter from operator import attrgetter
import datetime
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -256,7 +257,7 @@ class AccountStatementCompletionRule(orm.Model):
st_obj = self.pool.get('account.bank.statement.line') st_obj = self.pool.get('account.bank.statement.line')
res = {} res = {}
# As we have to iterate on each partner for each line, # As we have to iterate on each partner for each line,
# we memoize the pair to avoid #  we memoize the pair to avoid
# to redo computation for each line. # to redo computation for each line.
# Following code can be done by a single SQL query # Following code can be done by a single SQL query
# but this option is not really maintanable # but this option is not really maintanable
@@ -605,7 +606,7 @@ class AccountBankStatement(orm.Model):
st += ''.join(traceback.format_tb(trbk, 30)) st += ''.join(traceback.format_tb(trbk, 30))
_logger.error(st) _logger.error(st)
if res: if res:
#stat_line_obj.write(cr, uid, [line.id], vals, context=ctx) # stat_line_obj.write(cr, uid, [line.id], vals, context=ctx)
try: try:
stat_line_obj._update_line(cr, uid, res, context=context) stat_line_obj._update_line(cr, uid, res, context=context)
except Exception as exc: except Exception as exc:

View File

@@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement extension and profiles", {'name': "Bank statement extension and profiles",
'version': '1.3.5', 'version': '1.3.6',
'author': 'Camptocamp', 'author': 'Camptocamp',
'maintainer': 'Camptocamp', 'maintainer': 'Camptocamp',
'category': 'Finance', 'category': 'Finance',

View File

@@ -22,7 +22,7 @@ from openerp.report import report_sxw
from openerp.tools.translate import _ from openerp.tools.translate import _
from openerp import pooler from openerp import pooler
from datetime import datetime from datetime import datetime
from report_webkit import webkit_report from openerp.addons.report_webkit import webkit_report
class BankStatementWebkit(report_sxw.rml_parse): class BankStatementWebkit(report_sxw.rml_parse):

View File

@@ -434,7 +434,7 @@ class AccountBankStatement(Model):
if errors_stack: if errors_stack:
msg = u"\n".join(errors_stack) msg = u"\n".join(errors_stack)
raise osv.except_osv(_('Error'), msg) raise osv.except_osv(_('Error'), msg)
#end changes # end changes
self.write(cr, uid, [st.id], self.write(cr, uid, [st.id],
{'name': st_number, {'name': st_number,
'balance_end_real': st.balance_end}, 'balance_end_real': st.balance_end},
@@ -537,31 +537,15 @@ class AccountBankStatement(Model):
:return: tuple of int/long ID that give account_receivable, account_payable based on :return: tuple of int/long ID that give account_receivable, account_payable based on
company default. company default.
""" """
account_receivable = False
account_payable = False
property_obj = self.pool.get('ir.property')
model_fields_obj = self.pool.get('ir.model.fields')
model_fields_ids = model_fields_obj.search(
cr,
uid,
[('name', 'in', ['property_account_receivable',
'property_account_payable']),
('model', '=', 'res.partner')],
context=context
)
property_ids = property_obj.search(cr,
uid,
[('fields_id', 'in', model_fields_ids),
('res_id', '=', False)],
context=context)
for erp_property in property_obj.browse( property_obj = self.pool.get('ir.property')
cr, uid, property_ids, context=context): account_receivable = property_obj.get(cr, uid, 'property_account_receivable',
if erp_property.fields_id.name == 'property_account_receivable': 'res.partner', context=context)
account_receivable = erp_property.value_reference.id account_payable = property_obj.get(cr, uid, 'property_account_payable',
elif erp_property.fields_id.name == 'property_account_payable': 'res.partner', context=context)
account_payable = erp_property.value_reference.id
return account_receivable, account_payable return (account_receivable and account_receivable.id or False,
account_payable and account_payable.id or False)
def balance_check(self, cr, uid, st_id, journal_type='bank', context=None): def balance_check(self, cr, uid, st_id, journal_type='bank', context=None):
""" """

View File

@@ -96,13 +96,9 @@
<field name="model">account.bank.statement</field> <field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form"/> <field name="inherit_id" ref="account.view_bank_statement_form"/>
<field name="type">form</field> <field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml" >
<!-- Add before the group : profile and related infos --> <!-- Add before the group : profile and related infos -->
<field name="journal_id" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<label for="name" position="before"> <label for="name" position="before">
<group> <group>
<field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/> <field name="profile_id" select="1" required="1" on_change="onchange_imp_config_id(profile_id)" widget="selection"/>
@@ -110,7 +106,11 @@
</group> </group>
</label> </label>
# Make balance visible or not depending on profile <field name="journal_id" position="attributes">
<attribute name="invisible">True</attribute>
</field>
<!-- Make balance visible or not depending on profile -->
<field name="balance_start" position="attributes"> <field name="balance_start" position="attributes">
<attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute> <attribute name="attrs">{'invisible':[('balance_check','=',False)]}</attribute>
</field> </field>
@@ -128,7 +128,7 @@
<xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before"> <xpath expr="//field[@name='line_ids']/form//field[@name='date']" position="before">
<field name="id" readonly="1" /> <field name="id" readonly="1" />
</xpath> </xpath>
# Adapt onchange signature <!-- Adapt onchange signature -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace"> <xpath expr="//field[@name='line_ids']/tree/field[@name='partner_id']" position="replace">
<field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/> <field name="partner_id" on_change="onchange_partner_id(partner_id,parent.profile_id)" domain="['|',('parent_id','=',False),('is_company','=',True)]"/>
</xpath> </xpath>
@@ -139,7 +139,7 @@
<xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace"> <xpath expr="//field[@name='line_ids']/form//field[@name='type']" position="replace">
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/> <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)"/>
</xpath> </xpath>
# also set type hidden as it has no impact on reconciliation <!-- also set type hidden as it has no impact on reconciliation -->
<xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace"> <xpath expr="//field[@name='line_ids']/tree/field[@name='type']" position="replace">
<field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/> <field name="type" on_change="onchange_type(partner_id, type, parent.profile_id)" invisible="1"/>
</xpath> </xpath>

View File

@@ -21,7 +21,7 @@
############################################################################## ##############################################################################
{'name': "Bank statement OFX import", {'name': "Bank statement OFX import",
'version': '1.0', 'version': '1.0.1',
'author': 'Servicios Tecnológicos Avanzados - Pedro M. Baeza', 'author': 'Servicios Tecnológicos Avanzados - Pedro M. Baeza',
'maintainer': 'Pedro M. Baeza', 'maintainer': 'Pedro M. Baeza',
'category': 'Finance', 'category': 'Finance',

View File

@@ -18,11 +18,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
from openerp.tools.translate import _
from account_statement_base_import.parser import BankStatementImportParser
import tempfile import tempfile
import datetime import datetime
from openerp.tools.translate import _
from openerp.addons.account_statement_base_import.parser import BankStatementImportParser
try: try:
import ofxparse import ofxparse
except: except: