-Added Use model wizard.
-Added 'legend' field on account.model -Added 'description' field and name_get method on account.tax." bzr revid: jvo-20080715100458-0io7neh1n1grgrt3
This commit is contained in:
parent
996fd9fb47
commit
57d0ebb5e6
|
@ -1086,8 +1086,19 @@ class account_tax(osv.osv):
|
|||
'ref_tax_sign': fields.float('Tax Code Sign', help="Usualy 1 or -1."),
|
||||
'include_base_amount': fields.boolean('Include in base amount', help="Indicate if the amount of tax must be included in the base amount for the computation of the next taxes"),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
'description': fields.char('Description', size=128, required=True),
|
||||
}
|
||||
|
||||
def name_get(self, cr, uid, ids, context={}):
|
||||
if not len(ids):
|
||||
return []
|
||||
reads = self.read(cr, uid, ids, ['description'], context)
|
||||
res = []
|
||||
for record in reads:
|
||||
name = record['description']
|
||||
res.append((record['id'],name ))
|
||||
return res
|
||||
|
||||
def _default_company(self, cr, uid, context={}):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
|
@ -1367,7 +1378,13 @@ class account_model(osv.osv):
|
|||
'ref': fields.char('Ref', size=64),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'lines_id': fields.one2many('account.model.line', 'model_id', 'Model Entries'),
|
||||
'legend' :fields.text('Legend',readonly=True,size=100),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'legend':lambda *a:'''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) : Current Date\n\ne.g. My model on %(date)s''',
|
||||
}
|
||||
|
||||
def generate(self, cr, uid, ids, datas={}, context={}):
|
||||
move_ids = []
|
||||
for model in self.browse(cr, uid, ids, context):
|
||||
|
|
|
@ -559,7 +559,8 @@
|
|||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Account Tax">
|
||||
<field name="name"/>
|
||||
<!--<field name="name"/>-->
|
||||
<field name="description" string="Name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -573,6 +574,7 @@
|
|||
<page string="Tax Definition">
|
||||
<field name="name" select="1"/>
|
||||
<field name="company_id"/>
|
||||
<field name="description" select="1"/>
|
||||
<field name="tax_group" select="1"/>
|
||||
<field name="active" select="2"/>
|
||||
<field name="type"/>
|
||||
|
@ -1125,6 +1127,8 @@
|
|||
<field name="ref" select="1"/>
|
||||
<field name="journal_id" select="1"/>
|
||||
<field colspan="4" name="lines_id" widget="one2many_list"/>
|
||||
<separator string="Legend" colspan="4"/>
|
||||
<field name="legend" colspan="4" nolabel="1"/>
|
||||
<group col="1" colspan="4">
|
||||
<button name="generate" string="Create entries" type="object"/>
|
||||
</group>
|
||||
|
|
|
@ -9,71 +9,71 @@
|
|||
<menuitem id="menu_finance_entries" name="Entries" parent="account.menu_finance" sequence="2"/>
|
||||
|
||||
<wizard id="wizard_invoice_refund" model="account.invoice" name="account.invoice.refund" string="Refund invoice"/>
|
||||
|
||||
|
||||
<wizard id="wizard_invoice_pay" model="account.invoice" name="account.invoice.pay" string="Pay invoice"/>
|
||||
|
||||
|
||||
<wizard id="wizard_budget_spread" menu="False" model="account.budget.post" name="account.budget.spread" string="Spread amount"/>
|
||||
|
||||
|
||||
<!-- close year, period, journal -->
|
||||
<wizard id="wizard_fiscalyear_close" menu="False" model="account.fiscalyear" name="account.fiscalyear.close" string="Close a Fiscal Year"/>
|
||||
<menuitem id="menu_finance" name="Financial Management"/><menuitem action="wizard_fiscalyear_close" id="menu_wizard_fy_close" parent="menu_account_end_year_treatments" sequence="11" type="wizard"/>
|
||||
|
||||
|
||||
<wizard id="wizard_open_closed_fiscalyear" menu="False" model="account.fiscalyear" name="account.open_closed_fiscalyear" string="Open a Closed Fiscal Year"/>
|
||||
<menuitem action="wizard_open_closed_fiscalyear" id="menu_wizard_open_closed_fy" parent="account.menu_account_end_year_treatments" sequence="12" type="wizard"/>
|
||||
|
||||
|
||||
<wizard id="wizard_period_close" model="account.period" name="account.period.close" string="Close Period"/>
|
||||
|
||||
|
||||
<!-- automatic reconcile -->
|
||||
<wizard id="wizard_automatic_reconcile" menu="False" model="account.account" name="account.automatic.reconcile" string="Automatic reconciliation"/>
|
||||
<menuitem id="next_id_20" name="Reconciliation" parent="menu_finance_periodical_processing"/><menuitem action="wizard_automatic_reconcile" id="menu_automatic_reconcile" parent="next_id_20" type="wizard"/>
|
||||
|
||||
|
||||
<!-- manual reconcile -->
|
||||
<wizard id="wizard_reconcile" model="account.move.line" name="account.move.line.reconcile" string="Reconcile Entries"/>
|
||||
|
||||
|
||||
<wizard id="wizard_reconcile_unreconcile" model="account.move.reconcile" name="account.reconcile.unreconcile" string="Unreconcile Entries"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wizard id="wizard_reconcile_select" menu="False" model="account.move.line" name="account.move.line.reconcile.select" string="Reconcile entries"/>
|
||||
<menuitem action="wizard_reconcile_select" id="menu_reconcile_select" parent="account.next_id_20" type="wizard"/>
|
||||
|
||||
|
||||
<!-- unreconcile -->
|
||||
<wizard id="wizard_unreconcile" model="account.move.line" name="account.move.line.unreconcile" string="Unreconcile Entries"/>
|
||||
|
||||
|
||||
<wizard id="wizard_unreconcile_select" menu="False" model="account.move.line" name="account.move.line.unreconcile.select" string="Unreconcile entries"/>
|
||||
<menuitem action="wizard_unreconcile_select" id="menu_unreconcile_select" parent="account.next_id_20" type="wizard"/>
|
||||
|
||||
|
||||
<!-- subscriptions -->
|
||||
<wizard id="wizard_generate_subscription" menu="False" model="account.subscription" name="account.subscription.generate" string="Create subscription entries"/>
|
||||
<menuitem action="wizard_generate_subscription" id="menu_generate_subscription" parent="account.menu_finance_periodical_processing" type="wizard"/>
|
||||
|
||||
|
||||
<!-- Aged partner balance -->
|
||||
<wizard id="wizard_aged_trial_balance" menu="False" model="res.partner" name="account.aged.trial.balance" string="Aged partner balance"/>
|
||||
<menuitem id="next_id_22" name="Partner Accounts" parent="menu_finance_reporting"/><menuitem action="wizard_aged_trial_balance" id="menu_aged_trial_balance" parent="next_id_22" type="wizard"/>
|
||||
|
||||
|
||||
<!-- report-related wizards -->
|
||||
<wizard id="wizard_partner_balance_report" menu="False" model="res.partner" name="account.partner.balance.report" string="Partner balance"/>
|
||||
<menuitem action="wizard_partner_balance_report" id="menu_partner_balance" parent="account.next_id_22" type="wizard"/>
|
||||
|
||||
|
||||
<wizard id="wizard_third_party_ledger" menu="False" model="res.partner" name="account.third_party_ledger.report" string="Partner ledger"/>
|
||||
<menuitem action="wizard_third_party_ledger" id="menu_third_party_ledger" parent="account.next_id_22" type="wizard"/>
|
||||
|
||||
|
||||
<wizard id="wizard_budget_report" keyword="client_print_multi" model="account.budget.post" name="account.budget.report" string="Budget"/>
|
||||
<wizard id="wizard_balance_report" keyword="client_print_multi" model="account.account" name="account.account.balance.report" string="Account balance"/>
|
||||
<wizard id="wizard_general_ledger_report" keyword="client_print_multi" model="account.account" name="account.general.ledger.report" string="General ledger"/>
|
||||
|
||||
|
||||
<wizard id="wizard_invoice_state_confirm" keyword="client_action_multi" model="account.invoice" multi="True" name="account.invoice.state.confirm" string="Confirm draft invoices"/>
|
||||
<wizard id="wizard_invoice_state_cancel" keyword="client_action_multi" model="account.invoice" multi="True" name="account.invoice.state.cancel" string="Cancel selected invoices"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<wizard id="wizard_account_duplicate" keyword="tree_but_action" model="account.account" name="account.wizard.account.duplicate" string="Duplicate"/>
|
||||
|
||||
|
||||
<!-- account.move validate -->
|
||||
<wizard id="wizard_validate_account_moves" menu="False" model="account.move" name="account.move.validate" string="Validate Account Moves"/>
|
||||
<menuitem action="wizard_validate_account_moves" id="menu_validate_account_moves" parent="account.menu_finance_periodical_processing" type="wizard"/>
|
||||
|
||||
|
||||
<wizard id="wizard_validate_account_moves_line" menu="True" model="account.move.line" name="account.move_line.validate" string="Validate Account Moves"/>
|
||||
|
||||
<!-- Use Models -->
|
||||
|
||||
<!-- Use Models -->
|
||||
<wizard string="Use Models" model="account.model" name="account_use_models" menu="False" id="wizard_account_use_model"/>
|
||||
<menuitem action="wizard_account_use_model" type="wizard" parent="account.menu_finance_periodical_processing" id="menu_account_use_model"/>
|
||||
|
||||
|
|
|
@ -60,3 +60,4 @@ import wizard_account_chart
|
|||
import wizard_move_line_select
|
||||
|
||||
import wizard_validate_account_move
|
||||
import wizard_use_model
|
|
@ -0,0 +1,108 @@
|
|||
import wizard
|
||||
import time
|
||||
import datetime
|
||||
import pooler
|
||||
|
||||
model_form = """<?xml version="1.0"?>
|
||||
<form string="Select Message">
|
||||
<field name="model"/>
|
||||
</form>"""
|
||||
|
||||
model_fields = {
|
||||
'model': {'string': 'Account Model', 'type': 'many2many', 'relation': 'account.model', 'required': True},
|
||||
}
|
||||
|
||||
form = """<?xml version="1.0"?>
|
||||
<form string="Use Model">
|
||||
<label string="Move Lines Created."/>
|
||||
</form>
|
||||
"""
|
||||
fields = {
|
||||
}
|
||||
def _create_entries(self, cr, uid, data, context):
|
||||
pool_obj = pooler.get_pool(cr.dbname)
|
||||
model_ids = data['form']['model'][0][2]
|
||||
data_model = pool_obj.get('account.model').browse(cr,uid,model_ids)
|
||||
move_ids = []
|
||||
for model in data_model:
|
||||
|
||||
period_id = pool_obj.get('account.period').find(cr,uid, context=context)
|
||||
if not period_id:
|
||||
raise wizard.except_wizard('No period found !', 'Unable to find a valid period !')
|
||||
period_id = period_id[0]
|
||||
name = model.name
|
||||
if model.journal_id.sequence_id:
|
||||
name_seq = pool_obj.get('ir.sequence').get_id(cr, uid, model.journal_id.sequence_id.id)
|
||||
|
||||
if name.find("%(year)s") != -1:
|
||||
name=name.decode('utf-8').replace("%(year)s",str(time.strftime("%Y")))
|
||||
|
||||
if name.find("%(month)s") != -1:
|
||||
name=name.decode('utf-8').replace("%(month)s",str(time.strftime("%B")))
|
||||
|
||||
if name.find("%(date)s") != -1:
|
||||
name=name.decode('utf-8').replace("%(date)s",str(time.strftime("%Y-%m-%d")))
|
||||
|
||||
move_id = pool_obj.get('account.move').create(cr, uid, {
|
||||
'name': str(name_seq) + " : " +name,
|
||||
'ref': model.ref,
|
||||
'period_id': period_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
})
|
||||
move_ids.append(move_id)
|
||||
for line in model.lines_id:
|
||||
val = {
|
||||
'move_id': move_id,
|
||||
'journal_id': model.journal_id.id,
|
||||
'period_id': period_id
|
||||
}
|
||||
val.update({
|
||||
'name': line.name,
|
||||
'quantity': line.quantity,
|
||||
'debit': line.debit,
|
||||
'credit': line.credit,
|
||||
'account_id': line.account_id.id,
|
||||
'move_id': move_id,
|
||||
'ref': line.ref,
|
||||
'partner_id': line.partner_id.id,
|
||||
'date': time.strftime('%Y-%m-%d'),
|
||||
'date_maturity': time.strftime('%Y-%m-%d')
|
||||
})
|
||||
c = context.copy()
|
||||
c.update({'journal_id': model.journal_id.id,'period_id': period_id})
|
||||
id_line = pool_obj.get('account.move.line').create(cr, uid, val, context=c)
|
||||
data['form']['move_ids']=move_ids
|
||||
return data['form']
|
||||
|
||||
class use_model(wizard.interface):
|
||||
|
||||
def _open_moves(self, cr, uid, data, context):
|
||||
pool_obj = pooler.get_pool(cr.dbname)
|
||||
model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_move_form')])
|
||||
resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str,data['form']['move_ids']))+"])]",
|
||||
'name': 'Entries',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.move',
|
||||
'views': [(False,'tree'),(resource_id,'form')],
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':model_form, 'fields':model_fields, 'state':[('end','Cancel'),('create','Create Entries')]},
|
||||
},
|
||||
'create': {
|
||||
'actions': [_create_entries],
|
||||
'result': {'type': 'form','arch':form, 'fields':fields, 'state':[('end','Ok'),('open_move','Open')]},
|
||||
},
|
||||
'open_move': {
|
||||
'actions': [],
|
||||
'result': {'type':'action', 'action':_open_moves, 'state':'end'}
|
||||
}
|
||||
}
|
||||
|
||||
use_model("account_use_models")
|
Loading…
Reference in New Issue