invoice numbering module(from 4.2 addons) merge to account
bzr revid: mra@tinyerp.com-20090116062102-ceollow4a2eyc8d1
This commit is contained in:
parent
9f89106631
commit
81632ee871
|
@ -457,6 +457,7 @@ class account_journal(osv.osv):
|
||||||
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
|
'currency': fields.many2one('res.currency', 'Currency', help='The currency used to enter statement'),
|
||||||
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want that new account moves pass through the \'draft\' state and goes direclty to the \'posted state\' without any manual validation.'),
|
'entry_posted': fields.boolean('Skip \'Draft\' State for Created Entries', help='Check this box if you don\'t want that new account moves pass through the \'draft\' state and goes direclty to the \'posted state\' without any manual validation.'),
|
||||||
'company_id': fields.related('default_credit_account_id','company_id',type='many2one', relation="res.company", string="Company"),
|
'company_id': fields.related('default_credit_account_id','company_id',type='many2one', relation="res.company", string="Company"),
|
||||||
|
'fy_seq_id': fields.one2many('fiscalyear.seq', 'journal_id', 'Sequences'),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
|
@ -922,7 +923,7 @@ class account_move(osv.osv):
|
||||||
for move in self.browse(cr, uid, ids, context):
|
for move in self.browse(cr, uid, ids, context):
|
||||||
#unlink analytic lines on move_lines
|
#unlink analytic lines on move_lines
|
||||||
for obj_line in move.line_id:
|
for obj_line in move.line_id:
|
||||||
for obj in obj_line.analytic_lines:
|
for obj in obj_line.analytic_lines:
|
||||||
self.pool.get('account.analytic.line').unlink(cr,uid,obj.id)
|
self.pool.get('account.analytic.line').unlink(cr,uid,obj.id)
|
||||||
|
|
||||||
journal = move.journal_id
|
journal = move.journal_id
|
||||||
|
@ -1871,14 +1872,14 @@ account_tax_template()
|
||||||
class account_fiscal_position_template(osv.osv):
|
class account_fiscal_position_template(osv.osv):
|
||||||
_name = 'account.fiscal.position.template'
|
_name = 'account.fiscal.position.template'
|
||||||
_description = 'Template for Fiscal Position'
|
_description = 'Template for Fiscal Position'
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Fiscal Position Template', size=64, translate=True, required=True),
|
'name': fields.char('Fiscal Position Template', size=64, translate=True, required=True),
|
||||||
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
|
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
|
||||||
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Accounts Mapping'),
|
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Accounts Mapping'),
|
||||||
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Taxes Mapping')
|
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Taxes Mapping')
|
||||||
}
|
}
|
||||||
|
|
||||||
account_fiscal_position_template()
|
account_fiscal_position_template()
|
||||||
|
|
||||||
class account_fiscal_position_tax_template(osv.osv):
|
class account_fiscal_position_tax_template(osv.osv):
|
||||||
|
@ -1904,7 +1905,7 @@ class account_fiscal_position_account_template(osv.osv):
|
||||||
'account_dest_id': fields.many2one('account.account.template', 'Account Destination', domain=[('type','<>','view')], required=True)
|
'account_dest_id': fields.many2one('account.account.template', 'Account Destination', domain=[('type','<>','view')], required=True)
|
||||||
}
|
}
|
||||||
|
|
||||||
account_fiscal_position_account_template()
|
account_fiscal_position_account_template()
|
||||||
|
|
||||||
# Multi charts of Accounts wizard
|
# Multi charts of Accounts wizard
|
||||||
|
|
||||||
|
@ -2155,19 +2156,19 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
property_obj.create(cr, uid, vals)
|
property_obj.create(cr, uid, vals)
|
||||||
|
|
||||||
fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)])
|
fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)])
|
||||||
|
|
||||||
if fp_ids:
|
if fp_ids:
|
||||||
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
||||||
|
|
||||||
vals_fp = {
|
vals_fp = {
|
||||||
'company_id' : company_id,
|
'company_id' : company_id,
|
||||||
'name' : position.name,
|
'name' : position.name,
|
||||||
}
|
}
|
||||||
new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
|
new_fp = obj_fiscal_position.create(cr, uid, vals_fp)
|
||||||
|
|
||||||
obj_tax_fp = self.pool.get('account.fiscal.position.tax')
|
obj_tax_fp = self.pool.get('account.fiscal.position.tax')
|
||||||
obj_ac_fp = self.pool.get('account.fiscal.position.account')
|
obj_ac_fp = self.pool.get('account.fiscal.position.account')
|
||||||
|
|
||||||
for tax in position.tax_ids:
|
for tax in position.tax_ids:
|
||||||
vals_tax = {
|
vals_tax = {
|
||||||
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
|
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
|
||||||
|
@ -2175,7 +2176,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
'position_id' : new_fp,
|
'position_id' : new_fp,
|
||||||
}
|
}
|
||||||
obj_tax_fp.create(cr, uid, vals_tax)
|
obj_tax_fp.create(cr, uid, vals_tax)
|
||||||
|
|
||||||
for acc in position.account_ids:
|
for acc in position.account_ids:
|
||||||
vals_acc = {
|
vals_acc = {
|
||||||
'account_src_id' : acc_template_ref[acc.account_src_id.id],
|
'account_src_id' : acc_template_ref[acc.account_src_id.id],
|
||||||
|
@ -2183,7 +2184,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||||
'position_id' : new_fp,
|
'position_id' : new_fp,
|
||||||
}
|
}
|
||||||
obj_ac_fp.create(cr, uid, vals_acc)
|
obj_ac_fp.create(cr, uid, vals_acc)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'view_type': 'form',
|
'view_type': 'form',
|
||||||
"view_mode": 'form',
|
"view_mode": 'form',
|
||||||
|
|
|
@ -269,6 +269,16 @@
|
||||||
<field name="group_invoice_lines"/>
|
<field name="group_invoice_lines"/>
|
||||||
|
|
||||||
<field name="update_posted"/>
|
<field name="update_posted"/>
|
||||||
|
<field name="fy_seq_id" colspan="4" widget="one2many_list" >
|
||||||
|
<tree string="Invoice Sequences">
|
||||||
|
<field name="fiscalyear_id"/>
|
||||||
|
<field name="sequence_id"/>
|
||||||
|
</tree>
|
||||||
|
<form string="Invoice Sequences">
|
||||||
|
<field name="fiscalyear_id"/>
|
||||||
|
<field name="sequence_id"/>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
<field name="entry_posted"/>
|
<field name="entry_posted"/>
|
||||||
</page>
|
</page>
|
||||||
<page string="Entry Controls">
|
<page string="Entry Controls">
|
||||||
|
@ -1682,9 +1692,9 @@
|
||||||
</graph>
|
</graph>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Fiscal Position Templates -->
|
<!-- Fiscal Position Templates -->
|
||||||
|
|
||||||
<record id="view_account_position_template_form" model="ir.ui.view">
|
<record id="view_account_position_template_form" model="ir.ui.view">
|
||||||
<field name="name">account.fiscal.position.template.form</field>
|
<field name="name">account.fiscal.position.template.form</field>
|
||||||
<field name="model">account.fiscal.position.template</field>
|
<field name="model">account.fiscal.position.template</field>
|
||||||
|
|
|
@ -30,6 +30,18 @@ from mx.DateTime import RelativeDateTime
|
||||||
from tools import config
|
from tools import config
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
|
|
||||||
|
class fiscalyear_seq(osv.osv):
|
||||||
|
_name = "fiscalyear.seq"
|
||||||
|
_description = "Maintains Invoice sequences with Fiscal Year"
|
||||||
|
_rec_name = 'fiscalyear_id'
|
||||||
|
_columns = {
|
||||||
|
'journal_id': fields.many2one('account.journal', 'Journal'),
|
||||||
|
'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year',required=True),
|
||||||
|
'sequence_id':fields.many2one('ir.sequence', 'Sequence',required=True),
|
||||||
|
}
|
||||||
|
|
||||||
|
fiscalyear_seq()
|
||||||
|
|
||||||
class account_invoice(osv.osv):
|
class account_invoice(osv.osv):
|
||||||
def _amount_all(self, cr, uid, ids, name, args, context=None):
|
def _amount_all(self, cr, uid, ids, name, args, context=None):
|
||||||
res = {}
|
res = {}
|
||||||
|
@ -384,7 +396,7 @@ class account_invoice(osv.osv):
|
||||||
for taxe in ait_obj.compute(cr, uid, id).values():
|
for taxe in ait_obj.compute(cr, uid, id).values():
|
||||||
ait_obj.create(cr, uid, taxe)
|
ait_obj.create(cr, uid, taxe)
|
||||||
# Update the stored value (fields.function), so we write to trigger recompute
|
# Update the stored value (fields.function), so we write to trigger recompute
|
||||||
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
|
self.pool.get('account.invoice').write(cr, uid, ids, {}, context=context)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def button_compute(self, cr, uid, ids, context=None, set_total=False):
|
def button_compute(self, cr, uid, ids, context=None, set_total=False):
|
||||||
|
@ -621,10 +633,18 @@ class account_invoice(osv.osv):
|
||||||
cr.execute('SELECT id, type, number, move_id, reference ' \
|
cr.execute('SELECT id, type, number, move_id, reference ' \
|
||||||
'FROM account_invoice ' \
|
'FROM account_invoice ' \
|
||||||
'WHERE id IN ('+','.join(map(str,ids))+')')
|
'WHERE id IN ('+','.join(map(str,ids))+')')
|
||||||
|
obj_inv = self.browse(cr, uid, ids)[0]
|
||||||
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,
|
flag = True
|
||||||
'account.invoice.' + invtype)
|
for seq in obj_inv.journal_id.fy_seq_id:
|
||||||
|
if seq.fiscalyear_id.id == obj_inv.move_id.period_id.fiscalyear_id.id:
|
||||||
|
number = self.pool.get('ir.sequence').get_id(cr, uid,seq.sequence_id.id)
|
||||||
|
flag = False
|
||||||
|
break
|
||||||
|
if flag:
|
||||||
|
number = self.pool.get('ir.sequence').get(cr, uid,
|
||||||
|
'account.invoice.' + invtype)
|
||||||
if invtype in ('in_invoice', 'in_refund'):
|
if invtype in ('in_invoice', 'in_refund'):
|
||||||
ref = reference
|
ref = reference
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue