[MERGE] merge sbh branch for account_coda (osv memory) , and other stock access rules

bzr revid: mra@mra-laptop-20100623090329-w1fghtgn20w17jxp
This commit is contained in:
Mustufa Rangwala 2010-06-23 14:33:29 +05:30
commit eb1fb94485
25 changed files with 480 additions and 442 deletions

View File

@ -19,7 +19,7 @@
#
##############################################################################
import coda
import account_coda
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@ -15,7 +15,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@ -24,13 +24,16 @@
"version":"1.0",
"author":"Tiny",
"category":"Account CODA",
"description":"""Module provides functionality to import
"description":"""
Module provides functionality to import
bank statements from coda files.
""",
"depends":["base", "account"],
"demo_xml":["coda_demo.xml"],
"demo_xml":["account_coda_demo.xml"],
"init_xml":[],
"update_xml" : ["security/ir.model.access.csv","coda_wizard.xml","coda_view.xml"],
"update_xml" : ["security/ir.model.access.csv",
"wizard/account_coda_import.xml",
"account_coda_view.xml"],
"active":False,
"installable":True,

View File

@ -26,15 +26,15 @@ class account_coda(osv.osv):
_name = "account.coda"
_description = "coda for an Account"
_columns = {
'name': fields.binary('Coda file', readonly=True),
'name': fields.binary('Coda file', readonly=True ,help="Store the detail of bank statements"),
'statement_ids': fields.one2many('account.bank.statement','coda_id','Generated Bank Statements', readonly=True),
'note': fields.text('Import log', readonly=True),
'journal_id': fields.many2one('account.journal','Bank Journal', readonly=True, select=True),
'date': fields.date('Import Date', readonly=True, select=True),
'journal_id': fields.many2one('account.journal','Journal', readonly=True, select=True,help="Bank Journal"),
'date': fields.date('Date', readonly=True, select=True, help="Import Date"),
'user_id': fields.many2one('res.users','User', readonly=True, select=True),
}
_defaults = {
'date': lambda *a: time.strftime('%Y-%m-%d'),
'date': time.strftime('%Y-%m-%d'),
'user_id': lambda self,cr,uid,context: uid,
}
account_coda()

View File

@ -0,0 +1,89 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record model="ir.ui.view" id="view_account_coda_form">
<field name="name">account.coda.form</field>
<field name="model">account.coda</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Coda import">
<field name="name" />
<field name="journal_id" />
<field name="date" />
<field name="user_id" />
<notebook colspan="4">
<page string="Log">
<field name="note" colspan="4" nolabel="1"/>
</page>
<page string="Statements">
<field name="statement_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_account_coda_tree">
<field name="name">account.coda.tree</field>
<field name="model">account.coda</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Coda import">
<field name="journal_id" />
<field name="date" />
<field name="user_id" />
<field name="statement_ids"/>
</tree>
</field>
</record>
<record id="view_aaccount_coda_filter" model="ir.ui.view">
<field name="name">account.coda.select</field>
<field name="model">account.coda</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Search Coda">
<group col="10" colspan="4">
<field name="journal_id"/>
<field name="user_id" default="uid"/>
<field name="date"/>
</group>
<newline/>
<group expand="0" string="Group By...">
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
<filter string="Date" icon="terp-go-month" domain="[]" context="{'group_by':'date'}"/>
<separator orientation="vertical"/>
<filter string="User" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_coda">
<field name="name">Coda Statements</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.coda</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{"search_default_user_id":uid}</field>
<field name="search_view_id" ref="view_aaccount_coda_filter"/>
</record>
<menuitem name="Coda Statements" parent="account.menu_finance_periodical_processing" id="menu_account_coda" sequence="12"/>
<menuitem name="Coda Statements" parent="menu_account_coda" id="menu_account_coda_statement" action="action_account_coda" sequence="15"/>
<menuitem name="Import Coda Statements" action="action_account_coda_import" parent="menu_account_coda"
id="menu_account_coda_import" sequence="13"/>
<act_window name="Coda File"
domain="[('statement_ids', 'in', [active_id])]"
res_model="account.coda"
src_model="account.bank.statement"
view_type="form"
view_mode="tree,form"
id="act_account_payment_account_bank_statement"/>
</data>
</openerp>

View File

@ -1,63 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record model="ir.ui.view" id="view_account_coda_form">
<field name="name">account.coda.form</field>
<field name="model">account.coda</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Coda import">
<field name="name" />
<field name="journal_id" />
<field name="date" />
<field name="user_id" />
<notebook colspan="4">
<page string="Log">
<field name="note" colspan="4" nolabel="1"/>
</page>
<page string="Statements">
<field name="statement_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_account_coda_tree">
<field name="name">account.coda.tree</field>
<field name="model">account.coda</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Coda import">
<field name="journal_id" />
<field name="date" />
<field name="user_id" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_account_coda">
<field name="name">Coda import</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.coda</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem name="Coda Statements" parent="account.menu_finance_reporting" id="menu_account_coda" action="action_account_coda" sequence="12"/>
<menuitem name="Import Coda Statements" action="wizard_account_coda_import" parent="account.menu_finance_periodical_processing"
type="wizard" id="menu_account_coda_wizard" sequence="15"/>
<act_window name="Coda File"
domain="[('statement_ids', 'in', [active_id])]"
res_model="account.coda"
src_model="account.bank.statement"
view_type="form"
view_mode="tree,form"
id="act_account_payment_account_bank_statement"/>
</data>
</openerp>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard
string="Import Coda File"
model="account.bank.statement"
name="account.coda_import"
id="wizard_account_coda_import"
menu="False"
/>
</data>
</openerp>

View File

@ -1,3 +1,5 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_account_coda","account.coda","model_account_coda","account.group_account_user",1,0,0,0
"access_account_coda_manager","account.coda","model_account_coda","account.group_account_manager",1,1,1,1
"access_account_coda_manager","account.coda","model_account_coda","account.group_account_manager",1,1,1,1
"access_account_coda_import_manager","account.coda.import","model_account_coda_import","account.group_account_manager",1,1,1,1
"access_account_coda_import_user","account.coda","model_account_coda","account.group_account_user",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_account_coda account.coda model_account_coda account.group_account_user 1 0 0 0
3 access_account_coda_manager account.coda model_account_coda account.group_account_manager 1 1 1 1
4 access_account_coda_import_manager account.coda.import model_account_coda_import account.group_account_manager 1 1 1 1
5 access_account_coda_import_user account.coda model_account_coda account.group_account_user 1 0 0 0

View File

@ -19,7 +19,7 @@
#
##############################################################################
import coda_import
import account_coda_import
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,292 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
from mx import DateTime
import base64
from osv import fields
from osv import osv
from tools.translate import _
def str2date(date_str):
return time.strftime("%y/%m/%d", time.strptime(date_str, "%d%m%y"))
def str2float(str):
try:
return float(str)
except:
return 0.0
def list2float(lst):
try:
return str2float((lambda s : s[:-3] + '.' + s[-3:])(lst))
except:
return 0.0
class account_coda_import(osv.osv_memory):
_name = 'account.coda.import'
_description = 'Account Coda Import'
_columns = {
'journal_id': fields.many2one('account.journal', 'Bank Journal', required=True),
'def_payable': fields.many2one('account.account', 'Default Payable Account', domain=[('type', '=', 'payable')], required=True, help= 'Set here the payable account that will be used, by default, if the partner is not found'),
'def_receivable': fields.many2one('account.account', 'Default Receivable Account', domain=[('type', '=', 'receivable')], required=True, help= 'Set here the receivable account that will be used, by default, if the partner is not found',),
'awaiting_account': fields.many2one('account.account', 'Default Account for Unrecognized Movement', required=True, help= 'Set here the default account that will be used, if the partner is found but does not have the bank account , or if he is domiciled',),
'coda': fields.binary('Coda File', required=True),
'note':fields.text('Log'),
}
def coda_parsing(self, cr, uid, ids, context):
journal_obj=self.pool.get('account.journal')
account_period_obj = self.pool.get('account.period')
partner_bank_obj = self.pool.get('res.partner.bank')
bank_statement_obj = self.pool.get('account.bank.statement')
move_line_obj = self.pool.get('account.move.line')
bank_statement_line_obj = self.pool.get('account.bank.statement.line')
statement_reconcile_obj = self.pool.get('account.bank.statement.reconcile')
account_coda_obj = self.pool.get('account.coda')
mod_obj = self.pool.get('ir.model.data')
data = self.read(cr, uid, ids)[0]
codafile = data['coda']
journal_code = journal_obj.browse(cr, uid, data['journal_id'], context).code
period = account_period_obj.find(cr, uid, context=context)[0]
def_pay_acc = data['def_payable']
def_rec_acc = data['def_receivable']
str_log = ""
err_log = "Errors:\n------\n"
nb_err=0
std_log=''
str_log1 = "Coda File is Imported : "
str_not=''
str_not1=''
bank_statements=[]
bank_statement = {}
recordlist = base64.decodestring(codafile).split('\n')
recordlist.pop()
for line in recordlist:
if line[0] == '0':
# header data
bank_statement["bank_statement_line"]={}
bank_statement_lines = {}
bank_statement['date'] = str2date(line[5:11])
bank_statement['journal_id']=data['journal_id']
period_id = account_period_obj.search(cr, uid, [('date_start', '<=', time.strftime('%Y-%m-%d', time.strptime(bank_statement['date'], "%y/%m/%d"))), ('date_stop', '>=', time.strftime('%Y-%m-%d', time.strptime(bank_statement['date'], "%y/%m/%d")))])
bank_statement['period_id'] = period_id and period_id[0] or False
bank_statement['state']='draft'
elif line[0] == '1':
# old balance data
bal_start = list2float(line[43:58])
if line[42] == '1':
bal_start = - bal_start
bank_statement["balance_start"]= bal_start
bank_statement["acc_number"]=line[5:17]
bank_statement["acc_holder"]=line[64:90]
bank_statement['name'] = journal_code + ' ' + str(line[2:5])
elif line[0]=='2':
# movement data record 2
if line[1]=='1':
# movement data record 2.1
if bank_statement_lines.has_key(line[2:6]):
continue
st_line = {}
st_line['extra_note'] = ''
st_line['statement_id']=0
st_line['ref'] = line[2:10]
st_line['date'] = time.strftime('%Y-%m-%d', time.strptime(str2date(line[115:121]), "%y/%m/%d")),
st_line_amt = list2float(line[32:47])
if line[61]=='1':
st_line['toreconcile'] = True
st_line['name']=line[65:77]
else:
st_line['toreconcile'] = False
st_line['name']=line[62:115]
st_line['free_comm'] = st_line['name']
st_line['val_date']=time.strftime('%Y-%m-%d', time.strptime(str2date(line[47:53]), "%y/%m/%d")),
st_line['entry_date']=time.strftime('%Y-%m-%d', time.strptime(str2date(line[115:121]), "%y/%m/%d")),
st_line['partner_id']=0
if line[31] == '1':
st_line_amt = - st_line_amt
st_line['account_id'] = def_pay_acc
else:
st_line['account_id'] = def_rec_acc
st_line['amount'] = st_line_amt
bank_statement_lines[line[2:6]]=st_line
bank_statement["bank_statement_line"]=bank_statement_lines
elif line[1] == '2':
st_line_name = line[2:6]
bank_statement_lines[st_line_name].update({'account_id': data['awaiting_account']})
elif line[1] == '3':
# movement data record 3.1
st_line_name = line[2:6]
st_line_partner_acc = str(line[10:47]).strip()
cntry_number=line[10:47].strip()
contry_name=line[47:125].strip()
bank_ids = partner_bank_obj.search(cr, uid, [('acc_number', '=', st_line_partner_acc)])
bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name})
if bank_ids:
bank = partner_bank_obj.browse(cr, uid, bank_ids[0], context)
if line and bank.partner_id:
bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id})
if bank_statement_lines[st_line_name]['amount'] < 0 :
bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_payable.id})
else :
bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_receivable.id})
else:
nb_err += 1
err_log += _('The bank account %s is not defined for the partner %s.\n')%(cntry_number, contry_name)
bank_statement_lines[st_line_name].update({'account_id': data['awaiting_account']})
bank_statement["bank_statement_line"]=bank_statement_lines
elif line[0]=='3':
if line[1] == '1':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[40:113]
elif line[1] == '2':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:115]
elif line[1] == '3':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:100]
elif line[0]=='8':
# new balance record
bal_end = list2float(line[42:57])
if line[41] == '1':
bal_end = - bal_end
bank_statement["balance_end_real"]= bal_end
elif line[0]=='9':
# footer record
bank_statements.append(bank_statement)
#end for
bkst_list=[]
for statement in bank_statements:
try:
bk_st_id =bank_statement_obj.create(cr, uid, {
'journal_id': statement['journal_id'],
'date':time.strftime('%Y-%m-%d', time.strptime(statement['date'], "%y/%m/%d")),
'period_id':statement['period_id'] or period,
'balance_start': statement["balance_start"],
'balance_end_real': statement["balance_end_real"],
'state': 'draft',
'name': statement['name'],
})
lines=statement["bank_statement_line"]
for value in lines:
line=lines[value]
reconcile_id = False
if line['toreconcile']:
rec_id = move_line_obj.search(cr, uid, [('name', '=', line['name']), ('reconcile_id', '=', False), ('account_id.reconcile', '=', True)])
if rec_id:
reconcile_id = statement_reconcile_obj.create(cr, uid, {
'line_ids': [(6, 0, rec_id)]
}, context=context)
str_not1 = ''
if line.has_key('contry_name') and line.has_key('cntry_number'):
str_not1="Partner name:%s \n Partner Account Number:%s \n Communication:%s \n Value Date:%s \n Entry Date:%s \n"%(line["contry_name"], line["cntry_number"], line["free_comm"]+line['extra_note'], line["val_date"][0], line["entry_date"][0])
id=bank_statement_line_obj.create(cr, uid, {
'name':line['name'],
'date': line['date'],
'amount': line['amount'],
'partner_id':line['partner_id'] or 0,
'account_id':line['account_id'],
'statement_id': bk_st_id,
'reconcile_id': reconcile_id,
'note':str_not1,
'ref':line['ref'],
})
str_not= "\n \n Account Number: %s \n Account Holder Name: %s " %(statement["acc_number"], statement["acc_holder"])
std_log += "\nStatement : %s , Date : %s, Starting Balance : %.2f , Ending Balance : %.2f \n"\
%(statement['name'], statement['date'], float(statement["balance_start"]), float(statement["balance_end_real"]))
bkst_list.append(bk_st_id)
except osv.except_osv, e:
cr.rollback()
nb_err+=1
err_log += '\n Application Error : ' + str(e)
raise # REMOVEME
except Exception, e:
cr.rollback()
nb_err+=1
err_log += '\n System Error : '+str(e)
raise # REMOVEME
except :
cr.rollback()
nb_err+=1
err_log += '\n Unknown Error'
raise
err_log += '\n\nNumber of statements : '+ str(len(bkst_list))
err_log += '\nNumber of error :'+ str(nb_err) +'\n'
account_coda_obj.create(cr, uid, {
'name':codafile,
'statement_ids': [(6, 0, bkst_list,)],
'note':str_log1+str_not+std_log+err_log,
'journal_id':data['journal_id'],
'date':time.strftime("%Y-%m-%d"),
'user_id':uid,
})
test=''
test=str_log1 + std_log + err_log
self.write(cr, uid, ids, {'note':test}, context=context)
extraction= { 'statment_ids':bkst_list}
context.update({ 'statment_ids':bkst_list})
model_data_ids = mod_obj.search(cr, uid, [('model', '=', 'ir.ui.view'), ('name', '=', 'account_coda_note_view')], context=context)
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
return {
'name': _('Result'),
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'res_model': 'account.coda.import',
'view_id': False,
'target':'new',
'views': [(resource_id, 'form')],
'context': context,
'type': 'ir.actions.act_window',
}
def action_open_window(self, cr, uid, data, context):
return {
'domain':"[('id','in',%s)]"%(context.get('statment_ids', False)),
'name': 'Statement',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.bank.statement',
'view_id': False,
'type': 'ir.actions.act_window',
}
account_coda_import()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,59 @@
<?xml version="1.0" ?>
<openerp>
<data>
<record id="account_coda_import_view" model="ir.ui.view">
<field name="name">Import Coda Statement</field>
<field name="model">account.coda.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Import Coda Statement">
<separator colspan="4" string="Configure Your Journal and Account :" />
<field name="journal_id" colspan="1" domain="[('type','=','cash')]" />
<newline />
<field name="def_payable" />
<newline />
<field name="def_receivable" />
<newline />
<field name="awaiting_account" />
<separator string="Click on 'New' to select your file :" colspan="4"/>
<field name="coda"/>
<newline/>
<group colspan="4" col="6">
<separator colspan="6"/>
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
<button name="coda_parsing" string="Import" type="object" icon="gtk-ok"/>
</group>
</form>
</field>
</record>
<record id="account_coda_note_view" model="ir.ui.view">
<field name="name">Import Coda Statement</field>
<field name="model">account.coda.import</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Result of Imported Coda Statements">
<group width="500" height="420">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="500"/>
<newline/>
<separator colspan="6"/>
<button special="cancel" string="Close" icon="gtk-cancel"/>
<button name="action_open_window" string="Open Statements" type="object" icon="gtk-apply"/>
</group>
</form>
</field>
</record>
<record id="action_account_coda_import" model="ir.actions.act_window">
<field name="name">Import Coda Statement</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.coda.import</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="account_coda_import_view"/>
</record>
</data>
</openerp>

View File

@ -1,341 +0,0 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pooler
import time
import datetime
import wizard
import netsvc
import base64
from osv import osv
from tools.translate import _
codawiz_form = """<?xml version="1.0"?>
<form string="Import Coda Statement">
<separator colspan="4" string="Select your bank journal :" />
<field name="journal_id" colspan="1" domain="[('type','=','cash')]" />
<newline />
<field name="def_payable" />
<newline />
<field name="def_receivable" />
<newline />
<field name="awaiting_account" />
<separator string="Click on 'New' to select your file :" colspan="4"/>
<field name="coda"/>
</form>
"""
codawiz_fields = {
'journal_id' : {
'string':'Bank Journal',
'type':'many2one',
'relation':'account.journal',
'required':True,
},
'coda' : {
'string':'Coda File',
'type':'binary',
'required':True,
},
'def_payable' : {
'string' : 'Default Payable Account',
'type' : 'many2one',
'relation': 'account.account',
'required':True,
'domain':[('type','=','payable')],
'help': 'Set here the payable account that will be used, by default, if the partner is not found',
},
'def_receivable' : {
'string' : 'Default receivable Account',
'type' : 'many2one',
'relation': 'account.account',
'required':True,
'domain':[('type','=','receivable')],
'help': 'Set here the receivable account that will be used, by default, if the partner is not found',
},
'awaiting_account' : {
'string' : 'Default Account for Unrecognized Movement',
'type' : 'many2one',
'relation': 'account.account',
'required':True,
'help': 'Set here the default account that will be used, if the partner is found but does not have the bank account , or if he is domiciled',
}
}
result_form = """<?xml version="1.0"?>
<form string="Import Coda Statement">
<separator colspan="4" string="Results :" />
<field name="note" colspan="4" nolabel="1" width="500"/>
</form>
"""
result_fields = {
'note' : {'string':'Log','type':'text'}
}
def _coda_parsing(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
codafile = data['form']['coda']
journal_code = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context).code
def_pay_acc = data['form']['def_payable']
def_rec_acc = data['form']['def_receivable']
str_log = ""
err_log = "Errors:\n------\n"
nb_err=0
std_log=''
str_log1 = "Coda File is Imported : "
str_not=''
str_not1=''
bank_statements=[]
recordlist = base64.decodestring(codafile).split('\n')
recordlist.pop()
for line in recordlist:
if line[0] == '0':
# header data
bank_statement = {}
bank_statement["bank_statement_line"]={}
bank_statement_lines = {}
bank_statement['date'] = str2date(line[5:11])
bank_statement['journal_id']=data['form']['journal_id']
period_id = pool.get('account.period').search(cr, uid, [('date_start','<=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d"))),('date_stop','>=',time.strftime('%Y-%m-%d',time.strptime(bank_statement['date'],"%y/%m/%d")))])
bank_statement['period_id'] = period_id and period_id[0] or False
bank_statement['state']='draft'
elif line[0] == '1':
# old balance data
bal_start = list2float(line[43:58])
if line[42] == '1':
bal_start = - bal_start
bank_statement["balance_start"]= bal_start
bank_statement["acc_number"]=line[5:17]
bank_statement["acc_holder"]=line[64:90]
bank_statement['name'] = journal_code + ' ' + str(line[2:5])
elif line[0]=='2':
# movement data record 2
if line[1]=='1':
# movement data record 2.1
if bank_statement_lines.has_key(line[2:6]):
continue
st_line = {}
st_line['extra_note'] = ''
st_line['statement_id']=0
st_line['ref'] = line[2:10]
st_line['date'] = time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")),
st_line_amt = list2float(line[32:47])
if line[61]=='1':
st_line['toreconcile'] = True
st_line['name']=line[65:77]
else:
st_line['toreconcile'] = False
st_line['name']=line[62:115]
st_line['free_comm'] = st_line['name']
st_line['val_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[47:53]),"%y/%m/%d")),
st_line['entry_date']=time.strftime('%Y-%m-%d',time.strptime(str2date(line[115:121]),"%y/%m/%d")),
st_line['partner_id']=0
if line[31] == '1':
st_line_amt = - st_line_amt
st_line['account_id'] = def_pay_acc
else:
st_line['account_id'] = def_rec_acc
st_line['amount'] = st_line_amt
bank_statement_lines[line[2:6]]=st_line
bank_statement["bank_statement_line"]=bank_statement_lines
elif line[1] == '2':
st_line_name = line[2:6]
bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']})
elif line[1] == '3':
# movement data record 3.1
st_line_name = line[2:6]
st_line_partner_acc = str(line[10:47]).strip()
cntry_number=line[10:47].strip()
contry_name=line[47:125].strip()
bank_ids = pool.get('res.partner.bank').search(cr, uid, [('acc_number','=',st_line_partner_acc)])
bank_statement_lines[st_line_name].update({'cntry_number': cntry_number, 'contry_name': contry_name})
if bank_ids:
bank = pool.get('res.partner.bank').browse(cr, uid, bank_ids[0], context)
if line and bank.partner_id:
bank_statement_lines[st_line_name].update({'partner_id': bank.partner_id.id})
if bank_statement_lines[st_line_name]['amount'] < 0 :
bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_payable.id})
else :
bank_statement_lines[st_line_name].update({'account_id': bank.partner_id.property_account_receivable.id})
else:
nb_err += 1
err_log += _('The bank account %s is not defined for the partner %s.\n')%(cntry_number,contry_name)
bank_statement_lines[st_line_name].update({'account_id': data['form']['awaiting_account']})
bank_statement["bank_statement_line"]=bank_statement_lines
elif line[0]=='3':
if line[1] == '1':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[40:113]
elif line[1] == '2':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:115]
elif line[1] == '3':
st_line_name = line[2:6]
bank_statement_lines[st_line_name]['extra_note'] += '\n' + line[10:100]
elif line[0]=='8':
# new balance record
bal_end = list2float(line[42:57])
if line[41] == '1':
bal_end = - bal_end
bank_statement["balance_end_real"]= bal_end
elif line[0]=='9':
# footer record
bank_statements.append(bank_statement)
#end for
bkst_list=[]
for statement in bank_statements:
try:
bk_st_id = pool.get('account.bank.statement').create(cr,uid,{
'journal_id': statement['journal_id'],
'date':time.strftime('%Y-%m-%d',time.strptime(statement['date'],"%y/%m/%d")),
'period_id':statement['period_id'],
'balance_start': statement["balance_start"],
'balance_end_real': statement["balance_end_real"],
'state': 'draft',
'name': statement['name'],
})
lines=statement["bank_statement_line"]
for value in lines:
line=lines[value]
reconcile_id = False
if line['toreconcile']:
rec_id = pool.get('account.move.line').search(cr, uid, [('name','=',line['name']),('reconcile_id','=',False),('account_id.reconcile','=',True)])
if rec_id:
reconcile_id = pool.get('account.bank.statement.reconcile').create(cr, uid, {
'line_ids': [(6, 0, rec_id)]
}, context=context)
str_not1 = ''
if line.has_key('contry_name') and line.has_key('cntry_number'):
str_not1="Partner name:%s \n Partner Account Number:%s \n Communication:%s \n Value Date:%s \n Entry Date:%s \n"%(line["contry_name"],line["cntry_number"],line["free_comm"]+line['extra_note'],line["val_date"][0],line["entry_date"][0])
id=pool.get('account.bank.statement.line').create(cr,uid,{
'name':line['name'],
'date': line['date'],
'amount': line['amount'],
'partner_id':line['partner_id'] or 0,
'account_id':line['account_id'],
'statement_id': bk_st_id,
'reconcile_id': reconcile_id,
'note':str_not1,
'ref':line['ref'],
})
str_not= "\n \n Account Number: %s \n Account Holder Name: %s " %(statement["acc_number"],statement["acc_holder"])
std_log += "\nStatement : %s , Date : %s, Starting Balance : %.2f , Ending Balance : %.2f \n"\
%(statement['name'], statement['date'], float(statement["balance_start"]), float(statement["balance_end_real"]))
bkst_list.append(bk_st_id)
except osv.except_osv, e:
cr.rollback()
nb_err+=1
err_log += '\n Application Error : ' + str(e)
raise # REMOVEME
except Exception, e:
cr.rollback()
nb_err+=1
err_log += '\n System Error : '+str(e)
raise # REMOVEME
except :
cr.rollback()
nb_err+=1
err_log += '\n Unknown Error'
raise
err_log += '\n\nNumber of statements : '+ str(len(bkst_list))
err_log += '\nNumber of error :'+ str(nb_err) +'\n'
pool.get('account.coda').create(cr, uid, {
'name':codafile,
'statement_ids': [(6, 0, bkst_list,)],
'note':str_log1+str_not+std_log+err_log,
'journal_id':data['form']['journal_id'],
'date':time.strftime("%Y-%m-%d"),
'user_id':uid,
})
return {'note':str_log1 + std_log + err_log ,'journal_id': data['form']['journal_id'], 'coda': data['form']['coda'],'statment_ids':bkst_list}
def str2date(date_str):
return time.strftime("%y/%m/%d",time.strptime(date_str,"%d%m%y"))
def str2float(str):
try:
return float(str)
except:
return 0.0
def list2float(lst):
try:
return str2float((lambda s : s[:-3] + '.' + s[-3:])(lst))
except:
return 0.0
class coda_import(wizard.interface):
def _action_open_window(self, cr, uid, data, context):
form=data['form']
return {
'domain':"[('id','in',%s)]"%(form['statment_ids']),
'name': 'Statement',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'account.bank.statement',
'view_id': False,
'type': 'ir.actions.act_window',
}
states = {
'init' : {
'actions' : [],
'result' : {'type' : 'form',
'arch' : codawiz_form,
'fields' : codawiz_fields,
'state' : [('end', '_Close'),('extraction', '_Ok') ]}
},
'extraction' : {
'actions' : [_coda_parsing],
'result' : {'type' : 'form',
'arch' : result_form,
'fields' : result_fields,
'state' : [('end', '_Close'),('open', '_Open Statement')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _action_open_window, 'state': 'end'}
},
}
coda_import("account.coda_import")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,4 +28,5 @@
"access_product_pricelist_item_user","product.pricelist.item.user","model_product_pricelist_item","base.group_user",1,0,0,0
"access_product_pricelist_type_partner_manager","product.pricelist.type partner manager","model_product_pricelist_type","base.group_partner_manager",1,0,0,0
"access_product_pricelist_partner_manager","product.pricelist partner manager","model_product_pricelist","base.group_partner_manager",1,0,0,0
"access_ir_property_group_product_manager","ir_property group_product_manager","base.model_ir_property",product.group_product_manager,1,1,1,1
"access_ir_property_group_product_manager","ir_property group_product_manager","base.model_ir_property","product.group_product_manager",1,1,1,1
"access_product_price_list","product.price_list","model_product_price_list","base.group_user",1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
28 access_product_pricelist_item_user product.pricelist.item.user model_product_pricelist_item base.group_user 1 0 0 0
29 access_product_pricelist_type_partner_manager product.pricelist.type partner manager model_product_pricelist_type base.group_partner_manager 1 0 0 0
30 access_product_pricelist_partner_manager product.pricelist partner manager model_product_pricelist base.group_partner_manager 1 0 0 0
31 access_ir_property_group_product_manager ir_property group_product_manager base.model_ir_property product.group_product_manager 1 1 1 1
32 access_product_price_list product.price_list model_product_price_list base.group_user 1 0 0 0

View File

@ -31,7 +31,11 @@
- removal date
- alert date
Used, for example, in food industries.''',
"update_xml" : ["product_expiry_view.xml", "report/report_stock_view.xml", "wizard/stock_partial_view.xml"],
"update_xml" : [
'security/ir.model.access.csv',
"product_expiry_view.xml",
"report/report_stock_view.xml",
"wizard/stock_partial_view.xml"],
"active": False,
"installable": True
}

View File

@ -0,0 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_stock_report_prodlots1_manager","stock.report.prodlots1","model_stock_report_prodlots1","product.group_product_manager",1,1,1,1
"access_stock_report_prodlots1_user","stock.report.prodlots1","model_stock_report_prodlots1","base.group_user",1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_stock_report_prodlots1_manager stock.report.prodlots1 model_stock_report_prodlots1 product.group_product_manager 1 1 1 1
3 access_stock_report_prodlots1_user stock.report.prodlots1 model_stock_report_prodlots1 base.group_user 1 0 0 0

View File

@ -9,10 +9,10 @@
<field name="inherit_id" ref="stock.view_split_in_lots"/>
<field name="arch" type="xml">
<data>
<xpath expr="//form/group/field[@name='line_ids']/tree/field[@name='name']" position="replace">
<xpath expr="//form/group/group/field[@name='line_ids']/tree/field[@name='name']" position="replace">
<field name="name" on_change="on_change_product(parent.product_id)"/>
</xpath>
<xpath expr="//form/group/field[@name='line_ids']/tree/field[@name='quantity']" position="after">
<xpath expr="//form//group/group/field[@name='line_ids']/tree/field[@name='quantity']" position="after">
<field name="date"/>
</xpath>
</data>

View File

@ -31,7 +31,10 @@ the report has several options to help you get the data you need.
""",
'author': 'Tiny',
'depends': ['base', 'product', 'account'],
'update_xml': ['wizard/product_margin_view.xml','product_margin_view.xml'],
'update_xml': [
'security/ir.model.access.csv',
'wizard/product_margin_view.xml',
'product_margin_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,

View File

@ -27,7 +27,3 @@
"access_sale_account_journal","account.journal sale order.user","account.model_account_journal","group_sale_user",1,0,0,0
"access_sale_make_invoice_user","sale.make.invoice","model_sale_make_invoice","group_sale_user",1,0,0,0
"access_sale_make_invoice_manager","sale.make.invoice","model_sale_make_invoice","group_sale_manager",1,1,1,1
"access_sale_order_by_clients_user","sale.order.by.clients","model_sale_order_by_clients","group_sale_user",1,0,0,0
"access_sale_order_by_clients_manager","sale.order.by.clients","model_sale_order_by_clients","group_sale_manager",1,1,1,1
"access_sales_by_regions_user ","sales.by.regions","model_sales_by_regions","group_sale_user",1,0,0,0
"access_sales_by_regions_manager","sales.by.regions","model_sales_by_regions","group_sale_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
27 access_sale_account_journal account.journal sale order.user account.model_account_journal group_sale_user 1 0 0 0
28 access_sale_make_invoice_user sale.make.invoice model_sale_make_invoice group_sale_user 1 0 0 0
29 access_sale_make_invoice_manager sale.make.invoice model_sale_make_invoice group_sale_manager 1 1 1 1
access_sale_order_by_clients_user sale.order.by.clients model_sale_order_by_clients group_sale_user 1 0 0 0
access_sale_order_by_clients_manager sale.order.by.clients model_sale_order_by_clients group_sale_manager 1 1 1 1
access_sales_by_regions_user sales.by.regions model_sales_by_regions group_sale_user 1 0 0 0
access_sales_by_regions_manager sales.by.regions model_sales_by_regions group_sale_manager 1 1 1 1

View File

@ -53,3 +53,4 @@
"access_stock_ups_upload","stock.ups.upload","model_stock_ups_upload","stock.group_stock_user",1,1,1,1
"access_stock_split_into","stock.split.into","model_stock_split_into","stock.group_stock_user",1,1,1,0
"access_stock_split_into_manager","stock.split.into","model_stock_split_into","stock.group_stock_manager",1,1,1,1
"access_report_stock_picking","report.stock.picking","model_report_stock_picking","stock.group_stock_manager",1,1,1,1

Can't render this file because it contains an unexpected character in line 40 and column 53.

View File

@ -3,7 +3,6 @@
<data>
<report auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Future Stock Forecast"/>
<report id="report_picking_list" model="stock.picking" name="stock.picking.list" string="Picking list" rml="stock/report/picking.rml"/>
<report id="report_packing_list" model="stock.picking" name="stock.packing.list2" string="Packing list" rml="stock/report/packing.rml"/>
<report id="report_move_labels" model="stock.move" name="stock.move.label" string="Item Labels" xml="stock/report/lot_move_label.xml" xsl="stock/report/lot_move_label.xsl"/>
<report auto="False" id="report_location_overview" model="stock.location" name="lot.stock.overview" string="Location Overview" rml="stock/report/lot_overview.rml" groups="base.group_extended"/>
<report auto="False" id="report_lot_location" model="stock.location" name="lot.location" rml="stock/report/lot_location.rml" string="Lots by location"/>

View File

@ -19,7 +19,7 @@
#
##############################################################################
import stock
import stock_location
import mrp_pull
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -39,7 +39,7 @@ This module may be useful for different purposes:
'author': 'Tiny',
'depends': ['procurement','stock'],
'init_xml': [],
'update_xml': ['stock_view.xml', 'security/ir.model.access.csv', 'mrp_pull_workflow.xml'],
'update_xml': ['stock_location_view.xml', 'security/ir.model.access.csv', 'mrp_pull_workflow.xml'],
'demo_xml': [],
'installable': True,
'test':[

View File

@ -152,7 +152,9 @@
<field name="product_amt" on_change="product_amt_change( product_amt, product_uom)" />
<field name="product_qty" />
<field name="state"/>
<button name="action_validate" icon="gtk-apply" string="Validate" states="draft" type="object" colspan = "2"/>
<label string = ""/>
<button name="action_validate" icon="gtk-apply" string="Validate" states="draft" type="object" colspan = "1"/>
</group>
</group>
<separator colspan ="4" string="Sales history"/>
@ -161,6 +163,7 @@
<label string = "Per User :"/>
<label string = "Per Department :"/>
<label string = "Per Warehouse :"/>
<label string = ""/>
<label string = "Periods :"/>
<field name="analyzed_user_id" nolabel = "1" domain = "[('company_id','=',company_id)] "/>
<field name="analyzed_dept_id" nolabel = "1" domain = "[('company_id','=',company_id)] " />