[IMP] Account:
- added analytic_account field on account_model_line - removed wizard asking whether to open entries after creating entries from account model - validating moves through Accounting/Periodical Processing/Draft Entries/Validate Journal Entries wizard validated moves with unbalanced entries too, fixed the bug - added search view on account model bzr revid: pap@tinyerp.co.in-20100903112950-eoferlxasre8pjkw
This commit is contained in:
parent
4fd67b69c6
commit
20bbdd3cf1
|
@ -1129,8 +1129,9 @@ class account_move(osv.osv):
|
||||||
|
|
||||||
def post(self, cr, uid, ids, context=None):
|
def post(self, cr, uid, ids, context=None):
|
||||||
invoice = context.get('invoice', False)
|
invoice = context.get('invoice', False)
|
||||||
if self.validate(cr, uid, ids, context) and len(ids):
|
valid_moves = self.validate(cr, uid, ids, context)
|
||||||
for move in self.browse(cr, uid, ids):
|
if valid_moves:
|
||||||
|
for move in self.browse(cr, uid, valid_moves):
|
||||||
if move.name =='/':
|
if move.name =='/':
|
||||||
new_name = False
|
new_name = False
|
||||||
journal = move.journal_id
|
journal = move.journal_id
|
||||||
|
@ -1150,7 +1151,7 @@ class account_move(osv.osv):
|
||||||
cr.execute('UPDATE account_move '\
|
cr.execute('UPDATE account_move '\
|
||||||
'SET state=%s '\
|
'SET state=%s '\
|
||||||
'WHERE id IN %s',
|
'WHERE id IN %s',
|
||||||
('posted', tuple(ids),))
|
('posted', tuple(valid_moves),))
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
raise osv.except_osv(_('Integrity Error !'), _('You can not validate a non-balanced entry !\nMake sure you have configured Payment Term properly !\nIt should contain atleast one Payment Term Line with type "Balance" !'))
|
||||||
return True
|
return True
|
||||||
|
@ -1421,7 +1422,8 @@ class account_move(osv.osv):
|
||||||
for record in valid_moves:
|
for record in valid_moves:
|
||||||
self.pool.get('account.move.line').create_analytic_lines(cr, uid, [line.id for line in record.line_id], context)
|
self.pool.get('account.move.line').create_analytic_lines(cr, uid, [line.id for line in record.line_id], context)
|
||||||
|
|
||||||
return len(valid_moves) > 0
|
valid_moves = [move.id for move in valid_moves]
|
||||||
|
return len(valid_moves) > 0 and valid_moves or False
|
||||||
|
|
||||||
account_move()
|
account_move()
|
||||||
|
|
||||||
|
@ -1986,21 +1988,26 @@ class account_model(osv.osv):
|
||||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||||
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
|
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
|
||||||
'legend' :fields.text('Legend', readonly=True, size=100),
|
'legend' :fields.text('Legend', readonly=True, size=100),
|
||||||
|
'date': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'),
|
'legend': lambda self, cr, uid, context:_('You can specify year, month and date in the name of the model using the following labels:\n\n%(year)s : To Specify Year \n%(month)s : To Specify Month \n%(date)s : Current Date\n\ne.g. My model on %(date)s'),
|
||||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id
|
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||||
|
'date': 'today'
|
||||||
}
|
}
|
||||||
def generate(self, cr, uid, ids, datas={}, context={}):
|
def generate(self, cr, uid, ids, datas={}, context={}):
|
||||||
move_ids = []
|
move_ids = []
|
||||||
|
account_move_obj = self.pool.get('account.move')
|
||||||
|
account_move_line_obj = self.pool.get('account.move.line')
|
||||||
|
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
|
||||||
|
if not period_id:
|
||||||
|
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
|
||||||
|
period_id = period_id[0]
|
||||||
|
|
||||||
for model in self.browse(cr, uid, ids, context):
|
for model in self.browse(cr, uid, ids, context):
|
||||||
context.update({'date':datas['date']})
|
context.update({'date':datas['date']})
|
||||||
period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
|
move_id = account_move_obj.create(cr, uid, {
|
||||||
if not period_id:
|
|
||||||
raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
|
|
||||||
period_id = period_id[0]
|
|
||||||
move_id = self.pool.get('account.move').create(cr, uid, {
|
|
||||||
'ref': model.ref,
|
'ref': model.ref,
|
||||||
'period_id': period_id,
|
'period_id': period_id,
|
||||||
'journal_id': model.journal_id.id,
|
'journal_id': model.journal_id.id,
|
||||||
|
@ -2008,10 +2015,16 @@ class account_model(osv.osv):
|
||||||
})
|
})
|
||||||
move_ids.append(move_id)
|
move_ids.append(move_id)
|
||||||
for line in model.lines_id:
|
for line in model.lines_id:
|
||||||
|
analytic_account_id = False
|
||||||
|
if line.analytic_account_id:
|
||||||
|
if not model.journal_id.analytic_journal_id:
|
||||||
|
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
|
||||||
|
analytic_account_id = line.analytic_account_id.id
|
||||||
val = {
|
val = {
|
||||||
'move_id': move_id,
|
'move_id': move_id,
|
||||||
'journal_id': model.journal_id.id,
|
'journal_id': model.journal_id.id,
|
||||||
'period_id': period_id
|
'period_id': period_id,
|
||||||
|
'analytic_account_id': analytic_account_id
|
||||||
}
|
}
|
||||||
val.update({
|
val.update({
|
||||||
'name': line.name,
|
'name': line.name,
|
||||||
|
@ -2027,7 +2040,7 @@ class account_model(osv.osv):
|
||||||
})
|
})
|
||||||
c = context.copy()
|
c = context.copy()
|
||||||
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
||||||
self.pool.get('account.move.line').create(cr, uid, val, context=c)
|
account_move_line_obj.create(cr, uid, val, context=c)
|
||||||
return move_ids
|
return move_ids
|
||||||
account_model()
|
account_model()
|
||||||
|
|
||||||
|
@ -2040,22 +2053,14 @@ class account_model_line(osv.osv):
|
||||||
'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Account'), help="The optional quantity on entries"),
|
'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Account'), help="The optional quantity on entries"),
|
||||||
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
|
||||||
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
|
||||||
|
|
||||||
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade"),
|
|
||||||
|
|
||||||
'model_id': fields.many2one('account.model', 'Model', required=True, ondelete="cascade", select=True),
|
|
||||||
|
|
||||||
'ref': fields.char('Reference', size=16),
|
'ref': fields.char('Reference', size=16),
|
||||||
|
'account_id': fields.many2one('account.account', 'Account', required=True, ondelete="cascade"),
|
||||||
|
'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account', ondelete="cascade"),
|
||||||
|
'model_id': fields.many2one('account.model', 'Model', required=True, ondelete="cascade", select=True),
|
||||||
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency."),
|
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency."),
|
||||||
'currency_id': fields.many2one('res.currency', 'Currency'),
|
'currency_id': fields.many2one('res.currency', 'Currency'),
|
||||||
|
|
||||||
'partner_id': fields.many2one('res.partner', 'Partner'),
|
'partner_id': fields.many2one('res.partner', 'Partner'),
|
||||||
'date_maturity': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Maturity date', help="The maturity date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."),
|
'date_maturity': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Maturity date', help="The maturity date of the generated entries for this model. You can choose between the creation date or the creation date of the entries plus the partner payment terms."),
|
||||||
'date': fields.selection([('today','Date of the day'), ('partner','Partner Payment Term')], 'Current Date', required=True, help="The date of the generated entries"),
|
|
||||||
}
|
|
||||||
_defaults = {
|
|
||||||
'date': lambda *a: 'today'
|
|
||||||
}
|
}
|
||||||
_order = 'sequence'
|
_order = 'sequence'
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
|
|
|
@ -986,7 +986,7 @@ class account_move_line(osv.osv):
|
||||||
if 'period_id' in vals and 'period_id' not in context:
|
if 'period_id' in vals and 'period_id' not in context:
|
||||||
period_id = vals['period_id']
|
period_id = vals['period_id']
|
||||||
elif 'journal_id' not in context and 'move_id' in vals:
|
elif 'journal_id' not in context and 'move_id' in vals:
|
||||||
if vals['move_id']:
|
if vals.get('move_id', False):
|
||||||
m = self.pool.get('account.move').browse(cr, uid, vals['move_id'])
|
m = self.pool.get('account.move').browse(cr, uid, vals['move_id'])
|
||||||
journal_id = m.journal_id.id
|
journal_id = m.journal_id.id
|
||||||
period_id = m.period_id.id
|
period_id = m.period_id.id
|
||||||
|
|
|
@ -1548,13 +1548,13 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Journal Entry Model Line" editable="bottom">
|
<tree string="Journal Entry Model Line" editable="bottom">
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="ref"/>
|
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
<field name="ref"/>
|
||||||
<field name="account_id"/>
|
<field name="account_id"/>
|
||||||
|
<field name="analytic_account_id"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="debit"/>
|
<field name="debit"/>
|
||||||
<field name="credit"/>
|
<field name="credit"/>
|
||||||
<field name="date"/>
|
|
||||||
<field name="date_maturity"/>
|
<field name="date_maturity"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
|
@ -1571,12 +1571,11 @@
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="ref" select="1"/>
|
<field name="ref" select="1"/>
|
||||||
<field name="account_id" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
<field name="account_id" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
|
||||||
|
<field name="analytic_account_id"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
|
<field name="quantity"/>
|
||||||
<field name="debit" select="1"/>
|
<field name="debit" select="1"/>
|
||||||
<field name="credit" select="1"/>
|
<field name="credit" select="1"/>
|
||||||
<field name="quantity"/>
|
|
||||||
<newline/>
|
|
||||||
<field name="date"/>
|
|
||||||
<field name="date_maturity"/>
|
<field name="date_maturity"/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
@ -1589,9 +1588,10 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Journal Entry Model">
|
<form string="Journal Entry Model">
|
||||||
<field name="name" select="1"/>
|
<field name="name" select="1"/>
|
||||||
<field name="ref" select="1"/>
|
<field name="ref"/>
|
||||||
<field name="journal_id" select="1"/>
|
<field name="journal_id" select="1"/>
|
||||||
<field name="company_id" select="1" widget='selection'/>
|
<field name="company_id" select="1" widget='selection' groups="base.group_multi_company"/>
|
||||||
|
<field name="date" context="{'date': date}"/>
|
||||||
<field colspan="4" nolabel="1" name="lines_id" height="250" widget="one2many_list"/>
|
<field colspan="4" nolabel="1" name="lines_id" height="250" widget="one2many_list"/>
|
||||||
<separator string="Legend" colspan="4"/>
|
<separator string="Legend" colspan="4"/>
|
||||||
<field name="legend" colspan="4" nolabel="1"/>
|
<field name="legend" colspan="4" nolabel="1"/>
|
||||||
|
@ -1601,6 +1601,7 @@
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_model_tree" model="ir.ui.view">
|
<record id="view_model_tree" model="ir.ui.view">
|
||||||
<field name="name">account.model.tree</field>
|
<field name="name">account.model.tree</field>
|
||||||
<field name="model">account.model</field>
|
<field name="model">account.model</field>
|
||||||
|
@ -1609,15 +1610,39 @@
|
||||||
<tree string="Journal Entry Model">
|
<tree string="Journal Entry Model">
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
<field name="company_id"/>
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="view_model_search" model="ir.ui.view">
|
||||||
|
<field name="name">account.model.search</field>
|
||||||
|
<field name="model">account.model</field>
|
||||||
|
<field name="type">search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Journal Entry Model">
|
||||||
|
<group>
|
||||||
|
<filter string="Sale" icon="terp-sale" domain="[('journal_id.type', '=', 'sale')]"/>
|
||||||
|
<filter string="Purchase" icon="terp-purchase" domain="[('journal_id.type', '=', 'purchase')]"/>
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="journal_id"/>
|
||||||
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
|
</group>
|
||||||
|
<newline/>
|
||||||
|
<group expand="0" string="Group By...">
|
||||||
|
<filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="action_model_form" model="ir.actions.act_window">
|
<record id="action_model_form" model="ir.actions.act_window">
|
||||||
<field name="name">Recurring Models</field>
|
<field name="name">Recurring Models</field>
|
||||||
<field name="res_model">account.model</field>
|
<field name="res_model">account.model</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form,search</field>
|
||||||
|
<field name="search_id">view_model_search</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem action="action_model_form" id="menu_action_model_form" sequence="5" parent="account.menu_configuration_misc" groups="base.group_extended"/>
|
<menuitem action="action_model_form" id="menu_action_model_form" sequence="5" parent="account.menu_configuration_misc" groups="base.group_extended"/>
|
||||||
|
|
||||||
|
@ -2418,6 +2443,7 @@
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency, {'amount': amount})"/>
|
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency, {'amount': amount})"/>
|
||||||
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
|
<field domain="[('journal_id','=',parent.journal_id)]" name="account_id"/>
|
||||||
|
<field name="analytic_account_id" groups="base.group_extended" />
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field context="{'partner_id': partner_id, 'amount': amount, 'account_id': account_id, 'currency_id': parent.currency, 'journal_id': parent.journal_id, 'date':date}" name="reconcile_id"/>
|
<field context="{'partner_id': partner_id, 'amount': amount, 'account_id': account_id, 'currency_id': parent.currency, 'journal_id': parent.journal_id, 'date':date}" name="reconcile_id"/>
|
||||||
<field invisible="1" name="reconcile_amount"/>
|
<field invisible="1" name="reconcile_amount"/>
|
||||||
|
|
|
@ -60,10 +60,16 @@ class account_use_model(osv.osv_memory):
|
||||||
})
|
})
|
||||||
move_ids.append(move_id)
|
move_ids.append(move_id)
|
||||||
for line in model.lines_id:
|
for line in model.lines_id:
|
||||||
|
analytic_account_id = False
|
||||||
|
if line.analytic_account_id:
|
||||||
|
if not model.journal_id.analytic_journal_id:
|
||||||
|
raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (model.journal_id.name,))
|
||||||
|
analytic_account_id = line.analytic_account_id.id
|
||||||
val = {
|
val = {
|
||||||
'move_id': move_id,
|
'move_id': move_id,
|
||||||
'journal_id': model.journal_id.id,
|
'journal_id': model.journal_id.id,
|
||||||
'period_id': period_id
|
'period_id': period_id,
|
||||||
|
'analytic_account_id': analytic_account_id
|
||||||
}
|
}
|
||||||
val.update({
|
val.update({
|
||||||
'name': line.name,
|
'name': line.name,
|
||||||
|
@ -80,24 +86,8 @@ class account_use_model(osv.osv_memory):
|
||||||
c = context.copy()
|
c = context.copy()
|
||||||
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
||||||
id_line = account_move_line_obj.create(cr, uid, val, context=c)
|
id_line = account_move_line_obj.create(cr, uid, val, context=c)
|
||||||
context.update({'move_ids':move_ids})
|
|
||||||
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_use_model_open_entry')], context=context)
|
|
||||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
|
||||||
return {
|
|
||||||
'name': _('Use Model'),
|
|
||||||
'context': context,
|
|
||||||
'view_type': 'form',
|
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'account.use.model',
|
|
||||||
'views': [(resource_id,'form')],
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
'target': 'new',
|
|
||||||
}
|
|
||||||
|
|
||||||
def open_moves(self, cr, uid, ids, context=None):
|
context.update({'move_ids':move_ids})
|
||||||
mod_obj = self.pool.get('ir.model.data')
|
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_move_form')], context=context)
|
model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_move_form')], context=context)
|
||||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -42,22 +42,6 @@
|
||||||
<field name="model">account.move.line</field>
|
<field name="model">account.move.line</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_account_use_model_open_entry" model="ir.ui.view">
|
|
||||||
<field name="name">account.use.model.open.entry.form</field>
|
|
||||||
<field name="model">account.use.model</field>
|
|
||||||
<field name="type">form</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<form string="Use Model">
|
|
||||||
<group colspan="4" col="6" width="300" height="70">
|
|
||||||
<label string = "Entry Lines Created." colspan="2"/>
|
|
||||||
<newline/>
|
|
||||||
<button icon="gtk-ok" special="cancel" string="Ok"/>
|
|
||||||
<button icon="terp-gtk-go-back-rtl" string="Open" name="open_moves" type="object" default_focus='1'/>
|
|
||||||
</group>
|
|
||||||
</form>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
|
|
||||||
<record id="view_account_use_model_create_entry" model="ir.ui.view">
|
<record id="view_account_use_model_create_entry" model="ir.ui.view">
|
||||||
<field name="name">account.use.model.create.entry.form</field>
|
<field name="name">account.use.model.create.entry.form</field>
|
||||||
<field name="model">account.use.model</field>
|
<field name="model">account.use.model</field>
|
||||||
|
|
Loading…
Reference in New Issue