bzr revid: fp@tinyerp.com-20081024130217-wxv6mv2600gy46f0
This commit is contained in:
Fabien Pinckaers 2008-10-24 15:02:17 +02:00
commit fecfe88f88
7 changed files with 169 additions and 80 deletions

View File

@ -562,6 +562,17 @@ class account_period(osv.osv):
if not ids:
raise osv.except_osv(_('Error !'), _('No period defined for this date !\nPlease create a fiscal year.'))
return ids
def action_draft(self, cr, uid, ids, *args):
users_roles = self.pool.get('res.users').browse(cr, uid, uid).roles_id
for role in users_roles:
if role.name=='Period':
mode = 'draft'
for id in ids:
cr.execute('update account_journal_period set state=%s where period_id=%d', (mode, id))
cr.execute('update account_period set state=%s where id=%d', (mode, id))
return True
account_period()
class account_journal_period(osv.osv):

View File

@ -60,6 +60,9 @@
<!--
Period
-->
<record id="res_role_period" model="res.roles">
<field eval="&quot;&quot;&quot;Period&quot;&quot;&quot;" name="name"/>
</record>
<record id="view_account_period_form" model="ir.ui.view">
<field name="name">account.period.form</field>
@ -74,6 +77,7 @@
<field name="fiscalyear_id"/>
<separator colspan="4" string="States"/>
<field name="state" select="1"/>
<button name="action_draft" states="done" string="Set to Draft" type="object"/>
</form>
</field>
</record>

View File

@ -77,6 +77,47 @@ class account_balance(report_sxw.rml_parse):
result+=r[0]+", "
return str(result and result[:-1]) or ''
def transform_both_into_date_array(self,data):
if not data['periods'][0][2] :
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
else:
periods_id = data['periods'][0][2]
date_array = []
for period_id in periods_id:
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
period_start_date = date_array[0]
date_start_date = data['date_from']
period_stop_date = date_array[-1]
date_stop_date = data['date_to']
if period_start_date<date_start_date:
start_date = period_start_date
else :
start_date = date_start_date
if date_stop_date<period_stop_date:
stop_date = period_stop_date
else :
stop_date = date_stop_date
final_date_array = []
final_date_array = final_date_array + self.date_range(start_date, stop_date)
self.date_lst = final_date_array
self.date_lst.sort()
def transform_none_into_date_array(self,data):
sql = "SELECT min(date) as start_date from account_move_line"
self.cr.execute(sql)
start_date = self.cr.fetchone()[0]
sql = "SELECT max(date) as start_date from account_move_line"
self.cr.execute(sql)
stop_date = self.cr.fetchone()[0]
array= []
array = array + self.date_range(start_date, stop_date)
self.date_lst = array
self.date_lst.sort()
def lines(self, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
@ -90,14 +131,18 @@ class account_balance(report_sxw.rml_parse):
res={}
result_acc=[]
ctx = self.context.copy()
if form.has_key('fiscalyear'):
if form['state']=='byperiod' :
self.transform_period_into_date_array(form)
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
else:
elif form['state']== 'bydate':
self.transform_date_into_date_array(form)
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
elif form['state'] == 'all' :
self.transform_both_into_date_array(form)
elif form['state'] == 'none' :
self.transform_none_into_date_array(form)
# ctx['date_from'] = form['date_from']
# ctx['date_to'] = form['date_to']
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
def cmp_code(x, y):
@ -169,9 +214,12 @@ class account_balance(report_sxw.rml_parse):
"LEFT JOIN account_journal j " \
"ON (l.journal_id = j.id) " \
"WHERE l.account_id = '"+str(ids)+"' " \
"AND l.date IN (" + self.date_lst_string + ") " \
"AND l.date >= '"+self.date_lst[0]+"' " \
"AND l.date <= '"+self.date_lst[-1]+"' " \
"ORDER BY l.id")
res = self.cr.dictfetchall()
sum = 0.0
for r in res:
sum = r['debit1'] - r['credit1']
@ -227,5 +275,5 @@ class account_balance(report_sxw.rml_parse):
def _sum_debit(self):
return self.sum_debit
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=False)
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=False)

View File

