diff --git a/addons/account/account.py b/addons/account/account.py
index dbff7730fc9..e7304065b8d 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -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):
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 6b793707cb4..31b6c73d179 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -60,6 +60,9 @@
+
+
+
account.period.form
@@ -74,6 +77,7 @@
+
diff --git a/addons/account/report/account_balance.py b/addons/account/report/account_balance.py
index 044315c538c..1f3440c1357 100755
--- a/addons/account/report/account_balance.py
+++ b/addons/account/report/account_balance.py
@@ -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= '"+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)
diff --git a/addons/account/wizard/wizard_account_balance_report.py b/addons/account/wizard/wizard_account_balance_report.py
index 3677f51f050..af23f0581ca 100644
--- a/addons/account/wizard/wizard_account_balance_report.py
+++ b/addons/account/wizard/wizard_account_balance_report.py
@@ -30,37 +30,38 @@ import wizard
import pooler
import time
-report_type = '''
-'''
-
-
-dates_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 = '''
'''
-
-
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 = '''
@@ -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')
-
-
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 94c4ccbf00c..d202dd8ece9 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -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 = {
diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml
index 0e672a62112..44347f9fdc2 100644
--- a/addons/sale/sale_view.xml
+++ b/addons/sale/sale_view.xml
@@ -360,7 +360,8 @@
-
+
+
@@ -368,6 +369,7 @@
+
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 5db7c283517..5789aa27465 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -264,15 +264,15 @@
-
-
@@ -794,7 +794,7 @@
-
+
@@ -1302,31 +1302,51 @@
form
tree,form
-
+
-
+
-
-
-
+
+
+
+
+
tree_but_open
stock.location
Products
-
+
-
-
+
+
tree_but_open
stock.location
Open Products
-
-
-
-
-
+
+
+
+
+