Corrected manual entry behaviour on account.move form for unsaved move.line
Provided complete onchange effect to account.move.line removed old journal creation scheme Minor bugfixes and set the digits of code for accounts on charts of templates bzr revid: jvo@tinyerp.com-20080911113644-32ll82zbfsjkrzng
This commit is contained in:
commit
559e9c58be
|
@ -1522,8 +1522,6 @@ class account_config_fiscalyear(osv.osv_memory):
|
|||
|
||||
account_config_fiscalyear()
|
||||
|
||||
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Account Templates : Account, Tax, Tax Code and chart. + Wizard
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -1843,11 +1841,13 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
for tax in account_template.tax_ids:
|
||||
tax_ids.append(tax_template_ref[tax.id])
|
||||
#create the account_account
|
||||
|
||||
dig = obj_multi.code_digits
|
||||
code_main = len(account_template.code)
|
||||
code_acc = account_template.code
|
||||
if code_main<=dig and account_template.type != 'view':
|
||||
code_acc=str(code_acc) + (str('0'*(dig-code_main)))
|
||||
|
||||
vals={
|
||||
'name': (obj_acc_root.id == account_template.id) and obj_multi.company_id.name or account_template.name,
|
||||
#'sign': account_template.sign,
|
||||
|
@ -1924,7 +1924,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
|||
vals={
|
||||
'name': line.acc_no.bank and line.acc_no.bank.name+' '+tmp or tmp,
|
||||
'currency_id': line.currency_id and line.currency_id.id or False,
|
||||
'code': code_acc[:dig],
|
||||
'code': ref_acc_bank.code+str(current_num),
|
||||
'type': 'other',
|
||||
'user_type': account_template.user_type and account_template.user_type.id or False,
|
||||
'reconcile': True,
|
||||
|
|
|
@ -70,6 +70,33 @@ class account_move_line(osv.osv):
|
|||
# Compute simple values
|
||||
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
||||
|
||||
# Starts: Manual entry from account.move form
|
||||
if context.get('lines',[]):
|
||||
|
||||
total_new=0.00
|
||||
for i in context['lines']:
|
||||
total_new +=(i[2]['debit'] or 0.00)- (i[2]['credit'] or 0.00)
|
||||
for item in i[2]:
|
||||
data[item]=i[2][item]
|
||||
if context['journal']:
|
||||
journal_obj=self.pool.get('account.journal').browse(cr,uid,context['journal'])
|
||||
if journal_obj.type == 'purchase':
|
||||
if total_new>0:
|
||||
account = journal_obj.default_credit_account_id
|
||||
else:
|
||||
account = journal_obj.default_debit_account_id
|
||||
else:
|
||||
if total_new>0:
|
||||
account = journal_obj.default_credit_account_id
|
||||
else:
|
||||
account = journal_obj.default_debit_account_id
|
||||
data['account_id'] = account.id
|
||||
s = -total_new
|
||||
data['debit'] = s>0 and s or 0.0
|
||||
data['credit'] = s<0 and -s or 0.0
|
||||
return data
|
||||
# Ends: Manual entry from account.move form
|
||||
|
||||
if not 'move_id' in fields: #we are not in manual entry
|
||||
return data
|
||||
|
||||
|
@ -342,11 +369,13 @@ class account_move_line(osv.osv):
|
|||
def onchange_partner_id(self, cr, uid, ids, move_id, partner_id, account_id=None, debit=0, credit=0, date=False, journal=False):
|
||||
val = {}
|
||||
val['date_maturity'] = False
|
||||
|
||||
if not partner_id:
|
||||
return {'value':val}
|
||||
if not date:
|
||||
date = now().strftime('%Y-%m-%d')
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
|
||||
if part.property_payment_term and part.property_payment_term.line_ids:# Compute Maturity Date in val !
|
||||
line = part.property_payment_term.line_ids[0]
|
||||
next_date = mx.DateTime.strptime(date, '%Y-%m-%d') + RelativeDateTime(days=line.days)
|
||||
|
@ -647,7 +676,6 @@ class account_move_line(osv.osv):
|
|||
def create(self, cr, uid, vals, context=None, check=True):
|
||||
if not context:
|
||||
context={}
|
||||
|
||||
account_obj = self.pool.get('account.account')
|
||||
tax_obj=self.pool.get('account.tax')
|
||||
|
||||
|
|
|
@ -802,13 +802,13 @@
|
|||
<field name="to_check" select="2"/>
|
||||
|
||||
<separator colspan="4" string="Entry Lines"/>
|
||||
<field colspan="4" name="line_id" nolabel="1" readonly="1" widget="one2many_list">
|
||||
<field colspan="4" name="line_id" nolabel="1" widget="one2many_list" default_get="{'lines':line_id ,'journal':journal_id }">
|
||||
<form string="Account Entry Line">
|
||||
<separator colspan="4" string="General Information"/>
|
||||
<field name="name" select="1"/>
|
||||
<field name="date"/>
|
||||
<field name="account_id"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date)"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date,parent.journal_id)"/>
|
||||
|
||||
<field name="debit" select="1"/>
|
||||
<field name="credit" select="1"/>
|
||||
|
@ -830,7 +830,7 @@
|
|||
<tree editable="top" string="Account Entry Line">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date)"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(False,partner_id,account_id,debit,credit,date,parent.journal_id)"/>
|
||||
<field name="account_id"/>
|
||||
<field name="date_maturity"/>
|
||||
<field name="ref"/>
|
||||
|
@ -856,7 +856,18 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_move_tree"/>
|
||||
</record>
|
||||
<menuitem id="next_id_29" name="Search Entries" parent="account.menu_finance_accounting"/><menuitem action="action_move_line_form" id="menu_action_move_line_form" parent="next_id_29"/>
|
||||
<menuitem id="next_id_29" name="Search Entries" parent="account.menu_finance_accounting"/>
|
||||
<menuitem action="action_move_line_form" id="menu_action_move_line_form" parent="next_id_29"/>
|
||||
|
||||
<record id="action_move_line_form_encode_by_move" model="ir.actions.act_window">
|
||||
<field name="name">Entries Encoding by Move</field>
|
||||
<field name="res_model">account.move</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_move_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_move_line_form_encode_by_move" id="menu_encode_entries_by_move" parent="menu_finance_entries"/>
|
||||
|
||||
<record id="action_move_line_search" model="ir.actions.act_window">
|
||||
<field name="name">Entry lines</field>
|
||||
|
@ -1343,7 +1354,6 @@
|
|||
</record>
|
||||
|
||||
|
||||
|
||||
<!-- register configuration wizard -->
|
||||
|
||||
<record id="config_fiscalyear" model="ir.module.module.configuration.step">
|
||||
|
|
Loading…
Reference in New Issue