[IMP] Rebuild of all bank statment stuffs. This commit is more a backup cause it is under hard devs V2.0

(lp:c2c-financial-addons/6.1 rev 24.1.18)
This commit is contained in:
Joël Grand-Guillaume
2012-06-14 16:21:57 +02:00
parent 6360ac7369
commit 57215e0aa1
25 changed files with 1163 additions and 270 deletions

View File

@@ -24,15 +24,51 @@ import datetime
import netsvc
logger = netsvc.Logger()
from openerp.osv.orm import Model, fields
from openerp.addons.account_statement_base_completion.statement import ErrorTooManyPartner
class AccountStatementProfil(Model):
_inherit = "account.statement.profil"
class AccountStatementCompletionRule(Model):
"""Add a rule based on transaction ID"""
_inherit = "account.statement.completion.rule"
class AccountBankSatement(Model):
def _get_functions(self):
res = super (self,AccountStatementCompletionRule)._get_functions()
res.append(('get_from_transaction_id_and_so', 'From line reference (based on SO transaction ID'))
return res
_columns={
'function_to_call': fields.selection(_get_functions, 'Method'),
}
#TODO : Ensure we match only one partner => Otherwise raise an error !!!
def get_from_transaction_id_and_so(self, cr, uid, line_id, context=None):
"""Match the partner based on the transaction ID field of the SO.
Then, call the generic st_line method to complete other values.
In that case, we always fullfill the reference of the line with the SO name.
Return:
A dict of value that can be passed directly to the write method of
the statement line.
{'partner_id': value,
'account_id' : value,
...}
"""
st_obj = self.pool.get('account.bank.statement.line')
st_line = st_obj.browse(cr,uid,line_id)
res = {}
if st_line:
so_obj = self.pool.get('sale.order')
so_id = so_obj.search(cursor, uid, [('transaction_id', '=', st_line.transaction_id)])
if so_id and len(so_id) == 1:
so = so_obj.browse(cursor, uid, so_id[0])
res['partner_id'] = so.partner_id.id
res['ref'] = so.name
elif so_id and len(so_id) > 1:
raise Exception(_('Line named "%s" was matched by more than one partner.')%(st_line.name,st_line.id))
st_vals = st_obj.get_values_for_line(cr, uid, profile_id = st_line.statement_id.profile_id.id,
partner_id = res.get('partner_id',False), line_type = st_line.type, st_line.amount, context)
res.update(st_vals)
return res
_inherit = "account.bank.statement"
class AccountStatementLine(Model):
_inherit = "account.bank.statement.line"