[IMP] account_sequence:
*rename the field internal_sequence in internal_sequence_id
*improved the installation wizard to display the fields of the sequence to create (more user friendly)
*set the config wizard as "on_skip"
bzr revid: qdp-launchpad@tinyerp.com-20101126102830-9ppwdb3m205634jp
This commit is contained in:
@@ -46,7 +46,7 @@ class account_journal(osv.osv):
|
||||
_inherit = "account.journal"
|
||||
|
||||
_columns = {
|
||||
'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."),
|
||||
'internal_sequence_id': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."),
|
||||
}
|
||||
|
||||
account_journal()
|
||||
@@ -60,4 +60,4 @@ class account_move_line(osv.osv):
|
||||
|
||||
account_move_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="sequence_id" position="after">
|
||||
<field name="internal_sequence"/>
|
||||
<field name="internal_sequence_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -26,33 +26,57 @@ class account_sequence_installer(osv.osv_memory):
|
||||
_inherit = 'res.config.installer'
|
||||
|
||||
_columns = {
|
||||
'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used on Journals to maintain internal number for accounting entries."),
|
||||
'name': fields.char('Name',size=64, required=True),
|
||||
'prefix': fields.char('Prefix',size=64, help="Prefix value of the record for the sequence"),
|
||||
'suffix': fields.char('Suffix',size=64, help="Suffix value of the record for the sequence"),
|
||||
'number_next': fields.integer('Next Number', required=True, help="Next number of this sequence"),
|
||||
'number_increment': fields.integer('Increment Number', required=True, help="The next number of the sequence will be incremented by this number"),
|
||||
'padding' : fields.integer('Number padding', required=True, help="OpenERP will automatically adds some '0' on the left of the 'Next Number' to get the required padding size."),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'ir.sequence', context=c),
|
||||
'number_increment': 1,
|
||||
'number_next': 1,
|
||||
'padding' : 0,
|
||||
'name': 'Internal Sequence Journal',
|
||||
}
|
||||
|
||||
def _get_internal_sequence(self, cr, uid, context=None):
|
||||
result = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_sequence', 'internal_sequence_journal')
|
||||
return result and result[1] or False
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
jou_obj = self.pool.get('account.journal')
|
||||
obj_sequence = self.pool.get('ir.sequence')
|
||||
record = self.browse(cr, uid, ids)[0]
|
||||
record = self.browse(cr, uid, ids, context)[0]
|
||||
j_ids = []
|
||||
if record.company_id:
|
||||
company_id = record.company_id.id,
|
||||
search_criteria = [('company_id', '=', company_id)]
|
||||
else:
|
||||
company_id = False
|
||||
search_criteria = []
|
||||
vals = {
|
||||
'id': 'internal_sequence_journal',
|
||||
'code': 'account.journal',
|
||||
'name': record.name,
|
||||
'prefix': record.prefix,
|
||||
'suffix': record.suffix,
|
||||
'number_next': record.number_next,
|
||||
'number_increment': record.number_increment,
|
||||
'padding' : record.padding,
|
||||
'company_id': company_id,
|
||||
}
|
||||
|
||||
ir_seq = obj_sequence.create(cr, uid, vals, context)
|
||||
res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context)
|
||||
journal_ids = jou_obj.search(cr, uid, [], context=context)
|
||||
for journal in jou_obj.browse(cr, uid, journal_ids):
|
||||
if not journal.internal_sequence:
|
||||
journal_ids = jou_obj.search(cr, uid, search_criteria, context=context)
|
||||
for journal in jou_obj.browse(cr, uid, journal_ids, context):
|
||||
if not journal.internal_sequence_id:
|
||||
j_ids.append(journal.id)
|
||||
if j_ids:
|
||||
jou_obj.write(cr, uid, j_ids, {'internal_sequence': record.internal_sequence.id})
|
||||
jou_obj.write(cr, uid, j_ids, {'internal_sequence_id': ir_seq})
|
||||
return res
|
||||
|
||||
_defaults = {
|
||||
'internal_sequence': _get_internal_sequence
|
||||
}
|
||||
|
||||
account_sequence_installer()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -22,7 +22,13 @@
|
||||
<attribute name="string">You can enhance the Account Sequence Application by installing .</attribute>
|
||||
</xpath>
|
||||
<group colspan="8">
|
||||
<field name="internal_sequence"/>
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="prefix"/>
|
||||
<field name="suffix"/>
|
||||
<field name="number_next"/>
|
||||
<field name="number_increment"/>
|
||||
<field name="padding"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
<xpath expr="//button[@string='Install Modules']" position="attributes">
|
||||
<attribute name="string">Configure</attribute>
|
||||
@@ -44,7 +50,7 @@
|
||||
<record id="account_seq_installer_todo" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_account_seq_installer"/>
|
||||
<field name="sequence">3</field>
|
||||
<field name="restart">always</field>
|
||||
<field name="restart">onskip</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user