prototype of configuration wizard
bzr revid: hmo@tinyerp.com-9591a4aa840f7c7a4ecddde1adef198e27b5ddfa
This commit is contained in:
parent
24c3169bd7
commit
7318be91fe
|
@ -36,6 +36,7 @@ from tools.misc import currency
|
|||
import mx.DateTime
|
||||
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
|
||||
|
||||
|
||||
class account_payment_term(osv.osv):
|
||||
_name = "account.payment.term"
|
||||
_description = "Payment Term"
|
||||
|
@ -1541,3 +1542,70 @@ class account_subscription_line(osv.osv):
|
|||
account_subscription_line()
|
||||
|
||||
|
||||
class account_config_fiscalyear(osv.osv_memory):
|
||||
_name = 'account.config.fiscalyear'
|
||||
_columns = {
|
||||
'name':fields.char('Name', required=True,size=64),
|
||||
'code':fields.char('Code', required=True,size=64),
|
||||
'date1': fields.date('Start of period', required=True),
|
||||
'date2': fields.date('End of period', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'date1': lambda *a: time.strftime('%Y-01-01'),
|
||||
'date2': lambda *a: time.strftime('%Y-%m-%d'),
|
||||
}
|
||||
def action_create(self, cr, uid,ids, context=None):
|
||||
res=self.read(cr,uid,ids)[0]
|
||||
if 'date1' in res and 'date2' in res:
|
||||
res_obj = self.pool.get('account.fiscalyear')
|
||||
start_date=res['date1']
|
||||
end_date=res['date2']
|
||||
name=res['name']#DateTime.strptime(start_date, '%Y-%m-%d').strftime('%m.%Y') + '-' + DateTime.strptime(end_date, '%Y-%m-%d').strftime('%m.%Y')
|
||||
vals={
|
||||
'name':name,
|
||||
'code':name,
|
||||
'date_start':start_date,
|
||||
'date_stop':end_date,
|
||||
}
|
||||
new_id=res_obj.create(cr, uid, vals, context=context)
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'res_model': 'ir.module.module.configuration.wizard',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'new',
|
||||
|
||||
}
|
||||
|
||||
account_config_fiscalyear()
|
||||
|
||||
|
||||
class account_config_journal_bank_accounts(osv.osv_memory):
|
||||
_name='account.config.journal.bank.account'
|
||||
_columns = {
|
||||
'name':fields.char('Journal Name', size=64,required=True),
|
||||
'bank_account_id':fields.many2one('account.account', 'Bank Account', required=True, domain=[('type','=','cash')]),
|
||||
'view_id':fields.many2one('account.journal.view', 'Journal view', required=True),
|
||||
'sequence_id':fields.many2one('ir.sequence', 'Sequence', required=True),
|
||||
}
|
||||
def action_create(self, cr, uid, ids, context=None):
|
||||
res=self.read(cr,uid,ids)[0]
|
||||
res_obj = self.pool.get('account.journal')
|
||||
if 'name' in res and 'bank_account_id' in res and 'view_id' in res and 'sequence_id' in res:
|
||||
vals={
|
||||
'name':res['name'],
|
||||
'type':'cash',
|
||||
'view_id':res['view_id'],
|
||||
'default_credit_account_id':res['bank_account_id'],
|
||||
'default_debit_account_id':res['bank_account_id'],
|
||||
'sequence_id':res['sequence_id']
|
||||
}
|
||||
res_obj.create(cr, uid, vals, context=context)
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'res_model': 'ir.module.module.configuration.wizard',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'new',
|
||||
}
|
||||
|
||||
account_config_journal_bank_accounts()
|
||||
|
||||
|
|
|
@ -471,9 +471,9 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/General Accounts/"
|
||||
id="menu_action_account_type_form"
|
||||
<menuitem
|
||||
name="Financial Management/Configuration/General Accounts/"
|
||||
id="menu_action_account_type_form"
|
||||
groups="base.group_extended"
|
||||
action="action_account_type_form"/>
|
||||
<!--
|
||||
|
@ -1483,5 +1483,82 @@
|
|||
id="act_account_partner_account_move"/>
|
||||
|
||||
|
||||
|
||||
<!-- configuration wizard view -->
|
||||
|
||||
<record model="ir.ui.view" id="view_config_fiscalyear_form">
|
||||
<field name="name">Configure Fiscal Year</field>
|
||||
<field name="model">account.config.fiscalyear</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Configure Fiscal Year">
|
||||
<separator string="Configure Fiscal Year"/>
|
||||
<newline/>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<group colspan="4" col="4">
|
||||
<button special="cancel" string="Cancel" />
|
||||
<button name="action_create" type='object' string="Create" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_config_fiscalyear_form">
|
||||
<field name="name">Configure Fiscal Year</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.config.fiscalyear</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_config_journal_bank_account">
|
||||
<field name="name">Configure Journal of Bank account</field>
|
||||
<field name="model">account.config.journal.bank.account</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Configure Journal of Bank account">
|
||||
<separator string="Configure Journal of Bank account"/>
|
||||
<newline/>
|
||||
<field name="name"/>
|
||||
<field name="bank_account_id"/>
|
||||
<field name="view_id"/>
|
||||
<field name="sequence_id"/>
|
||||
<group colspan="4" col="4">
|
||||
<button special="cancel" string="Cancel" />
|
||||
<button name="action_create" type='object' string="Create"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_config_journal_bank_account">
|
||||
<field name="name">Configure Journal of Bank account</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.config.journal.bank.account</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- register configuration wizard -->
|
||||
|
||||
<record model="ir.module.module.configuration.step"
|
||||
id="config_fiscalyear">
|
||||
<field name="name">account.config.fiscalyear</field>
|
||||
<field name="action_id" ref="action_config_fiscalyear_form"/>
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.module.module.configuration.step"
|
||||
id="config_journal_bank_account">
|
||||
<field name="name">account.config.journal.bank.account</field>
|
||||
<field name="action_id" ref="action_config_journal_bank_account"/>
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
|
@ -12,5 +12,14 @@
|
|||
<field name="action_id" ref="action_wizard_setup"/>
|
||||
<field name="menu_id" ref="action_wizard_setup"/>
|
||||
</record>
|
||||
|
||||
|
||||
<!--<record model="ir.module.module.configuration.step"
|
||||
id="config_base_setup_menu">
|
||||
<field name="name">base_setup.base_setup.menu</field>
|
||||
<field name="action_id" ref=""/>
|
||||
<field name="sequence" eval="99999"/>
|
||||
<field name="state">open</field>
|
||||
</record>-->
|
||||
</data>
|
||||
</terp>
|
||||
|
|
|
@ -91,7 +91,7 @@ class sale_order(osv.osv):
|
|||
|
||||
def _amount_total(self, cr, uid, ids, field_name, arg, context):
|
||||
res = {}
|
||||
untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context)
|
||||
untax = self._amount_untaxed(cr, uid, ids, field_name, arg, context)
|
||||
tax = self._amount_tax(cr, uid, ids, field_name, arg, context)
|
||||
cur_obj=self.pool.get('res.currency')
|
||||
for id in ids:
|
||||
|
@ -242,8 +242,8 @@ class sale_order(osv.osv):
|
|||
def button_dummy(self, cr, uid, ids, context={}):
|
||||
return True
|
||||
|
||||
#FIXME: the method should return the list of invoices created (invoice_ids)
|
||||
# and not the id of the last invoice created (res). The problem is that we
|
||||
#FIXME: the method should return the list of invoices created (invoice_ids)
|
||||
# and not the id of the last invoice created (res). The problem is that we
|
||||
# cannot change it directly since the method is called by the sale order
|
||||
# workflow and I suppose it expects a single id...
|
||||
def _inv_get(self, cr, uid, order, context={}):
|
||||
|
@ -571,7 +571,7 @@ class sale_order_line(osv.osv):
|
|||
except:
|
||||
res[line.id] = 1
|
||||
return res
|
||||
|
||||
|
||||
def _get_1st_packaging(self, cr, uid, context={}):
|
||||
cr.execute('select id from product_packaging order by id asc limit 1')
|
||||
res = cr.fetchone()
|
||||
|
@ -833,3 +833,34 @@ class sale_order_line(osv.osv):
|
|||
return res
|
||||
|
||||
sale_order_line()
|
||||
|
||||
|
||||
|
||||
_policy_form = '''<?xml version="1.0"?>
|
||||
<form string="Select Bank Account">
|
||||
<field name="picking_policy" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
_policy_fields = {
|
||||
'picking_policy': {'string': 'Packing Policy', 'type': 'selection','selection': [('direct','Direct Delivery'),('one','All at once')],'required': True,}
|
||||
}
|
||||
class sale_config_picking_policy(osv.osv_memory):
|
||||
_name='sale.config.picking_policy'
|
||||
_columns = {
|
||||
'name':fields.char('Name', size=64),
|
||||
'picking_policy': fields.selection([('direct','Direct Delivery'),('one','All at once')], 'Packing Policy', required=True ),
|
||||
}
|
||||
_defaults={
|
||||
'picking_policy': lambda *a: 'direct',
|
||||
}
|
||||
def set_default(self, cr, uid, ids, context=None):
|
||||
if 'name' in context:
|
||||
ir_values_obj = self.pool.get('ir.values')
|
||||
ir_values_obj.set(cr,uid,'default',False,'picking_policy',['sale.order'],context['picking_policy'])
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'res_model': 'ir.module.module.configuration.wizard',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target':'new',
|
||||
}
|
||||
sale_config_picking_policy()
|
||||
|
|
|
@ -447,5 +447,43 @@
|
|||
domain="[('product_id','=',active_id)]"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- configartion view -->
|
||||
|
||||
<record model="ir.ui.view" id="view_config_picking_policy">
|
||||
<field name="name">Configure Picking Policy for Sale Order </field>
|
||||
<field name="model">sale.config.picking_policy</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Configure Picking Policy for Sale Order">
|
||||
<separator string="Configure Picking Policy for Sale Order"/>
|
||||
<newline/>
|
||||
<field name="picking_policy"/>
|
||||
<group colspan="4" col="4">
|
||||
<button special="cancel" string="Cancel" />
|
||||
<button name="set_default" type='object' string="Set Default"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_config_picking_policy">
|
||||
<field name="name">Configure Picking Policy for Sale Order</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sale.config.picking_policy</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- register configuration wizard -->
|
||||
<record model="ir.module.module.configuration.step"
|
||||
id="config_wizard_step_sale_picking_policy">
|
||||
<field name="name">sale.config.picking_policy</field>
|
||||
<field name="action_id" ref="action_config_picking_policy"/>
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
|
|
Loading…
Reference in New Issue