fix the problem of analytic account with the voucher entry
improve the voucher entry system lp bug: https://launchpad.net/bugs/296760 fixed bzr revid: mga@tinyerp.com-20081215114852-j5gij01eby4p0gqg
This commit is contained in:
parent
f0f0b55df3
commit
05c0ca7721
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
|
|
||||||
<data noupdate="1">
|
<data>
|
||||||
<record model="res.request.link" id="req_link_voucher">
|
<record model="res.request.link" id="req_link_voucher">
|
||||||
<field name="name">Voucher</field>
|
<field name="name">Voucher</field>
|
||||||
<field name="object">account.voucher</field>
|
<field name="object">account.voucher</field>
|
||||||
|
@ -12,32 +12,32 @@
|
||||||
-->
|
-->
|
||||||
<record model="ir.sequence.type" id="seq_type_cash_rec_voucher">
|
<record model="ir.sequence.type" id="seq_type_cash_rec_voucher">
|
||||||
<field name="name">Account Cash Received Voucher</field>
|
<field name="name">Account Cash Received Voucher</field>
|
||||||
<field name="code">account.voucher.rec_voucher</field>
|
<field name="code">rec_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.sequence.type" id="seq_type_cash_pay_voucher">
|
<record model="ir.sequence.type" id="seq_type_cash_pay_voucher">
|
||||||
<field name="name">Account Cash Payble Voucher</field>
|
<field name="name">Account Cash Payble Voucher</field>
|
||||||
<field name="code">account.voucher.pay_voucher</field>
|
<field name="code">pay_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type" id="seq_type_bank_rec_voucher">
|
<record model="ir.sequence.type" id="seq_type_bank_rec_voucher">
|
||||||
<field name="name">Account Bank Received Voucher</field>
|
<field name="name">Account Bank Received Voucher</field>
|
||||||
<field name="code">account.voucher.bank_rec_voucher</field>
|
<field name="code">bank_rec_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type" id="seq_type_bank_pay_voucher">
|
<record model="ir.sequence.type" id="seq_type_bank_pay_voucher">
|
||||||
<field name="name">Account Bank Payble Voucher</field>
|
<field name="name">Account Bank Payble Voucher</field>
|
||||||
<field name="code">account.voucher.bank_pay_voucher</field>
|
<field name="code">bank_pay_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type" id="seq_type_contra_voucher">
|
<record model="ir.sequence.type" id="seq_type_contra_voucher">
|
||||||
<field name="name">Account Contra Voucher</field>
|
<field name="name">Account Contra Voucher</field>
|
||||||
<field name="code">account.voucher.cont_voucher</field>
|
<field name="code">cont_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type" id="seq_type_jou_sale_voucher">
|
<record model="ir.sequence.type" id="seq_type_jou_sale_voucher">
|
||||||
<field name="name">Account Journal Voucher</field>
|
<field name="name">Sales Journal Voucher</field>
|
||||||
<field name="code">account.voucher.journal_sale_vou</field>
|
<field name="code">journal_sale_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence.type" id="seq_type_jou_pur_voucher">
|
<record model="ir.sequence.type" id="seq_type_jou_pur_voucher">
|
||||||
<field name="name">Account Journal Voucher</field>
|
<field name="name">Purchase Journal Voucher</field>
|
||||||
<field name="code">account.voucher.journal_pur_vou</field>
|
<field name="code">journal_pur_voucher</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -45,66 +45,48 @@
|
||||||
-->
|
-->
|
||||||
<record model="ir.sequence" id="seq_cash_rec_voucher">
|
<record model="ir.sequence" id="seq_cash_rec_voucher">
|
||||||
<field name="name">Account Cash Received Voucher</field>
|
<field name="name">Account Cash Received Voucher</field>
|
||||||
<field name="code">account.voucher.rec_voucher</field>
|
<field name="code">rec_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record model="ir.sequence" id="seq_cash_pay_voucher">
|
<record model="ir.sequence" id="seq_cash_pay_voucher">
|
||||||
<field name="name">Account Cash Payble Voucher</field>
|
<field name="name">Account Cash Payble Voucher</field>
|
||||||
<field name="code">account.voucher.pay_voucher</field>
|
<field name="code">pay_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="seq_bank_rec_voucher">
|
<record model="ir.sequence" id="seq_bank_rec_voucher">
|
||||||
<field name="name">Account Bank Received Voucher</field>
|
<field name="name">Account Bank Received Voucher</field>
|
||||||
<field name="code">account.voucher.bank_rec_voucher</field>
|
<field name="code">bank_rec_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="seq_bank_pay_voucher">
|
<record model="ir.sequence" id="seq_bank_pay_voucher">
|
||||||
<field name="name">Account Bank Payble Voucher</field>
|
<field name="name">Account Bank Payble Voucher</field>
|
||||||
<field name="code">account.voucher.bank_pay_voucher</field>
|
<field name="code">bank_pay_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="seq_contra_voucher">
|
<record model="ir.sequence" id="seq_contra_voucher">
|
||||||
<field name="name">Account Contra Voucher</field>
|
<field name="name">Account Contra Voucher</field>
|
||||||
<field name="code">account.voucher.cont_voucher</field>
|
<field name="code">cont_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="seq_jou_sale_voucher">
|
<record model="ir.sequence" id="seq_jou_sale_voucher">
|
||||||
<field name="name">Account Journal Voucher</field>
|
<field name="name">Sales Journal Voucher</field>
|
||||||
<field name="code">account.voucher.journal_sale_vou</field>
|
<field name="code">journal_sale_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.sequence" id="seq_jou_pur_voucher">
|
<record model="ir.sequence" id="seq_jou_pur_voucher">
|
||||||
<field name="name">Account Journal Voucher</field>
|
<field name="name">Purchase Journal Voucher</field>
|
||||||
<field name="code">account.voucher.journal_pur_vou</field>
|
<field name="code">journal_pur_voucher</field>
|
||||||
<field name="padding" eval="3"/>
|
<field name="padding" eval="3"/>
|
||||||
<field name="prefix">%(year)s/</field>
|
<field name="prefix">%(year)s/</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!--
|
|
||||||
Sequences types for analytic account
|
|
||||||
|
|
||||||
<record model="ir.sequence.type" id="seq_type_analytic_account">
|
|
||||||
<field name="name">Analytic account</field>
|
|
||||||
<field name="code">account.analytic.account</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
|
|
||||||
Sequence for analytic account
|
|
||||||
|
|
||||||
<record model="ir.sequence" id="seq_analytic_account">
|
|
||||||
<field name="name">Analytic account sequence</field>
|
|
||||||
<field name="code">account.analytic.account</field>
|
|
||||||
<field name="padding" eval="3" />
|
|
||||||
<field name="number_next" eval="2708" />
|
|
||||||
</record>
|
|
||||||
-->
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ class account_voucher(osv.osv):
|
||||||
('rec_voucher','Cash Receipt Voucher'),
|
('rec_voucher','Cash Receipt Voucher'),
|
||||||
('bank_rec_voucher','Bank Receipt Voucher'),
|
('bank_rec_voucher','Bank Receipt Voucher'),
|
||||||
('cont_voucher','Contra Voucher'),
|
('cont_voucher','Contra Voucher'),
|
||||||
('journal_sale_vou','Journal Sale Voucher'),
|
('journal_sale_voucher','Journal Sale Voucher'),
|
||||||
('journal_pur_voucher','Journal Purchase Voucher'),
|
('journal_pur_voucher','Journal Purchase Voucher'),
|
||||||
],'Type', readonly=True, select=True),
|
],'Type', readonly=True, select=True),
|
||||||
'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}),
|
'date':fields.date('Date', readonly=True, states={'draft':[('readonly',False)]}),
|
||||||
|
@ -99,7 +99,7 @@ class account_voucher(osv.osv):
|
||||||
('posted','Posted'),
|
('posted','Posted'),
|
||||||
('cancel','Cancel')
|
('cancel','Cancel')
|
||||||
], 'State',
|
], 'State',
|
||||||
readonly=True),
|
readonly=True, size=32),
|
||||||
'amount':fields.float('Amount'),
|
'amount':fields.float('Amount'),
|
||||||
'number':fields.char('Number', size=32, readonly=True),
|
'number':fields.char('Number', size=32, readonly=True),
|
||||||
'reference': fields.char('Voucher Reference', size=64),
|
'reference': fields.char('Voucher Reference', size=64),
|
||||||
|
@ -110,7 +110,6 @@ class account_voucher(osv.osv):
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
#'journal_id':get_bank,
|
|
||||||
'state': lambda *a: 'draft',
|
'state': lambda *a: 'draft',
|
||||||
'date' : lambda *a: time.strftime('%Y-%m-%d'),
|
'date' : lambda *a: time.strftime('%Y-%m-%d'),
|
||||||
'period_id': _get_period,
|
'period_id': _get_period,
|
||||||
|
@ -142,16 +141,13 @@ class account_voucher(osv.osv):
|
||||||
if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher')):
|
if journal_id and (type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher')):
|
||||||
account_id = journal.browse(cr, uid, journal_id).default_debit_account_id
|
account_id = journal.browse(cr, uid, journal_id).default_debit_account_id
|
||||||
return {'value':{'account_id':account_id.id}}
|
return {'value':{'account_id':account_id.id}}
|
||||||
elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_vou')) :
|
elif journal_id and (type in ('pay_voucher','bank_pay_voucher','journal_sale_voucher')) :
|
||||||
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
|
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
|
||||||
return {'value':{'account_id':account_id.id}}
|
return {'value':{'account_id':account_id.id}}
|
||||||
else:
|
else:
|
||||||
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
|
account_id = journal.browse(cr, uid, journal_id).default_credit_account_id
|
||||||
return {'value':{'account_id':account_id.id}}
|
return {'value':{'account_id':account_id.id}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def open_voucher(self, cr, uid, ids, context={}):
|
def open_voucher(self, cr, uid, ids, context={}):
|
||||||
obj=self.pool.get('account.voucher').browse(cr,uid,ids)
|
obj=self.pool.get('account.voucher').browse(cr,uid,ids)
|
||||||
total=0
|
total=0
|
||||||
|
@ -203,16 +199,16 @@ class account_voucher(osv.osv):
|
||||||
|
|
||||||
for il in iml:
|
for il in iml:
|
||||||
if il['account_analytic_id']:
|
if il['account_analytic_id']:
|
||||||
if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
|
if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'):
|
||||||
ref = inv.reference
|
ref = inv.reference
|
||||||
else:
|
else:
|
||||||
ref = self._convert_ref(cr, uid, inv.number)
|
ref = self._convert_ref(cr, uid, inv.number)
|
||||||
il['analytic_lines'] = [(0,0, {
|
|
||||||
|
il['analytic_lines'] = [(0, 0, {
|
||||||
'name': il['name'],
|
'name': il['name'],
|
||||||
'date': inv['date'],
|
'date': inv['date'],
|
||||||
'account_id': il['account_analytic_id'],
|
'account_id': il['account_analytic_id'],
|
||||||
'amount': inv['amount'] * sign,
|
'amount': inv['amount'] * sign,
|
||||||
#'partner_id': il['partner_id'] or False,
|
|
||||||
'general_account_id': il['account_id'] or False,
|
'general_account_id': il['account_id'] or False,
|
||||||
'journal_id': self.pool.get('account.voucher').browse(cr, uid, id).journal_id.analytic_journal_id.id or False,
|
'journal_id': self.pool.get('account.voucher').browse(cr, uid, id).journal_id.analytic_journal_id.id or False,
|
||||||
'ref': ref,
|
'ref': ref,
|
||||||
|
@ -222,43 +218,41 @@ class account_voucher(osv.osv):
|
||||||
def action_move_line_create(self, cr, uid, ids, *args):
|
def action_move_line_create(self, cr, uid, ids, *args):
|
||||||
|
|
||||||
for inv in self.browse(cr, uid, ids):
|
for inv in self.browse(cr, uid, ids):
|
||||||
|
|
||||||
if inv.move_id:
|
if inv.move_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
company_currency = inv.company_id.currency_id.id
|
company_currency = inv.company_id.currency_id.id
|
||||||
|
|
||||||
# create the analytical lines
|
|
||||||
line_ids = self.read(cr, uid, [inv.id], ['payment_ids'])[0]['payment_ids']
|
line_ids = self.read(cr, uid, [inv.id], ['payment_ids'])[0]['payment_ids']
|
||||||
ils = self.pool.get('account.voucher.line').read(cr, uid, line_ids)
|
ils = self.pool.get('account.voucher.line').read(cr, uid, line_ids)
|
||||||
# one move line per invoice line
|
|
||||||
iml = self._get_analytic_lines(cr, uid, inv.id)
|
iml = self._get_analytic_lines(cr, uid, inv.id)
|
||||||
# check if taxes are all computed
|
|
||||||
diff_currency_p = inv.currency_id.id <> company_currency
|
diff_currency_p = inv.currency_id.id <> company_currency
|
||||||
# create one move line for the total and possibly adjust the other lines amount
|
|
||||||
total = 0
|
total = 0
|
||||||
if inv.type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
|
if inv.type in ('pay_voucher', 'journal_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'):
|
||||||
ref = inv.reference
|
ref = inv.reference
|
||||||
else:
|
else:
|
||||||
ref = self._convert_ref(cr, uid, inv.number)
|
ref = self._convert_ref(cr, uid, inv.number)
|
||||||
|
|
||||||
date = inv.date
|
date = inv.date
|
||||||
total_currency = 0
|
total_currency = 0
|
||||||
for i in iml:
|
for i in iml:
|
||||||
|
partner_id=i['partner_id']
|
||||||
|
acc_id = i['account_id']
|
||||||
if inv.currency_id.id != company_currency:
|
if inv.currency_id.id != company_currency:
|
||||||
i['currency_id'] = inv.currency_id.id
|
i['currency_id'] = inv.currency_id.id
|
||||||
i['amount_currency'] = i['amount']
|
i['amount_currency'] = i['amount']
|
||||||
else:
|
else:
|
||||||
i['amount_currency'] = False
|
i['amount_currency'] = False
|
||||||
i['currency_id'] = False
|
i['currency_id'] = False
|
||||||
i['ref'] = ref
|
if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher','journal_voucher'):
|
||||||
if inv.type in ('rec_voucher','bank_rec_voucher','journal_pur_voucher'):
|
|
||||||
total += i['amount']
|
total += i['amount']
|
||||||
total_currency += i['amount_currency'] or i['amount']
|
total_currency += i['amount_currency'] or i['amount']
|
||||||
i['amount'] = - i['amount']
|
i['amount'] = - i['amount']
|
||||||
else:
|
else:
|
||||||
total -= i['amount']
|
total -= i['amount']
|
||||||
total_currency -= i['amount_currency'] or i['amount']
|
total_currency -= i['amount_currency'] or i['amount']
|
||||||
acc_id = inv.account_id.id
|
|
||||||
|
|
||||||
name = inv['name'] or '/'
|
name = inv['name'] or '/'
|
||||||
totlines = False
|
totlines = False
|
||||||
|
@ -266,39 +260,104 @@ class account_voucher(osv.osv):
|
||||||
iml.append({
|
iml.append({
|
||||||
'type': 'dest',
|
'type': 'dest',
|
||||||
'name': name,
|
'name': name,
|
||||||
'amount': total,
|
'amount': total or False,
|
||||||
'account_id': acc_id,
|
'account_id': acc_id,
|
||||||
'amount_currency': diff_currency_p \
|
'amount_currency': diff_currency_p \
|
||||||
and total_currency or False,
|
and total_currency or False,
|
||||||
'currency_id': diff_currency_p \
|
'currency_id': diff_currency_p \
|
||||||
and inv.currency_id.id or False,
|
and inv.currency_id.id or False,
|
||||||
'ref': ref
|
'ref': ref,
|
||||||
|
'partner_id':partner_id or False,
|
||||||
})
|
})
|
||||||
|
|
||||||
date = inv.date
|
date = inv.date
|
||||||
inv.amount=total
|
inv.amount=total
|
||||||
|
|
||||||
line = map(lambda x:(0, 0, self.line_get_convert(cr, uid, x,date, context={})), iml)
|
line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x,date, context={})) ,iml)
|
||||||
|
an_journal_id=inv.journal_id.analytic_journal_id.id
|
||||||
journal_id = inv.journal_id.id #self._get_journal(cr, uid, {'type': inv['type']})
|
journal_id = inv.journal_id.id
|
||||||
|
|
||||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
journal = self.pool.get('account.journal').browse(cr, uid, journal_id)
|
||||||
if journal.sequence_id:
|
if journal.sequence_id:
|
||||||
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
|
||||||
|
|
||||||
move = {'name': name, 'line_id': line, 'journal_id': journal_id}
|
move = {'name': name, 'journal_id': journal_id}
|
||||||
|
|
||||||
if inv.period_id:
|
if inv.period_id:
|
||||||
move['period_id'] = inv.period_id.id
|
move['period_id'] = inv.period_id.id
|
||||||
for i in line:
|
for i in line:
|
||||||
i[2]['period_id'] = inv.period_id.id
|
i[2]['period_id'] = inv.period_id.id
|
||||||
move_id = self.pool.get('account.move').create(cr, uid, move)
|
move_id = self.pool.get('account.move').create(cr, uid, move)
|
||||||
|
ref=move['name']
|
||||||
|
amount=0.0
|
||||||
|
|
||||||
|
#create the first line our self
|
||||||
|
move_line = {
|
||||||
|
'name': inv.name,
|
||||||
|
'debit': False,
|
||||||
|
'credit':False,
|
||||||
|
'account_id': inv.account_id.id or False,
|
||||||
|
'move_id':move_id ,
|
||||||
|
'journal_id':journal_id ,
|
||||||
|
'period_id':inv.period_id.id,
|
||||||
|
'partner_id': False,
|
||||||
|
'ref': ref,
|
||||||
|
'date': inv.date
|
||||||
|
}
|
||||||
|
if inv.type in ('rec_voucher', 'bank_rec_voucher', 'journal_pur_voucher', 'journal_voucher'):
|
||||||
|
move_line['debit'] = inv.amount
|
||||||
|
else:
|
||||||
|
move_line['credit'] = inv.amount * (-1)
|
||||||
|
self.pool.get('account.move.line').create(cr, uid, move_line)
|
||||||
|
|
||||||
|
for line in inv.payment_ids:
|
||||||
|
|
||||||
|
move_line = {
|
||||||
|
'name':line.name,
|
||||||
|
'debit':False,
|
||||||
|
'credit':False,
|
||||||
|
'account_id':line.account_id.id or False,
|
||||||
|
'move_id':move_id ,
|
||||||
|
'journal_id':journal_id ,
|
||||||
|
'period_id':inv.period_id.id,
|
||||||
|
'partner_id':line.partner_id.id or False,
|
||||||
|
'ref':ref,
|
||||||
|
'date':inv.date
|
||||||
|
}
|
||||||
|
|
||||||
|
if line.type == 'dr':
|
||||||
|
move_line['debit'] = line.amount or False
|
||||||
|
amount=line.amount
|
||||||
|
elif line.type == 'cr':
|
||||||
|
move_line['credit'] = line.amount or False
|
||||||
|
amount=line.amount * (-1)
|
||||||
|
ml_id=self.pool.get('account.move.line').create(cr, uid, move_line)
|
||||||
|
|
||||||
|
if inv.narration:
|
||||||
|
line.name=inv.narration
|
||||||
|
else:
|
||||||
|
line.name=line.name
|
||||||
|
|
||||||
|
an_line = {
|
||||||
|
'name':line.name,
|
||||||
|
'date':inv.date,
|
||||||
|
'amount':amount,
|
||||||
|
'account_id':line.account_analytic_id.id or False,
|
||||||
|
'move_id':ml_id,
|
||||||
|
'journal_id':an_journal_id ,
|
||||||
|
'general_account_id':line.account_id.id,
|
||||||
|
'ref':ref
|
||||||
|
}
|
||||||
|
self.pool.get('account.analytic.line').create(cr,uid,an_line)
|
||||||
|
|
||||||
self.write(cr, uid, [inv.id], {'move_id': move_id})
|
self.write(cr, uid, [inv.id], {'move_id': move_id})
|
||||||
obj=self.pool.get('account.move').browse(cr,uid,move_id)
|
obj=self.pool.get('account.move').browse(cr, uid, move_id)
|
||||||
|
|
||||||
for line in obj.line_id :
|
for line in obj.line_id :
|
||||||
cr.execute('insert into voucher_id (account_id,rel_account_move) values (%s, %s)',(int(ids[0]),int(line.id)))
|
cr.execute('insert into voucher_id (account_id,rel_account_move) values (%d, %d)',(int(ids[0]),int(line.id)))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def line_get_convert(self, cr, uid, x, date, context={}):
|
def line_get_convert(self, cr, uid, x, date, context={}):
|
||||||
return {
|
return {
|
||||||
'date':date,
|
'date':date,
|
||||||
|
@ -326,9 +385,9 @@ class account_voucher(osv.osv):
|
||||||
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
for (id, invtype, number, move_id, reference) in cr.fetchall():
|
||||||
if not number:
|
if not number:
|
||||||
number = self.pool.get('ir.sequence').get(cr, uid,
|
number = self.pool.get('ir.sequence').get(cr, uid,
|
||||||
'account.voucher.' + invtype)
|
invtype)
|
||||||
|
|
||||||
if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_vou','journal_pur_voucher'):
|
if type in ('pay_voucher', 'rec_voucher','cont_voucher','bank_pay_voucher','bank_rec_voucher','journal_sale_voucher','journal_pur_voucher'):
|
||||||
ref = reference
|
ref = reference
|
||||||
else:
|
else:
|
||||||
ref = self._convert_ref(cr, uid, number)
|
ref = self._convert_ref(cr, uid, number)
|
||||||
|
@ -344,21 +403,18 @@ class account_voucher(osv.osv):
|
||||||
(ref, move_id))
|
(ref, move_id))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def name_get(self, cr, uid, ids, context={}):
|
def name_get(self, cr, uid, ids, context={}):
|
||||||
if not len(ids):
|
if not len(ids):
|
||||||
return []
|
return []
|
||||||
types = {
|
types = {
|
||||||
'pay_voucher': 'CPV: ',
|
'pay_voucher': 'CPV: ',
|
||||||
'rec_voucher': 'CRV: ',
|
'rec_voucher': 'CRV: ',
|
||||||
'cont_voucher': 'CV: ',
|
'cont_voucher': 'CV: ',
|
||||||
'bank_pay_voucher': 'BPV: ',
|
'bank_pay_voucher': 'BPV: ',
|
||||||
'bank_rec_voucher': 'BRV: ',
|
'bank_rec_voucher': 'BRV: ',
|
||||||
'journal_sale_vou': 'JSV: ',
|
'journal_sale_voucher': 'JSV: ',
|
||||||
'journal_pur_voucher': 'JPV: ',
|
'journal_pur_voucher': 'JPV: ',
|
||||||
|
}
|
||||||
}
|
|
||||||
return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')]
|
return [(r['id'], types[r['type']]+(r['number'] or '')+' '+(r['name'] or '')) for r in self.read(cr, uid, ids, ['type', 'number', 'name'], context, load='_classic_write')]
|
||||||
|
|
||||||
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
|
||||||
|
@ -426,12 +482,11 @@ class VoucherLine(osv.osv):
|
||||||
res.append(self.move_line_get_item(cr, uid, line, context))
|
res.append(self.move_line_get_item(cr, uid, line, context))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def onchange_partner(self, cr, uid, ids, partner_id, type,type1):
|
def onchange_partner(self, cr, uid, ids, partner_id, type, type1):
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
return {'value' : {'account_id' : False, 'type' : False ,'amount':False}}
|
return {'value' : {'account_id' : False, 'type' : False ,'amount':False}}
|
||||||
obj = self.pool.get('res.partner')
|
obj = self.pool.get('res.partner')
|
||||||
account_id = False
|
account_id = False
|
||||||
|
|
||||||
if type1 in ('rec_voucher','bank_rec_voucher'):
|
if type1 in ('rec_voucher','bank_rec_voucher'):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
balance=obj.browse(cr,uid,partner_id).credit
|
balance=obj.browse(cr,uid,partner_id).credit
|
||||||
|
@ -440,12 +495,11 @@ class VoucherLine(osv.osv):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
balance=obj.browse(cr,uid,partner_id).debit
|
balance=obj.browse(cr,uid,partner_id).debit
|
||||||
type = 'dr'
|
type = 'dr'
|
||||||
elif type1 in ('journal_sale_vou') :
|
elif type1 in ('journal_sale_voucher') :
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
balance=obj.browse(cr,uid,partner_id).credit
|
balance=obj.browse(cr,uid,partner_id).credit
|
||||||
type = 'dr'
|
type = 'dr'
|
||||||
|
elif type1 in ('journal_pur_voucher') :
|
||||||
elif type1 in ('journal_pur_vou') :
|
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
balance=obj.browse(cr,uid,partner_id).debit
|
balance=obj.browse(cr,uid,partner_id).debit
|
||||||
type = 'cr'
|
type = 'cr'
|
||||||
|
@ -474,7 +528,7 @@ class VoucherLine(osv.osv):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
type = 'dr'
|
type = 'dr'
|
||||||
|
|
||||||
elif type1 in ('journal_sale_vou') :
|
elif type1 in ('journal_sale_voucher') :
|
||||||
if amount < 0 :
|
if amount < 0 :
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
type = 'cr'
|
type = 'cr'
|
||||||
|
@ -482,7 +536,7 @@ class VoucherLine(osv.osv):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
type = 'dr'
|
type = 'dr'
|
||||||
|
|
||||||
elif type1 in ('journal_pur_vou') :
|
elif type1 in ('journal_pur_voucher') :
|
||||||
if amount< 0 :
|
if amount< 0 :
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
type = 'dr'
|
type = 'dr'
|
||||||
|
@ -516,7 +570,7 @@ class VoucherLine(osv.osv):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
amount*=1
|
amount*=1
|
||||||
|
|
||||||
elif type1 in ('journal_sale_vou') :
|
elif type1 in ('journal_sale_voucher') :
|
||||||
if type == 'cr' :
|
if type == 'cr' :
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
account_id = obj.browse(cr, uid, partner_id).property_account_payable
|
||||||
amount*=-1
|
amount*=-1
|
||||||
|
@ -524,7 +578,7 @@ class VoucherLine(osv.osv):
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
amount*=1
|
amount*=1
|
||||||
|
|
||||||
elif type1 in ('journal_pur_vou') :
|
elif type1 in ('journal_pur_voucher') :
|
||||||
if type == 'dr' :
|
if type == 'dr' :
|
||||||
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
account_id = obj.browse(cr, uid, partner_id).property_account_receivable
|
||||||
amount*=-1
|
amount*=-1
|
||||||
|
@ -539,12 +593,12 @@ class VoucherLine(osv.osv):
|
||||||
|
|
||||||
def move_line_get_item(self, cr, uid, line, context={}):
|
def move_line_get_item(self, cr, uid, line, context={}):
|
||||||
return {
|
return {
|
||||||
'type':'src',
|
'type':'src',
|
||||||
'name': line.name[:64],
|
'name': line.name[:64],
|
||||||
'amount':line.amount,
|
'amount':line.amount,
|
||||||
'account_id':line.account_id.id,
|
'account_id':line.account_id.id,
|
||||||
'partner_id':line.partner_id.id or False ,
|
'partner_id':line.partner_id.id or False ,
|
||||||
'account_analytic_id':line.account_analytic_id.id or False,
|
'account_analytic_id':line.account_analytic_id.id or False,
|
||||||
}
|
}
|
||||||
VoucherLine()
|
VoucherLine()
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<field name="payment_ids" colspan="4" nolabel="1">
|
<field name="payment_ids" colspan="4" nolabel="1">
|
||||||
<tree string="Voucher Lines" editable="top">
|
<tree string="Voucher Lines" editable="top">
|
||||||
<field name="account_analytic_id"/>
|
<field name="account_analytic_id"/>
|
||||||
<field name="partner_id" on_change="onchange_partner(partner_id,type,parent.type)"/>
|
<field name="partner_id" on_change="onchange_partner(partner_id, type, parent.type)"/>
|
||||||
<field name="account_id"/>
|
<field name="account_id"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="ref"/>
|
<field name="ref"/>
|
||||||
|
|
Loading…
Reference in New Issue