@ -30,37 +30,38 @@ import wizard
import pooler
import time
report_type = '''<?xml version="1.0"?>
<form string="Select Report Type">
</form>'''
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="date_from" colspan="4"/>
<field name="date_to" colspan="4"/>
<field name="display_account" colspan="4"/>
</form>'''
dates_fields = {
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
'display_account':{'string':"Filter on Accounts",'type':'selection','selection':[('bal_mouvement','With Entries'),('bal_all','All Accounts'),('bal_solde','With Balance Different Than 0')]}
}
period_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
<field name="display_account" colspan="4"/>
<field name="company_id"/>
<field name="display_account" required = "True"/>
<newline/>
<field name="fiscalyear" attrs="{'readonly':[('state','=','bydate')]}"/>
<label colspan="2" string="(Keep empty for all open fiscal years)" align="0.0"/>
<newline/>
<separator string="Filters" colspan="4"/>
<field name="state" required="True"/>
<newline/>
<group attrs="{'invisible':[('state','=','byperiod'),('state','=','none')]}" colspan="4">
<separator string="Date Filter" colspan="4"/>
<field name="date_from"/>
<field name="date_to"/>
</group>
<group attrs="{'invisible':[('state','=','bydate'),('state','=','none')]}" colspan="4">
<separator string="Filter on Periods" colspan="4"/>
<field name="periods" colspan="4" nolabel="1"/>
</group>
</form>'''
period_fields = {
'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True},
'state':{
'string':"Date/Period Filter",
'type':'selection',
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
'default': lambda *a:'bydate'
},
'fiscalyear': {
'string':'Fiscal year',
'type':'many2one',
@ -68,7 +69,9 @@ period_fields = {
'help':'Keep empty for all open fiscal year'
},
'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'},
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]}
'display_account':{'string':"Display accounts ",'type':'selection','selection':[('bal_mouvement','With movements'),('bal_all','All'),('bal_solde','With balance is not equal to 0')]},
'date_from': {'string':"Start date",'type':'date','required':True ,'default': lambda *a: time.strftime('%Y-01-01')},
'date_to': {'string':"End date",'type':'date','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
}
account_form = '''<?xml version="1.0"?>
@ -80,9 +83,14 @@ account_fields = {
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True ,'domain':[('parent_id','=',False)]},
}
class wizard_report(wizard.interface):
def _get_defaults(self, cr, uid, data, context):
user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context)
if user.company_id:
company_id = user.company_id.id
else:
company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
data['form']['company_id'] = company_id
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
@ -90,17 +98,28 @@ class wizard_report(wizard.interface):
data['form']['display_account']='bal_all'
return data['form']
def _get_defaults_fordate(self, cr, uid, data, context):
data['form']['display_account']='bal_all'
def _check_state(self, cr, uid, data, context):
my_ids=data['ids']
if data['model']!='account.account':
my_ids=[data['form']['Account_list']]
child_ids = pooler.get_pool(cr.dbname).get('account.account').search(cr, uid,[('parent_id', 'child_of',my_ids )])
for child in child_ids :
child_account = pooler.get_pool(cr.dbname).get('account.account').browse(cr, uid, child)
res = pooler.get_pool(cr.dbname).get('account.move.line').search(cr, uid,[('account_id','=',child_account.id)])
if not len(res):
raise wizard.except_wizard('UserError',"Make sure the account you select has children accounts.")
if data['form']['state'] == 'bydate':
self._check_date(cr, uid, data, context)
data['form']['fiscalyear'] = 0
else :
data['form']['fiscalyear'] = 1
return data['form']
def _check_path(self, cr, uid, data, context):
if data['model'] == 'account.account':
return 'checktype'
return 'checktype'
else:
return 'account_selection'
return 'account_selection'
def _check_date(self, cr, uid, data, context):
sql = """
@ -112,7 +131,6 @@ class wizard_report(wizard.interface):
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
else:
return 'report'
else:
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
@ -127,27 +145,12 @@ class wizard_report(wizard.interface):
'result': {'type':'form', 'arch':account_form,'fields':account_fields, 'state':[('end','Cancel'),('checktype','Print')]}
},
'checktype': {
'actions': [],
'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]}
},
'with_period': {
'actions': [_get_defaults],
'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]}
},
'with_date': {
'actions': [_get_defaults_fordate],
'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]}
},
'checkdate': {
'actions': [],
'result': {'type':'choice','next_state':_check_date}
},
'report': {
'actions': [],
'actions': [_check_state],
'result': {'type':'print', 'report':'account.account.balance', 'state':'end'}
}
}
wizard_report('account.account.balance.report')

View File

@ -671,6 +671,7 @@ class sale_order_line(osv.osv):
'notes': fields.text('Notes'),
'th_weight' : fields.float('Weight'),
'state': fields.selection([('draft','Draft'),('confirmed','Confirmed'),('done','Done'),('cancel','Canceled')], 'Status', required=True, readonly=True),
'order_partner_id': fields.related('order_id', 'partner_id', type='many2one', relation='res.partner', string='Customer')
}
_order = 'sequence, id'
_defaults = {

View File

@ -360,7 +360,8 @@
<field name="arch" type="xml">
<tree string="Sales order lines">
<field name="order_id"/>
<field colspan="4" name="name"/>
<field name="order_partner_id"/>
<field name="name"/>
<field name="product_id"/>
<field name="product_uom_qty" string="Qty"/>
<field name="product_uom" string="UoM"/>
@ -368,6 +369,7 @@
<field name="price_unit"/>
<field name="price_net"/>
<field name="price_subtotal"/>
<field name="state"/>
</tree>
</field>
</record>

View File

@ -264,15 +264,15 @@
</field>
</record>
<wizard
id="action_lot2"
model="stock.production.lot"
name="stock.traceability.lot.amont"
<wizard
id="action_lot2"
model="stock.production.lot"
name="stock.traceability.lot.amont"
string="Downstream traceability"/>
<wizard
id="action_lot4"
model="stock.production.lot"
name="stock.traceability.lot.aval"
<wizard
id="action_lot4"
model="stock.production.lot"
name="stock.traceability.lot.aval"
string="Upstream traceability"/>
<wizard id="action2" model="stock.tracking" name="stock.traceability.amont" string="Upstream traceability"/>
@ -794,7 +794,7 @@
<field name="address_id" select="2"/>
<field name="name" select="1" readonly="1"/>
<field name="min_date" select="2"/>
<field name="invoice_state"/>
<field name="invoice_state"/>
<field name="backorder_id" select="2" readonly="1"/>
</group>
<notebook colspan="4">
@ -1302,31 +1302,51 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_incoterms_tree" id="menu_action_incoterms_tree" parent="menu_stock_configuration"/>
<menuitem action="action_incoterms_tree" id="menu_action_incoterms_tree" parent="menu_stock_configuration"/>
<act_window context="{'location': active_id}" domain="[('type','&lt;&gt;','service')]" id="act_product_location_open" name="Products" res_model="product.product" src_model="stock.location"/>
<act_window
context="{'location': active_id}"
domain="[('type','&lt;&gt;','service')]"
id="act_product_location_open"
name="Products"
res_model="product.product"
src_model="stock.location"/>
<act_window context="{'location': active_id}" domain="[('product_id','=',active_id)]" id="act_product_stock_move_open" name="Stock Moves" res_model="stock.move" src_model="product.product"/>
<record id="ir_act_product_location_open" model="ir.values">
<act_window
context="{'location': active_id}"
domain="[('product_id','=',active_id)]"
id="act_product_stock_move_open"
name="All Stock Moves"
res_model="stock.move"
src_model="product.product"/>
<act_window
context="{'location': active_id}"
domain="[('product_id','=',active_id),('state','in',('waiting','confirmed','assigned'))]"
id="act_product_stock_move_futur_open"
name="Futur Stock Moves"
res_model="stock.move"
src_model="product.product"/>
<record id="ir_act_product_location_open" model="ir.values">
<field name="key2">tree_but_open</field>
<field name="model">stock.location</field>
<field name="name">Products</field>
<field eval="'ir.actions.act_window,%d'%act_product_location_open" name="value"/>
<field eval="True" name="object"/>
</record>    
</record>    
<record id="ir_act_product_location_open" model="ir.values">
<record id="ir_act_product_location_open" model="ir.values">
<field name="key2">tree_but_open</field>
<field name="model">stock.location</field>
<field name="name">Open Products</field>
<field eval="'ir.actions.wizard,%d'%ref('location_product')" name="value"/>
<field eval="True" name="object"/>
</record>  
     
<field eval="True" name="object"/>
</record>  
     
</data>
</openerp>