Ported all bugs from trunk to stable

bzr revid: hda@hda-20090413124313-x9gdobzpxf1lkfxl
This commit is contained in:
husen daudi 2009-04-13 18:13:13 +05:30
commit ea2efc1506
82 changed files with 1905 additions and 837 deletions

View File

@ -654,7 +654,8 @@ class account_journal_period(osv.osv):
'period_id': fields.many2one('account.period', 'Period', required=True, ondelete="cascade"),
'icon': fields.function(_icon_get, method=True, string='Icon', type='string'),
'active': fields.boolean('Active', required=True),
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True)
'state': fields.selection([('draft','Draft'), ('printed','Printed'), ('done','Done')], 'Status', required=True, readonly=True),
'fiscalyear_id': fields.related('period_id', 'fiscalyear_id', string='Fiscal Year', type='many2one', relation='account.fiscalyear'),
}
def _check(self, cr, uid, ids, context={}):
@ -1550,7 +1551,7 @@ class account_model_line(osv.osv):
'ref': fields.char('Ref.', size=16),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency."),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency."),
'currency_id': fields.many2one('res.currency', 'Currency'),
'partner_id': fields.many2one('res.partner', 'Partner Ref.'),
@ -2285,7 +2286,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
for tax in position.tax_ids:
vals_tax = {
'tax_src_id' : tax_template_ref[tax.tax_src_id.id],
'tax_dest_id' : tax_template_ref[tax.tax_dest_id.id],
'tax_dest_id' : tax.tax_dest_id and tax_template_ref[tax.tax_dest_id.id] or False,
'position_id' : new_fp,
}
obj_tax_fp.create(cr, uid, vals_tax)

View File

@ -84,7 +84,7 @@ class account_analytic_line(osv.osv):
a = prod.categ_id.property_account_expense_categ.id
if not a:
raise osv.except_osv(_('Error !'),
_('There is no expense account define ' \
_('There is no expense account defined ' \
'for this product: "%s" (id:%d)') % \
(prod.name, prod.id,))
amount = unit_amount * uom_obj._compute_price(cr, uid,

View File

@ -170,8 +170,8 @@
<field name="tax_line" nolabel="1">
<tree editable="bottom" string="Taxes">
<field name="name"/>
<field name="base" on_change="base_change(base)" readonly="1"/>
<field name="amount" on_change="amount_change(amount)"/>
<field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
<field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
<field invisible="True" name="base_amount"/>
<field invisible="True" name="tax_amount"/>
@ -257,8 +257,8 @@
<field name="tax_line" nolabel="1">
<tree editable="bottom" string="Taxes">
<field name="name"/>
<field name="base" on_change="base_change(base)" readonly="1"/>
<field name="amount" on_change="amount_change(amount)"/>
<field name="base" on_change="base_change(base,parent.currency_id,parent.company_id,parent.date_invoice)" readonly="1"/>
<field name="amount" on_change="amount_change(amount,parent.currency_id,parent.company_id,parent.date_invoice)"/>
<field invisible="True" name="base_amount"/>
<field invisible="True" name="tax_amount"/>
</tree>

View File

@ -40,16 +40,22 @@ class account_move_line(osv.osv):
else:
fiscalyear_clause = '%s' % context['fiscalyear']
state=context.get('state',False)
where_move_state=''
where_move_state = ''
where_move_lines_by_date = ''
if context.get('date_from', False) and context.get('date_to', False):
where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
if state:
if state.lower() not in ['all']:
where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
if context.get('periods', False):
ids = ','.join([str(x) for x in context['periods']])
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date)
else:
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date)
def default_get(self, cr, uid, fields, context={}):
data = self._default_get(cr, uid, fields, context)
@ -342,8 +348,8 @@ class account_move_line(osv.osv):
'statement_id': fields.many2one('account.bank.statement', 'Statement', help="The bank statement used for bank reconciliation", select=1),
'reconcile_id': fields.many2one('account.move.reconcile', 'Reconcile', readonly=True, ondelete='set null', select=2),
'reconcile_partial_id': fields.many2one('account.move.reconcile', 'Partial Reconcile', readonly=True, ondelete='set null', select=2),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optionnal other currency if it is a multi-currency entry."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optionnal other currency if it is a multi-currency entry."),
'amount_currency': fields.float('Amount Currency', help="The amount expressed in an optional other currency if it is a multi-currency entry."),
'currency_id': fields.many2one('res.currency', 'Currency', help="The optional other currency if it is a multi-currency entry."),
'period_id': fields.many2one('account.period', 'Period', required=True, select=2),
'journal_id': fields.many2one('account.journal', 'Journal', required=True, select=1),

View File

@ -1038,7 +1038,8 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Journals">
<field icon="icon" name="period_id"/>
<field icon="icon" name="fiscalyear_id"/>
<field name="period_id"/>
<field name="journal_id"/>
<field name="state"/>
</tree>

View File

@ -357,11 +357,16 @@ class account_invoice(osv.osv):
pt_obj= self.pool.get('account.payment.term')
if not date_invoice :
date_invoice = time.strftime('%Y-%m-%d')
pterm_list= pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
pterm_list = pt_obj.compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
if pterm_list:
pterm_list = [line[0] for line in pterm_list]
pterm_list.sort()
res= {'value':{'date_due': pterm_list[-1]}}
else:
raise osv.except_osv(_('Data Insufficient !'), _('The Payment Term of Supplier does not have Payment Term Lines(Computation) defined !'))
return res
def onchange_invoice_line(self, cr, uid, ids, lines):
@ -491,7 +496,6 @@ class account_invoice(osv.osv):
company_currency = inv.company_id.currency_id.id
# create the analytical lines
line_ids = self.read(cr, uid, [inv.id], ['invoice_line'])[0]['invoice_line']
ils = self.pool.get('account.invoice.line').read(cr, uid, line_ids)
# one move line per invoice line
iml = self._get_analytic_lines(cr, uid, inv.id)
# check if taxes are all computed
@ -897,17 +901,18 @@ account_invoice()
class account_invoice_line(osv.osv):
def _amount_line(self, cr, uid, ids, prop, unknow_none,unknow_dict):
res = {}
cur_obj=self.pool.get('res.currency')
for line in self.browse(cr, uid, ids):
if line.invoice_id:
res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0)
cur = line.invoice_id.currency_id
res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
else:
res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2)
return res
res = {}
cur_obj=self.pool.get('res.currency')
for line in self.browse(cr, uid, ids):
if line.invoice_id:
res[line.id] = line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0)
cur = line.invoice_id.currency_id
res[line.id] = cur_obj.round(cr, uid, cur, res[line.id])
else:
res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2)
return res
def _price_unit_default(self, cr, uid, context=None):
if context is None:
context = {}
@ -1098,9 +1103,23 @@ class account_invoice_tax(osv.osv):
'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."),
'tax_amount': fields.float('Tax Code Amount', digits=(16,2)),
}
def base_change(self, cr, uid, ids, base):
def base_change(self, cr, uid, ids, base,currency_id=False,company_id=False,date_invoice=False):
cur_obj = self.pool.get('res.currency')
company_obj = self.pool.get('res.company')
company_currency=False
if company_id:
company_currency=company_obj.browse(cr,uid,company_id).id
if currency_id and company_currency:
base=cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
return {'value': {'base_amount':base}}
def amount_change(self, cr, uid, ids, amount):
def amount_change(self, cr, uid, ids, amount,currency_id=False,company_id=False,date_invoice=False):
cur_obj = self.pool.get('res.currency')
company_obj = self.pool.get('res.company')
company_currency=False
if company_id:
company_currency=company_obj.browse(cr,uid,company_id).id
if currency_id and company_currency:
amount=cur_obj.compute(cr, uid, currency_id, company_currency, amount, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False)
return {'value': {'tax_amount':amount}}
_order = 'sequence'
_defaults = {

View File

@ -98,8 +98,8 @@
<td><para style="tbl_content"></para></td>
<td><para style="tbl_content">[[ move.name ]]</para></td>
<td><para style="tbl_content">[[ move.account_id.code ]] - [[ move.account_id.name ]]</para></td>
<td><para style="tbl_content"></para></td>
<td><para style="tbl_content_right">[[ formatLang(move.debit-move.credit) ]]</para></td>
<td><para style="tbl_content"></para></td>
</tr>
</blockTable>

View File

@ -60,55 +60,26 @@ class account_balance(report_sxw.rml_parse):
if form.has_key('periods') and form['periods'][0][2]:
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
res=self.cr.fetchall()
res = self.cr.fetchall()
len_res = len(res)
for r in res:
if (r == res[res.__len__()-1]):
if (r == res[len_res-1]):
result+=r[0]+". "
else:
result+=r[0]+", "
else:
fy_obj = self.pool.get('account.fiscalyear').browse(self.cr,self.uid,form['fiscalyear'])
res = fy_obj.period_ids
len_res = len(res)
for r in res:
if r == res[len_res-1]:
result+=r.name+". "
else:
result+=r.name+", "
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
@ -122,51 +93,59 @@ class account_balance(report_sxw.rml_parse):
res={}
result_acc=[]
ctx = self.context.copy()
ctx['fiscalyear'] = form['fiscalyear']
if form['state']=='byperiod' :
self.transform_period_into_date_array(form)
ctx['fiscalyear'] = form['fiscalyear']
ctx['periods'] = form['periods'][0][2]
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)
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
def cmp_code(x, y):
return cmp(x.code, y.code)
accounts.sort(cmp_code)
ctx['periods'] = form['periods'][0][2]
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):
# return cmp(x.code, y.code)
# accounts.sort(cmp_code)
child_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, ids, ctx)
if child_ids:
ids = child_ids
accounts = self.pool.get('account.account').read(self.cr, self.uid, ids,['type','code','name','debit','credit','balance','parent_id'], ctx)
for account in accounts:
if account.id in done:
if account['id'] in done:
continue
done[account.id] = 1
done[account['id']] = 1
res = {
'id' : account.id,
'type' : account.type,
'code': account.code,
'name': account.name,
'id' : account['id'],
'type' : account['type'],
'code': account['code'],
'name': account['name'],
'level': level,
'debit': account.debit,
'credit': account.credit,
'balance': account.balance,
'leef': not bool(account.child_id),
'debit': account['debit'],
'credit': account['credit'],
'balance': account['balance'],
# 'leef': not bool(account['child_id']),
'parent_id':account['parent_id'],
'bal_type':'',
}
self.sum_debit += account.debit
self.sum_credit += account.credit
if account.child_id:
def _check_rec(account):
if not account.child_id:
return bool(account.credit or account.debit)
for c in account.child_id:
if not _check_rec(c) or _check_rec(c):
return True
return False
if not _check_rec(account) :
continue
self.sum_debit += account['debit']
self.sum_credit += account['credit']
# if account.child_id:
# def _check_rec(account):
# if not account.child_id:
# return bool(account.credit or account.debit)
# for c in account.child_id:
# if not _check_rec(c) or _check_rec(c):
# return True
# return False
# if not _check_rec(account) :
# continue
if account['parent_id']:
# acc = self.pool.get('account.account').read(self.cr, self.uid, [ account['parent_id'][0] ] ,['name'], ctx)
for r in result_acc:
if r['id'] == account['parent_id'][0]:
res['level'] = r['level'] + 1
break
if form['display_account'] == 'bal_mouvement':
if res['credit'] > 0 or res['debit'] > 0 or res['balance'] > 0 :
result_acc.append(res)
@ -175,51 +154,18 @@ class account_balance(report_sxw.rml_parse):
result_acc.append(res)
else:
result_acc.append(res)
if account.child_id:
acc_id = [acc.id for acc in account.child_id]
lst_string = ''
lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\''
self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string))
a_id = self.cr.fetchall()
a_id.sort()
ids2 = [x[1] for x in a_id]
result_acc += self.lines(form, ids2, done, level+1)
# if account.child_id:
# acc_id = [acc.id for acc in account.child_id]
# lst_string = ''
# lst_string = '\'' + '\',\''.join(map(str,acc_id)) + '\''
# self.cr.execute("select code,id from account_account where id IN (%s)"%(lst_string))
# a_id = self.cr.fetchall()
# a_id.sort()
# ids2 = [x[1] for x in a_id]
#
# result_acc += self.lines(form, ids2, done, level+1)
return result_acc
def date_range(self,start,end):
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))
full_str_date = []
#
r = (end+datetime.timedelta(days=1)-start).days
#
date_array = [start+datetime.timedelta(days=i) for i in range(r)]
for date in date_array:
full_str_date.append(str(date))
return full_str_date
#
def transform_period_into_date_array(self,form):
## Get All Period Date
if not form['periods'][0][2] :
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',form['fiscalyear'])])
else:
periods_id = form['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)
self.date_lst = date_array
self.date_lst.sort()
def transform_date_into_date_array(self,form):
return_array = self.date_range(form['date_from'],form['date_to'])
self.date_lst = return_array
self.date_lst.sort()
def _sum_credit(self):
return self.sum_credit

View File

@ -61,7 +61,7 @@ class aged_trial_report(rml_parse.rml_parse):
context={'fiscalyear': form['fiscalyear']})
self.cr.execute("SELECT DISTINCT res_partner.id AS id, " \
"res_partner.name AS name " \
"FROM res_partner,account_move_line AS line, account_account,account_move_reconcile AS recon " \
"FROM res_partner,account_move_line AS line, account_account " \
"WHERE (line.account_id=account_account.id) " \
"AND ((reconcile_id IS NULL) " \
"OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s ))) " \

View File

@ -41,7 +41,7 @@
<blockTableStyle id="tbl_content">
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1"/>
<blockValign value="TOP"/>
</blockTableStyle>
@ -90,7 +90,7 @@
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<para>[[ repeatIn(objects, 'a') ]]</para>
<blockTable colWidths="66.0,124.0,70.0,40.0,80.0,59.0,52.0,54.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="date">Date</para></td>
@ -102,10 +102,11 @@
<td><para style="P4">Crebit</para></td>
<td><para style="P9">Balance</para></td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
</blockTable>
<section>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<blockTable colWidths="66.0,124.0,70.0,40.0,80.0,59.0,52.0,54.0" style="tbl_content">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td>
<blockTable colWidths="280.0,100.0,52.5,52.5,52.5" style="Table5">
<tr>
@ -115,28 +116,30 @@
<td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u>[[formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
</tr>
<tr>
<td>[[ repeatIn(lines(o, data['form']), 'line') ]]
<blockTable colWidths="54.0,123.0,70.0,40.0,80.0,59.0,52.0,54.0" style="tbl_content">
<tr>
<td><para style="P3">[[ formatLang(line['date'],date=True) ]]</para></td>
<td><para style="P3">[[ line['partner'] or '']]</para></td>
<td><para style="P3">[[ line['ref'] or '']]</para></td>
<td><para style="P3">[[ line['move'] or '']]</para></td>
<td><para style="P3">[[ line['name'] or '' ]]</para></td>
<td><para style="P4">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['progress']) ]]</para></td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</blockTable>
</td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
</tr>
<tr>
<td><para style="P3">[[ repeatIn(lines(o, data['form']), 'line') ]] <font>[[ formatLang(line['date'],date=True) ]]</font></para></td>
<td><para style="P3">[[ line['partner'] or '']]</para></td>
<td><para style="P3">[[ line['ref'] or '']]</para></td>
<td><para style="P3">[[ line['move'] or '']]</para></td>
<td><para style="P3">[[ line['name'] or '' ]]</para></td>
<td><para style="P4">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['progress']) ]]</para></td>
</tr>
</blockTable>
</section>
<blockTable colWidths="72.0,93.0,66.0,40.0,100.0,50.0,50.0,50.0,40.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
@ -150,10 +153,11 @@
<td><para style="P4">Balance</para></td>
<td><para style="P4">Currency</para></td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
</blockTable>
<section>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<blockTable colWidths="72.0,93.0,66.0,40.0,100.0,50.0,50.0,50.0,40.0" style="tbl_content">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td>
<blockTable colWidths="264.00,100.0,50.0,50.0,49.0,40.00" style="Table5">
<tr>
@ -164,29 +168,30 @@
<td><para style="P9b"><u>[[formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u> [[ formatLang(sum_currency_amount_account(a, data['form'])) ]]</u></para></td>
</tr>
<tr>
<td>[[ repeatIn(lines(o, data['form']), 'line') ]]
<blockTable colWidths="59.0,93.0,66.0,40.0,100.0,50.0,50.0,50.0,40.0" style="tbl_content">
<tr>
<td><para style="P3">[[ formatLang(line['date'],date=True) ]]</para></td>
<td><para style="P3">[[ line['partner'] or '' ]]</para></td>
<td><para style="P3">[[ line['ref'] or '']]</para></td>
<td><para style="P3">[[ line['move'] or '' ]]</para></td>
<td><para style="P3">[[ line['name'] or '' ]]</para></td>
<td><para style="P4">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['progress']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['amount_currency'] or 0.00) ]] [[ line['currency_code'] or '']]</para></td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</blockTable>
</td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
</tr>
<tr>
<td><para style="P3">[[ repeatIn(lines(o, data['form']), 'line') ]] <font>[[ formatLang(line['date'],date=True) ]]</font></para></td>
<td><para style="P3">[[ line['partner'] or '' ]]</para></td>
<td><para style="P3">[[ line['ref'] or '']]</para></td>
<td><para style="P3">[[ line['move'] or '' ]]</para></td>
<td><para style="P3">[[ line['name'] or '' ]]</para></td>
<td><para style="P4">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['progress']) ]]</para></td>
<td><para style="P4">[[ formatLang(line['amount_currency'] or 0.00) ]] [[ line['currency_code'] or '']]</para></td>
</tr>
</blockTable>
</section>
</story>

View File

@ -2,7 +2,7 @@
<document filename="test.pdf">
<template pageSize="(1120.0,770.0)" title="Test" author="Martin Simon" allowSplitting="20" >
<pageTemplate id="first">
<frame id="first" x1="22.0" y1="35.0" width="1080" height="680"/>
<frame id="first" x1="22.0" y1="31.0" width="1080" height="680"/>
<pageGraphics>
<!--logo-->
<!--<fill color="darkblue"/>-->
@ -34,28 +34,19 @@
</pageTemplate>
</template>
<stylesheet>
<blockTableStyle id="tbl_header">
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<blockValign value="TOP"/>
</blockTableStyle>
<blockTableStyle id="tbl_content">
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,-1"/>
<blockValign value="TOP"/>
<blockAlignment value="RIGHT" start="2,1" stop="-1,-1"/>
</blockTableStyle>
<blockTableStyle id="Table5">
<blockAlignment value="LEFT"/>
<lineStyle kind="LINEBELOW" colorName="#777777" start="0,0" stop="0,0"/>
<blockValign value="TOP"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
@ -91,63 +82,11 @@
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<blockTable colWidths="66.0,35.0,150.0, 90.0,60.0,335.0,50.0,69.0,72.0,64.0,58.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<para>[[ repeatIn(objects, 'a') ]]</para>
<blockTable colWidths="66.0,35.0,150.0, 90.0,60.0,335.0,50.0,69.0,72.0,64.0,58.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td><para style="P12"><font color="white"> </font></para><para style="date">Date</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">JNRL</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Partner</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Ref</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Mvt</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P3">Entry Label</para></td>
<td><para style="P12"><font color="white"> </font> </para><para style="P3">Counterpart</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Debit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Credit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Balance</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Currency</para></td>
</tr>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<td>
<blockTable colWidths="404.0,375.0,69.0,72.0,64.0,59.00" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_debit_account(o, data['form'])) ]]</u></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_credit_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u>[[ formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u> [[ formatLang(sum_currency_amount_account(o, data['form'])) ]]</u></para></td>
</tr>
<tr>
<td> [[ repeatIn(lines(o, data['form']), 'line') ]]
<blockTable colWidths="55.0,35.0,150.0, 90.0,60.0,333.0,50.0,69.0,72.0,64.0,58.0" style="tbl_content" >
<tr>
<td><para style="P2_content">[[ formatLang(line['date'],date=True) ]]</para></td>
<td><para style="P2_content">[[ line['code'] ]]</para></td>
<td><para style="P2_content">[[ line['partner'] ]]</para></td>
<td><para style="P2_content">[[ line['ref'] ]]</para></td>
<td><para style="P2_content">[[ line['move'] ]]</para></td>
<td><para style="P3_content">[[ line['name'] ]]</para></td>
<td><para style="P3_content">[[ strip_name(line['line_corresp'],55) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['progress']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['amount_currency'] or 0.00)]] [[ line['currency_code'] ]]</para></td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<blockTable colWidths="66.0,35.0,166.0,90.0,60.0,378.0,50.0,69.0,72.0,64.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="P12"><font color="white"> </font></para><para style="date">Date</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">JNRL</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Partner</para></td>
@ -158,43 +97,112 @@
<td><para style="P12"><font color="white"> </font></para><para style="P4">Debit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Credit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Balance</para></td>
</tr>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Currency</para></td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<blockTable colWidths="66.0,35.0,150.0, 90.0,60.0,335.0,50.0,69.0,72.0,64.0,58.0" style="tbl_content">[[ data['form']['amount_currency'] == True or removeParentNode('blockTable') ]]
<tr>
<td>
<blockTable colWidths="404.0,375.0,69.0,72.0,64.0,59.00" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_debit_account(o, data['form'])) ]]</u></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_credit_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u>[[ formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
<td><para style="P9b"><u> [[ formatLang(sum_currency_amount_account(o, data['form'])) ]]</u></para></td>
</tr>
</blockTable>
</td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
</tr>
<tr>
<td><para style="P2_content">[[ repeatIn(lines(o, data['form']), 'line') ]]<font> [[ formatLang(line['date'],date=True) ]]</font></para></td>
<td><para style="P2_content">[[ line['code'] ]]</para></td>
<td><para style="P2_content">[[ line['partner'] ]]</para></td>
<td><para style="P2_content">[[ line['ref'] ]]</para></td>
<td><para style="P2_content">[[ line['move'] ]]</para></td>
<td><para style="P3_content">[[ line['name'] ]]</para></td>
<td><para style="P3_content">[[ strip_name(line['line_corresp'],15) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['progress']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['amount_currency'] or 0.00)]] [[ line['currency_code'] ]]</para></td>
</tr>
</blockTable>
</section>
<blockTable colWidths="66.0,35.0,166.0,90.0,60.0,378.0,50.0,69.0,72.0,64.0" style="tbl_header" repeatRows="1">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td><para style="P12"><font color="white"> </font></para><para style="date">Date</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">JNRL</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Partner</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Ref</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P2">Mvt</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P3">Entry Label</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P3">Counterpart</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Debit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Credit</para></td>
<td><para style="P12"><font color="white"> </font></para><para style="P4">Balance</para></td>
</tr>
</blockTable>
<section>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<tr>
<para>[[ repeatIn(objects, 'a') ]]</para>
<para>[[ repeatIn(get_children_accounts(a,data['form']), 'o') ]]</para>
<td>
<blockTable colWidths="405.0,435.0,69.0,72.0,64.0" style="Table5">
<tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_debit_account(o, data['form']))]]</u></para></td>
<td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o, data['form']))]]</u></para></td>
<td><para style="P9b"><u>[[formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
</tr>
<tr>
<td> [[ repeatIn(lines(o, data['form']), 'line') ]]
<blockTable colWidths="55.0,35.0,166.0,90.0,60.0,378.0,50.0,69.0,72.0,64.0" style="tbl_content">
<blockTable colWidths="66.0,35.0,166.0,90.0,60.0,378.0,50.0,69.0,72.0,64.0" style="tbl_content">[[ data['form']['amount_currency'] == False or removeParentNode('blockTable') ]]
<tr>
<td>
<blockTable colWidths="405.0,435.0,69.0,72.0,64.0" style="Table5">
<tr>
<td><para style="P2_content">[[ formatLang(line['date'],date=True) ]]</para></td>
<td><para style="P2_content">[[ line['code'] ]]</para></td>
<td><para style="P2_content">[[ line['partner'] ]]</para></td>
<td><para style="P2_content">[[ line['ref'] ]]</para></td>
<td><para style="P2_content">[[ line['move'] ]]</para></td>
<td><para style="P3_content">[[ line['name'] ]]</para></td>
<td><para style="P3_content">[[ strip_name(line['line_corresp'],55) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['progress']) ]]</para></td>
</tr>
<td><para style="Standard">[[ o.code ]] [[ o.name ]]</para></td>
<td><para style="Standard"></para></td>
<td alignment="right"><para style="P9b"><u>[[ formatLang(sum_debit_account(o, data['form']))]]</u></para></td>
<td alignment="right"><para style="P9b"><u>[[formatLang(sum_credit_account(o, data['form']))]]</u></para></td>
<td><para style="P9b"><u>[[formatLang(sum_solde_account(o, data['form'])) ]]</u></para></td>
</tr>
</blockTable>
</td>
</td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
<td><para style="Standard"></para></td>
</tr>
</blockTable>
</td>
</tr>
</blockTable>
<tr>
<td><para style="P2_content">[[ repeatIn(lines(o, data['form']), 'line') ]]<font>[[ formatLang(line['date'],date=True) ]]</font></para></td>
<td><para style="P2_content">[[ line['code'] ]]</para></td>
<td><para style="P2_content">[[ line['partner'] ]]</para></td>
<td><para style="P2_content">[[ line['ref'] ]]</para></td>
<td><para style="P2_content">[[ line['move'] ]]</para></td>
<td><para style="P3_content">[[ line['name'] ]]</para></td>
<td><para style="P3_content">[[ strip_name(line['line_corresp'],15) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['debit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['credit']) ]]</para></td>
<td><para style="P4_content">[[ formatLang(line['progress']) ]]</para></td>
</tr>
</blockTable>
</section>
</story>
</document>

153
addons/account/report/partner_balance.py Normal file → Executable file
View File

@ -169,18 +169,12 @@ class partner_balance(report_sxw.rml_parse):
self.transform_both_into_date_array(data)
# if data['form']['fiscalyear']:
# print"data['form']['fiscalyear']=True"
# self.transform_period_into_date_array(data)
# else:
# print"data['form']['fiscalyear']=False"
# self.transform_date_into_date_array(data)
##
self.date_lst_string =''
if self.date_lst:
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
## Compute Code
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
#
@ -207,43 +201,6 @@ class partner_balance(report_sxw.rml_parse):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
full_account = []
result_tmp = 0.0
#
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT p.ref, p.name,l.account_id,ac.name as account_name,ac.code as code , sum(debit) as debit, sum(credit) as credit, " \
"CASE WHEN sum(debit) > sum(credit) " \
"THEN sum(debit) - sum(credit) " \
"ELSE 0 " \
"END AS sdebit, " \
"CASE WHEN sum(debit) < sum(credit) " \
"THEN sum(credit) - sum(debit) " \
"ELSE 0 " \
"END AS scredit, " \
"(SELECT sum(debit-credit) " \
"FROM account_move_line l " \
"WHERE partner_id = p.id " \
"AND date < %s " \
"AND blocked = TRUE AND l.reconcile_id IS NULL " \
") AS enlitige " \
"FROM account_move_line l LEFT JOIN res_partner p ON (l.partner_id=p.id) " \
"JOIN account_account ac ON (l.account_id = ac.id)" \
"WHERE ac.type IN " + self.ACCOUNT_TYPE + " " \
"AND l.date < %s AND l.reconcile_id IS NULL " \
"GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \
"ORDER BY l.account_id,p.name",
(self.date_lst[0],self.date_lst[0]))
res = self.cr.dictfetchall()
for r in res:
full_account.append(r)
#
#
#
if self.date_lst_string:
self.cr.execute(
"SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \
@ -317,23 +274,6 @@ class partner_balance(report_sxw.rml_parse):
#
else:
if cleanarray[i]['account_id'] <> cleanarray[i-1]['account_id']:
##
# new_tot = {}
# new_tot['ref'] = 'Total'
# new_tot['name'] = cleanarray[i-1]['account_name']
# new_tot['code'] = cleanarray[i-1]['code']
#
# new_tot['debit'] = tot_debit
# new_tot['credit'] = tot_credit
# new_tot['scredit'] = tot_scredit
# new_tot['sdebit'] = tot_sdebit
# new_tot['enlitige'] = tot_enlitige
# new_tot['balance'] = float(tot_sdebit) - float(tot_scredit)
# new_tot['type'] = 3
# ##
# completearray.append(new_tot)
new_header['debit'] = tot_debit
new_header['credit'] = tot_credit
@ -415,19 +355,6 @@ class partner_balance(report_sxw.rml_parse):
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(debit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id IN (" + self.account_ids + ") " \
"AND l.reconcile_id IS NULL " \
"AND date < %s ",
(self.date_lst[0],))
result_tmp = float(self.cr.fetchone()[0] or 0.0)
#
#
temp_res = 0.0
if self.date_lst_string:
self.cr.execute(
@ -446,19 +373,6 @@ class partner_balance(report_sxw.rml_parse):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(credit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id IN (" + self.account_ids + ") " \
"AND l.reconcile_id IS NULL " \
"AND l.date < %s " ,
(self.date_lst[0],))
result_tmp = float(self.cr.fetchone()[0] or 0.0)
#
#
temp_res = 0.0
if self.date_lst_string:
self.cr.execute(
@ -476,21 +390,6 @@ class partner_balance(report_sxw.rml_parse):
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT sum(debit-credit) " \
"FROM account_move_line AS l " \
"WHERE l.account_id IN (" + self.account_ids + ") " \
"AND l.reconcile_id IS NULL " \
"AND l.date < %s " \
"AND l.blocked=TRUE " ,
(self.date_lst[0],))
result_tmp = float(self.cr.fetchone()[0] or 0.0)
#
#
temp_res = 0.0
if self.date_lst_string:
self.cr.execute(
@ -509,28 +408,6 @@ class partner_balance(report_sxw.rml_parse):
return 0.0
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT CASE WHEN sum(debit) > sum(credit) " \
"THEN sum(debit) - sum(credit) " \
"ELSE 0 " \
"END " \
"FROM account_move_line AS l " \
"WHERE l.account_id IN (" + self.account_ids + ") " \
"AND l.date < %s " \
"AND l.reconcile_id IS NULL " \
"GROUP BY l.partner_id",
(self.date_lst[0],))
if self.cr.fetchone() != None:
result_tmp = float(self.cr.fetchone()[0])
else:
result_tmp = 0.0
#
#
a = 0.0
if self.date_lst_string:
self.cr.execute(
@ -558,27 +435,6 @@ class partner_balance(report_sxw.rml_parse):
account_move_line_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
result_tmp = 0.0
#
#
if self.date_lst and data['form']['soldeinit'] :
self.cr.execute(
"SELECT CASE WHEN sum(debit) < sum(credit) " \
"THEN sum(credit) - sum(debit) " \
"ELSE 0 " \
"END " \
"FROM account_move_line AS l " \
"WHERE l.account_id IN (" + self.account_ids + ") " \
"AND l.date <= %s " \
"AND l.reconcile_id IS NULL " \
"GROUP BY l.partner_id",
(self.date_lst[0],))
if self.cr.fetchone() != None:
result_tmp = float(self.cr.fetchone()[0]) or 0.0
else:
result_tmp = 0.0
#
#
a = 0.0
if self.date_lst_string:
self.cr.execute(
@ -591,10 +447,10 @@ class partner_balance(report_sxw.rml_parse):
"AND l.date IN (" + self.date_lst_string + ") " \
"GROUP BY l.partner_id")
a = self.cr.fetchone()[0] or 0.0
if self.cr.fetchone() != None:
result_tmp = result_tmp + (a or 0.0)
else:
result_tmp = 0.0
@ -617,4 +473,5 @@ class partner_balance(report_sxw.rml_parse):
report_sxw.report_sxw('report.account.partner.balance', 'res.partner',
'account/report/partner_balance.rml',parser=partner_balance,
header=False)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -87,10 +87,10 @@ class wizard_report(wizard.interface):
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')
# periods_obj=pooler.get_pool(cr.dbname).get('account.period')
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
data['form']['fiscalyear'] = False
# data['form']['periods'] = periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
# data['form']['fiscalyear'] = False
data['form']['display_account']='bal_all'
return data['form']
@ -98,9 +98,9 @@ class wizard_report(wizard.interface):
if data['form']['state'] == 'bydate':
self._check_date(cr, uid, data, context)
data['form']['fiscalyear'] = 0
else :
data['form']['fiscalyear'] = 1
# data['form']['fiscalyear'] = 0
# else :
# data['form']['fiscalyear'] = 1
return data['form']
def _check_path(self, cr, uid, data, context):

View File

@ -178,7 +178,8 @@ def _data_save(self, cr, uid, data, context):
'WHERE account_id = %s ' \
'AND ' + query_line + ' ' \
'ORDER BY id ' \
'LIMIT %s OFFSET %s', (account.id,fy_id, limit, offset))
'LIMIT %s OFFSET %s', (account.id, limit, offset))
result = cr.dictfetchall()
if not result:
break

View File

@ -69,35 +69,31 @@ class wiz_refund(wizard.interface):
if form['period'] :
period = form['period']
else:
period = inv.period_id.id
period = inv.period_id and inv.period_id.id or False
if form['date'] :
date = form['date']
if not form['period'] :
try :
#we try in multy company mode
cr.execute("select name from ir_model_fields where model='account.period' and name='company_id'")
result_query = cr.fetchone()
if result_query:
#in multi company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop and company_id = %s limit 1 """%(
form['date'],
pool.get('res.users').browse(cr,uid,uid).company_id.id
)
)
except :
#we try in mono company mode
))
else:
#in mono company mode
cr.execute("""SELECT id
from account_period where date('%s')
between date_start AND date_stop limit 1 """%(
form['date'],
)
)
))
res = cr.fetchone()
if res:
period = res[0]
else:
date = inv.date_invoice
@ -105,6 +101,10 @@ class wiz_refund(wizard.interface):
description = form['description']
else:
description = inv.name
if not period:
raise wizard.except_wizard(_('Data Insufficient !'), _('No Period found on Invoice!'))
refund_id = pool.get('account.invoice').refund(cr, uid, [inv.id],date, period, description)
refund = pool.get('account.invoice').browse(cr, uid, refund_id[0])
# we compute due date

View File

@ -60,7 +60,7 @@ class wizard_crossovered_analytic(wizard.interface):
break
if flag:
raise wizard.except_wizard(_('User Error'),_("There are no Analytic lines related to Account '%s'" % name))
raise wizard.except_wizard(_('User Error'),_('There are no Analytic lines related to Account %s' % name))
return {}
states = {

View File

@ -163,6 +163,7 @@ class crossovered_budget_lines(osv.osv):
acc_ids = [x.id for x in line.general_budget_id.account_ids]
if not acc_ids:
raise osv.except_osv(_('Error!'),_("The General Budget '%s' has no Accounts!") % str(line.general_budget_id.name))
date_to = line.date_to
date_from = line.date_from
if context.has_key('wizard_date_from'):

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>

View File

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<document filename="test.pdf">
<template pageSize="(612.0,792.0)" title="Test" author="Martin Simon" allowSplitting="20">
<template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
<pageTemplate id="first">
<frame id="first" x1="57.0" y1="57.0" width="498" height="678"/>
<frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
</pageTemplate>
</template>
<stylesheet>

View File

@ -37,7 +37,13 @@
It will generate a PDF with all the letters according the the
different levels of recall defined. You can define different policies
for different companies.""",
for different companies.
Note that if you want to change the followup level for a given partner/account entry, you can do it in the menu:
Financial_Management/Reporting/Follow-Ups/All Receivable Entries
""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['account'],

View File

@ -50,7 +50,7 @@ class report_rappel(report_sxw.rml_parse):
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
adr = res_partner.address_get(self.cr, self.uid, [partner.id], [type])[type]
return res_partner_address.read(self.cr, self.uid, [adr])
return adr and res_partner_address.read(self.cr, self.uid, [adr]) or False
def _lines_get(self, partner):
moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line')
@ -70,7 +70,7 @@ class report_rappel(report_sxw.rml_parse):
li_delay.sort(reverse=True)
text = ""
a = {}
partner_line = pooler.get_pool(self.cr.dbname).get('account.move.line').search(self.cr, self.uid, [('partner_id','=',partner.id)])
partner_line = pooler.get_pool(self.cr.dbname).get('account.move.line').search(self.cr, self.uid, [('partner_id','=',partner.id),('reconcile_id','=',False)])
partner_delay = []
context={}
context.update({'lang': partner.lang})

View File

@ -20,7 +20,7 @@
<field name="report_type" />
<newline/>
<separator string="Accounts" colspan="4"/>
<field name="account_id" colspan="4" nolabel="1" domain="[('type','=','view')]"/>
<field name="account_id" colspan="4" nolabel="1"/>
</page><page string="Notes">
<field name="note" nolabel="1" colspan="4"/>
</page>

View File

@ -58,9 +58,11 @@ class account_report_bs(report_sxw.rml_parse):
_total +=self.line_total(report,ctx)
return _total
def lines(self, form, ids={}, done=None, level=1):
if not ids:
ids = self.ids
def lines(self, form, ids={}, done=None, level=1, object=False):
if object:
ids = [object.id]
elif not ids:
ids = self.ids
if not ids:
return []
if not done:
@ -76,7 +78,7 @@ class account_report_bs(report_sxw.rml_parse):
def cmp_code(x, y):
return cmp(x.code, y.code)
report_objs.sort(cmp_code)
for report_obj in report_objs:
if report_obj.id in done:
continue
@ -87,12 +89,12 @@ class account_report_bs(report_sxw.rml_parse):
color_font = report_obj.color_font.name
if report_obj.color_back:
color_back = report_obj.color_back.name
res = {
'code': report_obj.code,
'name': report_obj.name,
'level': level,
'balance': self.line_total(report_obj.id,ctx),
'parent_id':False,
'color_font':color_font,
'color_back':color_back,
'font_style' : report_obj.font_style
@ -101,35 +103,55 @@ class account_report_bs(report_sxw.rml_parse):
report_type = report_obj.report_type
if report_type != 'only_obj':
account_ids = self.pool.get('account.report.bs').read(self.cr,self.uid,[report_obj.id],['account_id'])[0]['account_id']
for account_id in account_ids:
res1 = self.check_child_id(account_id,level,ctx,report_type)
result += res1
if report_type == 'acc_with_child':
acc_ids = self.pool.get('account.account')._get_children_and_consol(self.cr, self.uid, account_ids )
account_ids = acc_ids
account_objs = self.pool.get('account.account').browse(self.cr,self.uid,account_ids,ctx)
for acc_obj in account_objs:
res1={}
res1 = {
'code': acc_obj.code,
'name': acc_obj.name,
'level': level+1,
'balance': acc_obj.balance,
'parent_id':acc_obj.parent_id,
'color_font' : 'black',
'color_back' :'white',
'font_style' : 'Helvetica',
}
if acc_obj.parent_id:
for r in result:
if r['name']== acc_obj.parent_id.name:
res1['level'] = r['level'] + 1
break
result.append(res1)
#res1 = self.check_child_id(account_id,level,ctx,report_type)
#result += res1
if report_obj.child_id:
ids2 = [(x.code,x.id) for x in report_obj.child_id]
ids2.sort()
result += self.lines(form, [x[1] for x in ids2], done, level+1)
result += self.lines(form,[x[1] for x in ids2], done, level+1,object=False)
return result
def check_child_id(self,account_id,level,ctx,report_type):
account = self.pool.get('account.account').browse(self.cr,self.uid,[account_id],ctx)[0]
result = []
res = {
'code': account.code,
'name': account.name,
'level': level+1,
'balance': account.balance,
'color_font' : 'black',
'color_back' :'pink',
'font_style' : 'Helvetica-BoldOblique',
}
result.append(res)
if report_type != 'with_account':
acc_child_id = self.pool.get('account.account').search(self.cr,self.uid,[('parent_id','=',[account_id]),('type','=','view')])
for child_id in acc_child_id :
result += self.check_child_id(child_id,level+1,ctx,report_type)
return result
# def check_child_id(self,account_id,level,ctx,report_type):
# account = self.pool.get('account.account').browse(self.cr,self.uid,[account_id],ctx)[0]
# result = []
# res = {
# 'code': account.code,
# 'name': account.name,
# 'level': level+1,
# 'balance': account.balance,
# 'color_font' : 'black',
# 'color_back' :'white',
# 'font_style' : 'Helvetica',
# }
# result.append(res)
# if report_type != 'with_account':
# acc_child_id = self.pool.get('account.account').search(self.cr,self.uid,[('parent_id','=',[account_id]),('type','=','view')])
# for child_id in acc_child_id :
# result += self.check_child_id(child_id,level+1,ctx,report_type)
# return result
@ -138,6 +160,8 @@ class account_report_bs(report_sxw.rml_parse):
#
# def _sum_debit(self):
# return self.sum_debit
report_sxw.report_sxw('report.account.report.bs', 'account.report.bs', 'addons/account_reporting/report/account_report_bs.rml', parser=account_report_bs)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -13,9 +13,6 @@
<blockTableStyle id="Table1">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<blockBackground colorName="#e6e6e6" start="0,0" stop="0,0"/>
<blockBackground colorName="#e6e6e6" start="1,0" stop="1,0"/>
<blockBackground colorName="#e6e6e6" start="2,0" stop="2,0"/>
</blockTableStyle>
<blockTableStyle id="Table2">
<blockAlignment value="LEFT"/>
@ -24,41 +21,52 @@
<blockTableStyle id="Table7">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,2" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#000000" start="0,1" stop="-1,1"/>
</blockTableStyle>
<blockTableStyle id="Table4">
<blockAlignment value="LEFT"/>
<blockValign value="TOP"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,2" stop="-1,-1"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,0" stop="-1,0"/>
<lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,1" stop="-1,1"/>
</blockTableStyle>
<initialize>
<paraStyle name="all" alignment="justify"/>
</initialize>
<paraStyle name="P1" fontName="Times-Roman" fontSize="15.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Times-Roman" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P8" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Times-Roman" fontSize="8.0" leading="10"/>
<paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Times-Roman" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Times-Roman"/>
<paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Times-Roman" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Times-Roman"/>
<paraStyle name="P1" fontName="Helvetica" fontSize="15.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P2" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P3" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P4" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P5" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P6" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P7" fontName="Helvetica" fontSize="6.0" leading="8" alignment="LEFT"/>
<paraStyle name="P8" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT"/>
<paraStyle name="P9" fontName="Helvetica" fontSize="8.0" leading="10"/>
<paraStyle name="P10" fontName="Helvetica" fontSize="9.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P11" fontName="Helvetica" fontSize="8.0" leading="10" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P12a" fontName="Helvetica" fontSize="12.0" leading="14" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P13" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P14" fontName="Helvetica" fontSize="12.0" leading="14" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P15" fontName="Helvetica" fontSize="20.0" leading="25" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P16" fontName="Helvetica" fontSize="10.0" leading="13" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P17" fontName="Helvetica" fontSize="9.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P18" fontName="Helvetica" fontSize="9.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P19" fontName="Helvetica" fontSize="12.0" leading="14" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="P20" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Standard" fontName="Helvetica"/>
<paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
<paraStyle name="Caption" fontName="Helvetica" fontSize="10.0" leading="13" spaceBefore="6.0" spaceAfter="6.0"/>
<paraStyle name="Index" fontName="Helvetica"/>
</stylesheet>
<story>
<blockTable colWidths="143.0,226.0,156.0" repeatRows="1" style="Table1">
@ -95,29 +103,29 @@
</td>
</tr>
</blockTable>
<blockTable colWidths="70.0,341.0,131.0" style="Table7">
<blockTable colWidths="131.0,280.0,131.0" style="Table7">
<tr>
<td>
<para style="P12" ><font color='blue'>Code</font></para>
<para style="P12a" ><font color='blue'>Code</font></para>
</td>
<td>
<para style="P12"><font color='blue'>Account name</font></para>
<para style="P12a"><font color='blue'>Account Name</font></para>
</td>
<td>
<para style="P13"><font color='blue'>Balance</font></para>
</td>
</tr>
</blockTable>
<blockTable colWidths="75.0,341.0,131.0" style="Table4">
<blockTable colWidths="131.0,280.0,131.0" style="Table4">
<tr>
<td>
<para style="P10">[[ repeatIn(lines(data['form']), 'a') ]]<font> [[ a['code'] ]] [[ a['font_style'] and (setTag('font','font',{'face':a['font_style'] })) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
<para style="P10">[[ repeatIn(lines(data['form'],object=o), 'a') ]]<font> [[ a['code'] ]] [[ (a['font_style']) and (setTag('font','font',{'face':a['font_style']})) or (a['level']==1 and (setTag('para','para',{'fontName':'Helvetica-Bold'}))) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
<td>
<para style="P17"><font>[[ '.. .. '*(a['level']-1) ]] [[ a['name'] ]] [[ a['font_style'] and (setTag('font','font',{'face':a['font_style']})) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
<para style="P17"><font><font color="white">[[ '..'*(a['level']-1) ]]</font> [[ a['name'] ]] [[ (a['font_style']) and (setTag('font','font',{'face':a['font_style']})) or (a['level']==1 and (setTag('para','para',{'fontName':'Helvetica-Bold'}))) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
<td>
<para style="P18"><font>[[ '%.2f'% a['balance'] ]] [[ a['font_style'] and (setTag('font','font', {'face':a['font_style'] })) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
<para style="P18"><font>[[ '%.2f'% a['balance'] ]] [[ (a['font_style']) and (setTag('font','font',{'face':a['font_style']})) or (a['level']==1 and (setTag('para','para',{'fontName':'Helvetica-Bold'}))) ]] [[ a['color_font'] and ( setTag('font','font',{'color':a['color_font']})) ]] [[ a['color_back'] and ( setTag('para','para',{'backColor':a['color_back']})) ]]</font></para>
</td>
</tr>

View File

@ -159,7 +159,8 @@ class account_invoice_tax(osv.osv):
tax_obj = self.pool.get('account.tax')
cur_obj = self.pool.get('res.currency')
cur = inv.currency_id
company_currency = inv.company_id.currency_id.id
for line in inv.invoice_line:
data = self.pool.get('account.invoice.line')._amount_line2(cr, uid, [line.id], [], [], context)[line.id]
for tax in data['data']:
@ -174,14 +175,14 @@ class account_invoice_tax(osv.osv):
if inv.type in ('out_invoice','in_invoice'):
val['base_code_id'] = tax['base_code_id']
val['tax_code_id'] = tax['tax_code_id']
val['base_amount'] = val['base'] * tax['base_sign']
val['tax_amount'] = val['amount'] * tax['tax_sign']
val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
val['account_id'] = tax['account_collected_id'] or line.account_id.id
else:
val['base_code_id'] = tax['ref_base_code_id']
val['tax_code_id'] = tax['ref_tax_code_id']
val['base_amount'] = val['base'] * tax['ref_base_sign']
val['tax_amount'] = val['amount'] * tax['ref_tax_sign']
val['base_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['base'] * tax['ref_base_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
val['tax_amount'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, val['amount'] * tax['ref_tax_sign'], context={'date': inv.date_invoice or time.strftime('%Y-%m-%d')}, round=False)
val['account_id'] = tax['account_paid_id'] or line.account_id.id
key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
@ -193,6 +194,11 @@ class account_invoice_tax(osv.osv):
tax_grouped[key]['base_amount'] += val['base_amount']
tax_grouped[key]['tax_amount'] += val['tax_amount']
for t in tax_grouped.values():
t['amount'] = cur_obj.round(cr, uid, cur, t['amount'])
t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount'])
t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount'])
return tax_grouped
account_invoice_tax()

View File

@ -91,7 +91,7 @@ class account_voucher(osv.osv):
'account_id':fields.many2one('account.account', 'Account', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'payment_ids':fields.one2many('account.voucher.line','voucher_id','Voucher Lines', readonly=False, states={'proforma':[('readonly',True)]}),
'period_id': fields.many2one('account.period', 'Period', required=True, states={'posted':[('readonly',True)]}),
'narration':fields.text('Narration', readonly=True, states={'draft':[('readonly',False)]}),
'narration':fields.text('Narration', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}),
'company_id': fields.many2one('res.company', 'Company', required=True),
'state':fields.selection(

View File

@ -48,7 +48,7 @@ class hr_analytic_timesheet(osv.osv):
_inherit = "hr.analytic.timesheet"
def on_change_account_id(self, cr, uid, ids,account_id, user_id=False, unit_amount=0, journal_id=0):
def on_change_account_id(self, cr, uid, ids, user_id, account_id, unit_amount=0, journal_id=0):
res = {}
if not (account_id):
#avoid a useless call to super

View File

@ -47,6 +47,7 @@ class res_partner_contact(osv.osv):
'active' : fields.boolean('Active'),
'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'),
'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'),
'email': fields.char('E-Mail', size=240),
}
_defaults = {
'active' : lambda *a: True,
@ -121,6 +122,9 @@ class res_partner_job(osv.osv):
'sequence_partner':fields.integer('Partner Seq.',help='Order of importance of this job title in the list of job title of the linked partner'),
'email': fields.char('E-Mail', size=240),
'phone': fields.char('Phone', size=64),
'fax': fields.char('Fax', size=64),
'extension': fields.char('Extension', size=64, help='Internal/External extension phone number'),
'other': fields.char('Other', size=64, help='Additional phone field'),
'date_start' : fields.date('Date Start'),
'date_stop' : fields.date('Date Stop'),
'state' : fields.selection([('past', 'Past'),('current', 'Current')], 'State', required=True),

View File

@ -12,6 +12,7 @@
<field name="name"/>
<field name="first_name"/>
<field name="mobile"/>
<field name="email"/>
<field name="lang_id"/>
<field name="partner_id"/>
<field name="function_id"/>
@ -34,6 +35,7 @@
<field name="mobile" select="2"/>
<field name="title" select="1" />
<field name="website"/>
<field name="email"/>
<field name="lang_id"/>
<field name="active"/>
<field name="partner_id" invisible="1" select="2"/>
@ -45,6 +47,9 @@
<field name="name"/>
<field name="sequence_contact"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="other"/>
<field name="email" widget="email"/>
<field name="date_start" />
<field name="date_stop" />
@ -56,6 +61,9 @@
<field name="name"/>
<field name="address_id"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="other"/>
<field name="email"/>
<field name="state" />
</tree>
@ -113,6 +121,9 @@
<field name="contact_id"/>
<field name="function_id"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="other"/>
<field name="email"/>
</tree>
<form string="Contacts">
@ -121,6 +132,9 @@
<field name="contact_id"/>
<field name="function_id"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="other"/>
<field name="email" widget="email"/>
</form>
</field>
@ -271,12 +285,16 @@
<field name="contact_id"/>
<field name="function_id"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="email"/>
</tree>
<form string="Contacts">
<field name="contact_id"/>
<field name="function_id"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="email" widget="email"/>
</form>
</field>
@ -297,6 +315,8 @@
<field name="address_id"/>
<field name="email"/>
<field name="phone"/>
<field name="fax"/>
<field name="extension"/>
<field name="state" />
</tree>
</field>
@ -316,6 +336,8 @@
<field name="function_id" select="1"/>
<field name="email" select="2" widget="email"/>
<field name="phone" select="2"/>
<field name="fax"/>
<field name="extension"/>
<field name="sequence_contact" select="2" groups="base.group_user"/>
<field name="sequence_partner" select="2" groups="base.group_user"/>
<field name="date_start" groups="base.group_user"/>

View File

@ -306,7 +306,7 @@ from
return True
def _aggregation_error(self, cr, uid, ids):
aggregate_columns = ('int','float')
aggregate_columns = ('integer','float')
apply_functions = ('sum','min','max','avg','count')
this_objs = self.browse(cr, uid, ids)
for obj in this_objs:

View File

@ -3,8 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# Copyright (C) 2008-2009 B2CK, Cedric Krier, Bertrand Chenal (the methods "check_vat_[a-z]{2}"
# $Id$
# Copyright (C) 2008-2009 B2CK, Cedric Krier, Bertrand Chenal (the methods "check_vat_[a-z]{2}"
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@ -81,7 +81,9 @@ class board_board(osv.osv):
'type': 'form',
'arch': self.create_view(cr, user, id, context),
})
super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context)
return id
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):

View File

@ -240,6 +240,7 @@ class crm_case_rule(osv.osv):
'trg_priority_from': fields.selection([('','')] + AVAILABLE_PRIORITIES, 'Minimum Priority'),
'trg_priority_to': fields.selection([('','')] + AVAILABLE_PRIORITIES, 'Maximim Priority'),
'trg_max_history': fields.integer('Maximum Communication History'),
'act_method': fields.char('Call Object Method', size=64),
'act_state': fields.selection([('','')]+AVAILABLE_STATES, 'Set state to', size=16),
@ -418,6 +419,7 @@ class crm_case(osv.osv):
ok = ok and (not action.trg_categ_id or action.trg_categ_id.id==case.categ_id.id)
ok = ok and (not action.trg_user_id.id or action.trg_user_id.id==case.user_id.id)
ok = ok and (not action.trg_partner_id.id or action.trg_partner_id.id==case.partner_id.id)
ok = ok and (not action.trg_max_history or action.trg_max_history<=(len(case.history_line)+1))
ok = ok and (
not action.trg_partner_categ_id.id or
(
@ -660,6 +662,9 @@ class crm_case(osv.osv):
if not case.email_from:
raise osv.except_osv(_('Error!'),
_('You must put a Partner eMail to use this action!'))
if not case.user_id:
raise osv.except_osv(_('Error!'),
_('You must define a responsible user for this case in order to use this action!'))
if not case.description:
raise osv.except_osv(_('Error!'),
_('Can not send mail with empty body,you should have description in the body'))
@ -738,6 +743,7 @@ class crm_case(osv.osv):
else:
raise osv.except_osv(_('Error !'), _('You can not escalate this case.\nYou are already at the top level.'))
self.write(cr, uid, ids, data)
cases = self.browse(cr, uid, ids)
self.__history(cr, uid, cases, _('Escalate'))
self._action(cr, uid, cases, 'escalate')
return True
@ -810,6 +816,14 @@ class crm_case_history(osv.osv):
_description = "Case history"
_order = "id desc"
_inherits = {'crm.case.log':"log_id"}
def create(self, cr, user, vals, context=None):
if vals.has_key('case_id') and vals['case_id']:
case_obj = self.pool.get('crm.case')
cases = case_obj.browse(cr, user, [vals['case_id']])
case_obj._action(cr, user, cases, '')
return super(crm_case_history, self).create(cr, user, vals, context)
def _note_get(self, cursor, user, ids, name, arg, context=None):
res = {}
for hist in self.browse(cursor, user, ids, context or {}):

View File

@ -40,7 +40,7 @@ class crm_segmentation(osv.osv):
'state': fields.selection([('not running','Not Running'),('running','Running')], 'Execution Status', readonly=True),
'partner_id': fields.integer('Max Partner ID processed'),
'segmentation_line': fields.one2many('crm.segmentation.line', 'segmentation_id', 'Criteria', required=True),
'som_interval': fields.integer('Days per Periode', help="A period is the average number of days between two cycle of sale or purchase for this segmentation. It's mainly used to detect if a partner has not purchased or buy for a too long time, so we suppose that his state of mind has decreased because he probably bought goods to another supplier. Use this functionnality for recurring businesses."),
'som_interval': fields.integer('Days per Periode', help="A period is the average number of days between two cycle of sale or purchase for this segmentation. It's mainly used to detect if a partner has not purchased or buy for a too long time, so we suppose that his state of mind has decreased because he probably bought goods to another supplier. Use this functionality for recurring businesses."),
'som_interval_max': fields.integer('Max Interval', help="The computation is made on all events that occured during this interval, the past X periods."),
'som_interval_decrease': fields.float('Decrease (0>1)', help="If the partner has not purchased (or buied) during a period, decrease the state of mind by this factor. It\'s a multiplication"),
'som_interval_default': fields.float('Default (0=None)', help="Default state of mind for period preceeding the 'Max Interval' computation. This is the starting state of mind by default if the partner has no event."),
@ -102,7 +102,7 @@ class crm_segmentation_line(osv.osv):
'expr_name': fields.selection([('sale','Sale Amount'),('som','State of Mind'),('purchase','Purchase Amount')], 'Control Variable', size=64, required=True),
'expr_operator': fields.selection([('<','<'),('=','='),('>','>')], 'Operator', required=True),
'expr_value': fields.float('Value', required=True),
'operator': fields.selection([('and','Mandatory Expression'),('or','Optional Expression')],'Mandatory / Optionnal', required=True),
'operator': fields.selection([('and','Mandatory Expression'),('or','Optional Expression')],'Mandatory / Optional', required=True),
}
_defaults = {
'expr_name': lambda *a: 'sale',

View File

@ -20,7 +20,7 @@
</field>
</record>
<!-- Case Sections -->
<!-- Case Sections -->
<record id="crm_case_section_view_form" model="ir.ui.view">
<field name="name">crm.case.section.form</field>
<field name="model">crm.case.section</field>
@ -100,7 +100,7 @@
</tree>
</field>
</record>
<record id="crm_case_categ-act" model="ir.actions.act_window">
<field name="name">Categories</field>
<field name="res_model">crm.case.categ</field>
@ -108,7 +108,7 @@
<field name="view_id" ref="crm_case_categ_tree-view"/>
</record>
<menuitem action="crm_case_categ-act" id="menu_crm_case_categ-act" parent="crm.next_id_51"/>
<!-- Case rules -->
<record id="crm_case_rule-view" model="ir.ui.view">
<field name="name">crm.case.rule.form</field>
@ -123,7 +123,7 @@
<separator colspan="4" string="Conditions on States"/>
<field name="trg_state_from" select="2"/>
<field name="trg_state_to" select="2"/>
<separator colspan="4" string="Conditions on Case Fields"/>
<field name="trg_section_id" select="1"/>
<field name="trg_categ_id"/>
@ -141,6 +141,8 @@
<field name="trg_date_range" nolabel="1"/>
<field name="trg_date_range_type" nolabel="1"/>
</group>
<separator colspan="4" string="Condition on Communication History"/>
<field name="trg_max_history"/>
<separator colspan="4" string="Note"/>
<label align="0.0" string="The rule use a AND operator. The case must match all non empty fields so that the rule execute the action described in the 'Actions' tab." colspan="4"/>
</page>
@ -200,8 +202,8 @@
<field name="view_id" ref="crm_case_rule_tree-view"/>
</record>
<menuitem action="crm_case_rule-act" id="menu_crm_case_rule-act" parent="crm.next_id_51"/>
<!-- Cases -->
<record id="crm_case_log_tree-view" model="ir.ui.view">
<field name="name">crm.case.log.tree</field>
@ -218,8 +220,8 @@
</tree>
</field>
</record>
<record id="crm_case_history_tree-view" model="ir.ui.view">
<field name="name">crm.case.history.tree</field>
<field name="model">crm.case.history</field>
@ -234,7 +236,7 @@
</tree>
</field>
</record>
<record id="crm_case_calendar-view" model="ir.ui.view">
<field name="name">crm.case.calendar</field>
<field name="model">crm.case</field>
@ -247,8 +249,8 @@
</calendar>
</field>
</record>
<record id="crm_case_tree-view" model="ir.ui.view">
<field name="name">crm.case.tree</field>
<field name="model">crm.case</field>
@ -268,7 +270,7 @@
</tree>
</field>
</record>
<record id="crm_case-view" model="ir.ui.view">
<field name="name">crm.case.form</field>
<field name="model">crm.case</field>
@ -292,7 +294,7 @@
<field name="user_id" select="1"/>
<button name="remind_user" states="open,pending" string="Send Reminder" type="object"/>
</group>
<separator colspan="4"/>
<field colspan="2" mode="tree,form" name="history_line" nolabel="1">
<form string="Communication history">
@ -315,7 +317,7 @@
<button name="case_log_reply" states="open" string="Send Partner &amp; Historize" type="object"/>
<button name="case_log" states="open" string="Historize" type="object"/>
</group>
<separator colspan="4"/>
<group col="8" colspan="4">
<field name="state" select="1"/>
@ -362,7 +364,7 @@
</form>
</field>
</record>
<record id="crm_case_categ0-act" model="ir.actions.act_window">
<field name="name">All Cases</field>
<field name="res_model">crm.case</field>
@ -370,7 +372,7 @@
<field name="view_id" ref="crm_case_tree-view"/>
</record>
<menuitem action="crm_case_categ0-act" id="menu_crm_case_categ0-act" parent="crm.next_id_52"/>
<record id="crm_case_categ0-act_open" model="ir.actions.act_window">
<field name="name">Open Cases</field>
<field name="res_model">crm.case</field>
@ -378,8 +380,8 @@
<field name="domain">[('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]</field>
</record>
<menuitem action="crm_case_categ0-act_open" id="menu_crm_case_categ0-act_open" parent="crm.menu_crm_case_categ0-act"/>
<record id="crm_case_categ0-act_my" model="ir.actions.act_window">
<field name="name">My cases</field>
<field name="res_model">crm.case</field>
@ -396,10 +398,10 @@
<field name="domain">[('user_id','=',uid),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]</field>
</record>
<menuitem action="crm_case_categ0-act_my_open" id="menu_crm_case_categ0-act_my_open" parent="crm.menu_crm_case_categ0-act_my"/>
<record id="crm_case_section_open_act" model="ir.actions.act_window">
<field name="name">crm.case.section.open</field>
<field name="res_model">crm.case</field>
@ -414,8 +416,8 @@
<field eval="'ir.actions.act_window,%d'%crm_case_section_open_act" name="value"/>
<field eval="True" name="object"/>
</record>
<record id="crm_case_history-view" model="ir.ui.view">
<field name="name">crm.case.history.form</field>
<field name="model">crm.case.history</field>
@ -450,7 +452,7 @@
<field name="domain">[('user_id','=',uid)]</field>
</record>
<menuitem action="crm_case_history_my-act" id="menu_crm_case_history_my-act" parent="crm.menu_crm_case_history-act_main"/>
<record id="crm_segmentation_line_tree-view" model="ir.ui.view">
<field name="name">crm.segmentation.line.tree</field>
<field name="model">crm.segmentation.line</field>
@ -465,7 +467,7 @@
</tree>
</field>
</record>
<record id="crm_segmentation_line-view" model="ir.ui.view">
<field name="name">crm.segmentation.line.form</field>
<field name="model">crm.segmentation.line</field>
@ -483,7 +485,7 @@
</form>
</field>
</record>
<record id="crm_segmentation-view" model="ir.ui.view">
<field name="name">crm.segmentation.form</field>
<field name="model">crm.segmentation</field>
@ -532,14 +534,14 @@
</tree>
</field>
</record>
<record id="crm_segmentation-act" model="ir.actions.act_window">
<field name="name">Segmentations</field>
<field name="res_model">crm.segmentation</field>
<field name="view_type">form</field>
<field name="view_id" ref="crm_segmentation-view"/>
</record>
<record id="crm_segmentation_tree-act" model="ir.actions.act_window">
<field name="name">Segmentations</field>
<field name="res_model">crm.segmentation</field>
@ -547,17 +549,17 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem id="next_id_53" name="Segmentations" parent="crm.menu_crm_configuration"/><menuitem action="crm_segmentation_tree-act" id="menu_crm_segmentation-act" parent="next_id_53"/>
<act_window domain="[('section_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_crm_case_section_crm_case_opened" name="Open cases" res_model="crm.case" src_model="crm.case.section" view_mode="tree,form,calendar" view_type="form"/>
<act_window domain="[('categ_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_crm_case_categ_crm_case_opened" name="Open cases" res_model="crm.case" src_model="crm.case.categ" view_mode="tree,form,calendar" view_type="form"/>
<act_window domain="[('partner_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_partner_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.partner" view_mode="tree,form,calendar" view_type="form"/>
<act_window domain="[('canal_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_partner_canal_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.partner.canal" view_mode="tree,form,calendar" view_type="form"/>
<act_window domain="[('user_id', '=', active_id),('state','&lt;&gt;','done'),('state','&lt;&gt;','cancel'),('state','&lt;&gt;','pending')]" id="act_res_users_2_crm_case_opened" name="Open cases" res_model="crm.case" src_model="res.users" view_mode="tree,form,calendar" view_type="form"/>
</data>
</openerp>

View File

@ -141,7 +141,9 @@ class email_parser(object):
message['attachment'] = {};
attachment = message['attachment'];
counter = 1;
def replace(match):
return ''
for part in msg.walk():
if part.get_content_maintype() == 'multipart':
continue
@ -149,7 +151,10 @@ class email_parser(object):
if part.get_content_maintype()=='text' and part.get_content_subtype() == 'plain':
buf = part.get_payload(decode=True)
if buf:
message['body'] += buf.decode(part.get_charsets()[0] or 'ascii', 'replace')
txt = buf.decode(part.get_charsets()[0] or 'ascii', 'replace')
txt = re.sub("<(\w)>", replace, txt)
txt = re.sub("<\/(\w)>", replace, txt)
message['body'] += txt
elif part.get_content_maintype()=='application' or part.get_content_maintype()=='image' or part.get_content_maintype()=='text':
filename = part.get_filename();
if filename :

View File

@ -49,9 +49,14 @@ class crm_case_stage(osv.osv):
_name = "crm.case.stage"
_description = "Stage of case"
_rec_name = 'name'
_order = "sequence"
_columns = {
'name': fields.char('Stage Name', size=64, required=True, translate=True),
'section_id': fields.many2one('crm.case.section', 'Case Section'),
'sequence': fields.integer('Sequence'),
}
_defaults = {
'sequence': lambda *args: 1
}
crm_case_stage()

View File

@ -72,6 +72,7 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stages">
<field name="sequence"/>
<field name="name"/>
<field name="section_id"/>
</tree>
@ -85,6 +86,7 @@
<form string="Stage">
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="sequence"/>
</form>
</field>
</record>

View File

@ -260,7 +260,7 @@
<field name="view_mode">graph,tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support2)+')]'"/>
</record>
<menuitem parent="menu_action_report_crm_case_lead" name="Cases by Leads and Category2" action="action_report_crm_case_lead_categ" id="menu_action_report_crm_case_lead_categ"/>
<menuitem parent="menu_action_report_crm_case_lead" name="Cases by Leads and Type" action="action_report_crm_case_lead_categ" id="menu_action_report_crm_case_lead_categ"/>
<record model="ir.actions.act_window" id="action_report_crm_case_lead_stage">
<field name="res_model">report.crm.case.section.stage</field>
@ -284,7 +284,7 @@
<field name="view_mode">tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support2)+')]'"/>
</record>
<menuitem name="Cases by Section, Category and Category2" parent="menu_action_report_crm_case_lead" action="action_report_crm_case_lead_categ_categ2" id="menu_action_report_crm_case_lead_categ_categ2"/>
<menuitem name="Cases by Section, Category and Type" parent="menu_action_report_crm_case_lead" action="action_report_crm_case_lead_categ_categ2" id="menu_action_report_crm_case_lead_categ_categ2"/>
</data>

View File

@ -125,9 +125,9 @@
<field name="arch" type="xml">
<tree string="Leads Tree" colors="red:state=='open'">
<field name="id"/>
<field name="name" string="Name"/>
<field name="name" string="Lead Subject"/>
<field name="partner_phone"/>
<field name="partner_name2" string="Email"/>
<field name="partner_name2" string="Contact Name"/>
<field name="stage_id"/>
<field name="categ_id" string="Lead Source"/>
<field name="category2_id" string="Campaign Type"/>

View File

@ -255,7 +255,7 @@
<field name="view_mode">graph,tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
</record>
<menuitem name="Cases by Opportunities and Category2" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ" id="menu_action_report_crm_case_oppor_categ"/>
<menuitem name="Cases by Opportunities and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ" id="menu_action_report_crm_case_oppor_categ"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_stage">
<field name="res_model">report.crm.case.section.stage</field>
@ -271,7 +271,7 @@
<field name="view_mode">tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
</record>
<menuitem name="Cases by Section, Category and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_stage" id="menu_action_report_crm_case_oppor_categ_stage"/>
<menuitem name="Cases by Opportunities, Category and Stage" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_stage" id="menu_action_report_crm_case_oppor_categ_stage"/>
<record model="ir.actions.act_window" id="action_report_crm_case_oppor_categ_categ2">
<field name="res_model">report.crm.case.section.categ.categ2</field>
@ -279,7 +279,7 @@
<field name="view_mode">tree</field>
<field name="domain" eval="'[(\'section_id\',\'=\','+str(section_support3)+')]'"/>
</record>
<menuitem name="Cases by Section, Category and Category2" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_categ2" id="menu_action_report_crm_case_oppor_categ_categ2"/>
<menuitem name="Cases by Opportunities, Category and Type" parent="menu_action_report_crm_case_oppor" action="action_report_crm_case_oppor_categ_categ2" id="menu_action_report_crm_case_oppor_categ_categ2"/>
</data>

View File

@ -6,11 +6,11 @@
#
<record model="ir.ui.view" id="view_crm_case_section_categ_tree">
<field name="name">CRM Report - Sections and Category2(Tree)</field>
<field name="name">CRM Report - Sections and Type(Tree)</field>
<field name="model">report.crm.case.section.categ2</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section and Category2">
<tree string="Cases by Section and Type">
<field name="name"/>
<field name="user_id"/>
<field name="section_id"/>
@ -24,7 +24,7 @@
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_form">
<field name="name">CRM Report - Sections and Category2(Form)</field>
<field name="name">CRM Report - Sections and Type(Form)</field>
<field name="model">report.crm.case.section.categ2</field>
<field name="type">form</field>
<field name="arch" type="xml">
@ -42,11 +42,11 @@
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_graph">
<field name="name">CRM Report - Sections and Category2(Graph)</field>
<field name="name">CRM Report - Sections and Type(Graph)</field>
<field name="model">report.crm.case.section.categ2</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Cases by Section and Category2" type="bar" orientation="horizontal">
<graph string="Cases by Section and Type" type="bar" orientation="horizontal">
<field name="category2_id"/>
<field name="amount_revenue" operator="+"/>
<field name="section_id" group="True"/>
@ -60,14 +60,14 @@
<field name="view_mode">graph,tree</field>
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
</record>
<menuitem parent="report_crm.next_id_65" name="Cases by Section and Category2" action="action_report_crm_case_section_categ_tree_month" id="menu_crm_case_section_categ_tree_month"/>
<menuitem parent="report_crm.next_id_65" name="Cases by Section and Type" action="action_report_crm_case_section_categ_tree_month" id="menu_crm_case_section_categ_tree_month"/>
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_tree">
<field name="res_model">report.crm.case.section.categ2</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
</record>
<menuitem parent="report_crm.next_id_66" name="Cases by Section and Category2" action="action_report_crm_case_section_categ_tree" id="menu_crm_case_section_categ_tree"/>
<menuitem parent="report_crm.next_id_66" name="Cases by Section and Type" action="action_report_crm_case_section_categ_tree" id="menu_crm_case_section_categ_tree"/>
#
# Cases by section and stage
@ -192,11 +192,11 @@
#
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_tree">
<field name="name">CRM Report - Section, Category and Category2(Tree)</field>
<field name="name">CRM Report - Section, Category and Type(Tree)</field>
<field name="model">report.crm.case.section.categ.categ2</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section, Category and Category2">
<tree string="Cases by Section, Category and Type">
<field name="name"/>
<field name="user_id"/>
<field name="section_id"/>
@ -210,11 +210,11 @@
</field>
</record>
<record model="ir.ui.view" id="view_crm_case_section_categ_categ2_form">
<field name="name">CRM Report - Section, Category and Category2(Form)</field>
<field name="name">CRM Report - Section, Category and Type(Form)</field>
<field name="model">report.crm.case.section.categ.categ2</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Cases by Section, Category and Category2">
<form string="Cases by Section, Category and Type">
<field name="name"/>
<field name="user_id"/>
<field name="section_id" select="1"/>
@ -234,12 +234,12 @@
<field name="view_mode">tree</field>
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
</record>
<menuitem parent="report_crm.next_id_65" name="Cases by Section, Category and Category2" action="action_report_crm_case_section_categ_categ2_tree_month" id="menu_crm_case_section_categ_categ2_tree_month"/>
<menuitem parent="report_crm.next_id_65" name="Cases by Section, Category and Type" action="action_report_crm_case_section_categ_categ2_tree_month" id="menu_crm_case_section_categ_categ2_tree_month"/>
<record model="ir.actions.act_window" id="action_report_crm_case_section_categ_categ2_tree">
<field name="res_model">report.crm.case.section.categ.categ2</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<menuitem parent="report_crm.next_id_66" name="Cases by Section, Category and Category2" action="action_report_crm_case_section_categ_categ2_tree" id="menu_crm_case_section_categ_categ2_tree"/>
<menuitem parent="report_crm.next_id_66" name="Cases by Section, Category and Type" action="action_report_crm_case_section_categ_categ2_tree" id="menu_crm_case_section_categ_categ2_tree"/>
</data>
</openerp>

View File

@ -588,6 +588,7 @@ class document_file(osv.osv):
res=self.search(cr,uid,[('id','<>',file.id),('name','=',name),('parent_id','=',parent_id),('res_model','=',res_model),('res_id','=',res_id)])
if len(res):
return False
if op=='create':
res=self.search(cr,uid,[('name','=',name),('parent_id','=',parent_id),('res_id','=',res_id),('res_model','=',res_model)])
if len(res):

View File

@ -36,7 +36,7 @@ class ftp_server(threading.Thread):
logger.notifyChannel('FTP', level, message)
def run(self):
autho = authorizer.authorizer()
autho = authorizer.authorizer()
ftpserver.FTPHandler.authorizer = autho
ftpserver.max_cons = 300
ftpserver.max_cons_per_ip = 50

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -50,6 +50,7 @@ class hr_department(osv.osv):
return False
level -= 1
return True
_constraints = [
(_check_recursion, 'Error! You can not create recursive departments.', ['parent_id'])
]
@ -81,7 +82,50 @@ class ir_action_window(osv.osv):
ir_action_window()
class res_users(osv.osv):
_inherit = 'res.users'
_description = 'res.users'
def _parent_compute(self, cr, uid, ids, name, arg, context={}):
result = {}
obj_dept = self.pool.get('hr.department')
for id in ids:
ids_dept = obj_dept.search(cr, uid, [('member_ids', 'in', [id])])
parent_ids = []
if ids_dept:
data_dept = obj_dept.read(cr, uid, ids_dept, ['manager_id'])
parent_ids = map(lambda x: x['manager_id'][0], data_dept)
result[id] = parent_ids
return result
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
def _child_compute(self, cr, uid, ids):
obj_dept = self.pool.get('hr.department')
child_ids = []
for id in ids:
ids_dept = obj_dept.search(cr, uid, [('manager_id', '=', id)])
if ids_dept:
data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'])
childs = map(lambda x: x['member_ids'], data_dept)
childs = tools.flatten(childs)
if id in childs:
childs.remove(id)
child_ids.extend(tools.flatten(childs))
return child_ids
def _parent_search(self, cr, uid, obj, name, args):
parent = []
for arg in args:
if arg[0] == 'parent_id':
parent = arg[2]
child_ids = self._child_compute(cr, uid, parent)
if not child_ids:
return [('id', 'in', [0])]
return [('id', 'in', child_ids)]
_columns = {
'parent_id': fields.function(_parent_compute, relation='res.users',fnct_search=_parent_search, method=True, string="Parent Users", type='many2many'),
}
res_users()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!--
======================
department
@ -48,14 +48,29 @@
<field name="domain">[('parent_id','=',False)]</field>
</record>
<menuitem action="open_module_tree_department_tree" id="menu_department_tree" parent="base.menu_users"/>
<record id="open_module_tree_department" model="ir.actions.act_window">
<field name="name">Departments</field>
<field name="res_model">hr.department</field>
<field name="view_type">form</field>
</record>
<menuitem action="open_module_tree_department" id="menu_department_def" parent="hr.menu_department_tree"/>
<!-- res.users inherit -->
<record model="ir.ui.view" id="view_users_form_inherit">
<field name="name">res.users.form</field>
<field name="type">form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Parents">
<field name="parent_id" nolabel="1"/>
</page>
</notebook>
</field>
</record>
</data>
</openerp>

View File

@ -62,7 +62,7 @@ class hr_expense_expense(osv.osv):
'employee_id': fields.many2one('hr.employee', 'Employee', required=True),
'user_id': fields.many2one('res.users', 'User', required=True),
'date_confirm': fields.date('Date Confirmed'),
'date_valid': fields.date('Date Valided'),
'date_valid': fields.date('Date Validated'),
'user_valid': fields.many2one('res.users', 'Validation User'),
'account_move_id': fields.many2one('account.move', 'Account Move'),
'line_ids': fields.one2many('hr.expense.line', 'expense_id', 'Expense Lines', readonly=True, states={'draft':[('readonly',False)]} ),
@ -77,7 +77,7 @@ class hr_expense_expense(osv.osv):
('accepted', 'Accepted'),
('invoiced', 'Invoiced'),
('paid', 'Reimbursed'),
('canceled', 'Canceled')],
('cancelled', 'Cancelled')],
'State', readonly=True),
}
_defaults = {
@ -104,7 +104,7 @@ class hr_expense_expense(osv.osv):
return True
def expense_canceled(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {'state':'canceled'})
self.write(cr, uid, ids, {'state':'cancelled'})
return True
def expense_paid(self, cr, uid, ids, *args):
@ -172,6 +172,15 @@ class hr_expense_expense(osv.osv):
return res
hr_expense_expense()
class product_product(osv.osv):
_inherit = "product.product"
_columns = {
'hr_expense_ok': fields.boolean('Can be Expensed', help="Determine if the product can be visible in the list of product within a selection from an HR expense sheet line."),
}
product_product()
class hr_expense_line(osv.osv):
_name = "hr.expense.line"
@ -191,7 +200,7 @@ class hr_expense_line(osv.osv):
'total_amount': fields.function(_amount, method=True, string='Total'),
'unit_amount': fields.float('Unit Price'),
'unit_quantity': fields.float('Quantities' ),
'product_id': fields.many2one('product.product', 'Product' ),
'product_id': fields.many2one('product.product', 'Product', domain=[('hr_expense_ok','=',True)]),
'uom_id': fields.many2one('product.uom', 'UoM' ),
'description': fields.text('Description'),
'analytic_account': fields.many2one('account.analytic.account','Analytic account'),
@ -215,6 +224,5 @@ class hr_expense_line(osv.osv):
hr_expense_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -178,5 +178,17 @@
</record>
<menuitem action="expense_my_confirm" id="menu_expense_my_confirm" parent="hr_expense.menu_expense_my"/>
<record id="view_product_hr_expense_form" model="ir.ui.view">
<field name="name">product.product.expense.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field groups="base.group_extended" name="rental" position="after">
<field name="hr_expense_ok"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@ -288,6 +288,6 @@
<para style="terp_default_9">
<font color="white"> </font>
</para>
<para style="terp_default_9">This document must be dated and signed for reimbursment</para>
<para style="terp_default_9">This document must be dated and signed for reimbursement</para>
</story>
</document>

View File

@ -62,6 +62,48 @@ class hr_holidays_status(osv.osv):
}
hr_holidays_status()
class hr_holidays_per_user(osv.osv):
_name = "hr.holidays.per.user"
_description = "Holidays Per User"
_rec_name = "user_id"
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
obj_holiday = self.pool.get('hr.holidays')
result = {}
for holiday_user in self.browse(cr, uid, ids):
days = 0.0
ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
if ids_request:
holidays = obj_holiday.browse(cr, uid, ids_request)
for holiday in holidays:
days += holiday.number_of_days
days = holiday_user.max_leaves - days
result[holiday_user.id] = days
return result
_columns = {
'employee_id': fields.many2one('hr.employee', 'Employee',required=True),
'user_id' : fields.many2one('res.users','User'),
'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", required=True),
'max_leaves' : fields.float('Maximum Leaves Allowed',required=True),
'leaves_taken' : fields.float('Leaves Already Taken',readonly=True),
'active' : fields.boolean('Active'),
'notes' : fields.text('Notes'),
'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
'holiday_ids': fields.one2many('hr.holidays', 'holiday_user_id', 'Holidays')
}
_defaults = {
'active' : lambda *a: True,
}
def create(self, cr, uid, vals, *args, **kwargs):
if vals['employee_id']:
obj_emp=self.pool.get('hr.employee').browse(cr,uid,vals['employee_id'])
vals.update({'user_id': obj_emp.user_id.id})
return super(osv.osv,self).create(cr, uid, vals, *args, **kwargs)
hr_holidays_per_user()
class hr_holidays(osv.osv):
_name = "hr.holidays"
_description = "Holidays"
@ -76,8 +118,9 @@ class hr_holidays(osv.osv):
'user_id':fields.many2one('res.users', 'Employee_id', states={'draft':[('readonly',False)]}, select=True, readonly=True),
'manager_id' : fields.many2one('hr.employee', 'Holiday manager', invisible=False, readonly=True),
'notes' : fields.text('Notes',readonly=True, states={'draft':[('readonly',False)]}),
'number_of_days': fields.float('Number of Days in this Holiday Request',required=True),
'case_id':fields.many2one('crm.case', 'Case'),
'number_of_days': fields.float('Number of Days in this Holiday Request', required=True, readonly=True, states={'draft': [('readonly', False)]}),
'case_id': fields.many2one('crm.case', 'Case'),
'holiday_user_id': fields.many2one('hr.holidays.per.user', 'Holiday per user')
}
_defaults = {
@ -99,27 +142,19 @@ class hr_holidays(osv.osv):
def create(self, cr, uid, vals, *args, **kwargs):
id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs)
self._create_log(cr, uid, [id_holiday])
self._create_holiday(cr, uid, [id_holiday])
return id_holiday
def _create_log(self, cr, uid, ids):
def _create_holiday(self, cr, uid, ids):
holidays_user_obj = self.pool.get('hr.holidays.per.user')
list_request = []
holidays_data = self.browse(cr, uid, ids[0])
datas = {
'employee_id' : holidays_data.employee_id.id,
'name' : holidays_data.state,
'holiday_status' : holidays_data.holiday_status.id,
'holiday_req_id' : holidays_data.id,
'nb_holidays' : holidays_data.number_of_days
}
ids_log = self.pool.get('hr.holidays.log').create(cr, uid, datas)
list_holiday = []
ids_user_hdays = holidays_user_obj.search(cr, uid, [('employee_id', '=', holidays_data.employee_id.id),('holiday_status', '=', holidays_data.holiday_status.id)])
for hdays in holidays_user_obj.browse(cr, uid, ids_user_hdays):
for req in hdays.history:
list_request.append(req.id)
list_request.append(ids_log)
holidays_user_obj.write(cr, uid, ids_user_hdays, {'history' : [(6,0,list_request)]})
for req in hdays.holiday_ids:
list_holiday.append(req.id)
list_holiday.append(ids[0])
holidays_user_obj.write(cr, uid, ids_user_hdays, {'holiday_ids': [(6, 0, list_holiday)]})
return True
def onchange_date_to(self, cr, uid, ids, date_from, date_to):
@ -143,7 +178,7 @@ class hr_holidays(osv.osv):
'state':'draft',
'manager_id': False
})
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def holidays_validate(self, cr, uid, ids, *args):
@ -155,7 +190,7 @@ class hr_holidays(osv.osv):
if ids2:
vals['manager_id'] = ids2[0]
self.write(cr, uid, ids, vals)
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def holidays_confirm(self, cr, uid, ids, *args):
@ -167,7 +202,7 @@ class hr_holidays(osv.osv):
'state':'confirm',
'user_id': user,
})
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def holidays_refuse(self, cr, uid, ids, *args):
@ -176,7 +211,7 @@ class hr_holidays(osv.osv):
'state':'refuse',
'manager_id':ids2[0]
})
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def holidays_cancel(self, cr, uid, ids, *args):
@ -195,14 +230,14 @@ class hr_holidays(osv.osv):
self.write(cr, uid, ids, {
'state':'cancel'
})
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def holidays_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'draft'
})
self._create_log(cr, uid, ids)
self._create_holiday(cr, uid, ids)
return True
def check_holidays(self,cr,uid,ids):
@ -248,6 +283,7 @@ class hr_holidays(osv.osv):
return True
hr_holidays()
<<<<<<< TREE
class hr_holidays_per_user(osv.osv):
_name = "hr.holidays.per.user"
@ -311,3 +347,5 @@ holiday_user_log()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=======
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:>>>>>>> MERGE-SOURCE

View File

@ -51,36 +51,6 @@
</field>
</record>
<!-- holidays log -->
<record model="ir.ui.view" id="holiday_log_form">
<field name="name">hr.holidays.log.form</field>
<field name="model">hr.holidays.log</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Log Holidays">
<field name="name" select="1"/>
<field name="employee_id" select="2"/>
<field name="holiday_status" select="1" />
</form>
</field>
</record>
<record model="ir.ui.view" id="holiday_log_tree">
<field name="name">>hr.holidays.log.tree</field>
<field name="model">hr.holidays.log</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Log Holidays">
<field name="holiday_req_id" />
<field name="date" />
<field name="employee_id" />
<field name="name" />
<field name="holiday_status" />
<field name="nb_holidays" />
</tree>
</field>
</record>
<!-- holidays status -->
<record model="ir.ui.view" id="edit_holiday_status_form">
<field name="name">hr.holidays.status.form</field>
@ -129,21 +99,30 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Holidays Per Employee">
<notebook>
<group>
<field name="employee_id" select="1" />
<field name="holiday_status" select="1" />
<field name="max_leaves" select="2" />
<field name="active" select="2"/>
</group>
<notebook colspan="4">
<page string="General Information">
<field name="employee_id" select="1" />
<field name="holiday_status" select="1" />
<newline/>
<field name="max_leaves" select="2" />
<field name="leaves_taken" select="2" />
<newline/>
<field name="remaining_leaves" select="2" colspan="2" />
<field name="active" select="2"/>
<newline/>
<field name="notes" colspan="4" select="2"/>
</page>
<page string="History" >
<field name="history" nolabel="1"/>
<page string="Holidays" >
<field name="holiday_ids" nolabel="1">
<tree string="Employee Holidays">
<field name="name"/>
<field name="number_of_days" string="Number of Days"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="holiday_status"/>
<field name="state"/>
</tree>
</field>
</page>
</notebook>
</form>

View File

@ -32,7 +32,6 @@ def emp_create_xml(self,cr,uid,dept,holiday_type,row_id,empid,name,som,eom):
current=som+datetime.timedelta(diff)
for item in ids_date:
# print current,"from",item['date_from'],"to",item['date_to']
if current >= strToDate(item['date_from']) and current <= strToDate(item['date_to']):
if item['state'] in holiday_type:
display[index]=item['holiday_status'][0]
@ -150,7 +149,6 @@ class report_custom(report_rml):
width_dict[j]=x
day_diff1=day_diff1-x
# print "now day_diff1 is..frst.",day_diff1
else:
years=year+1
year=years
@ -175,7 +173,6 @@ class report_custom(report_rml):
width_dict[j]=x
day_diff1=day_diff1-x
# print "now day_diff1 is..scnd.",day_diff1
date_xml.append('</days>')
date_xml.append('<cols>3.5cm%s,0.4cm</cols>\n' % (',0.4cm' * (60)))

View File

@ -1,5 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_hr_holidays_log","hr.holidays.log","model_hr_holidays_log","hr.group_hr_user",1,1,1,1
"access_hr_holidays_per_user","hr.holidays.per.user","model_hr_holidays_per_user","hr.group_hr_user",1,1,1,1
"access_hr_holydays_status_user","hr.holidays.status user","model_hr_holidays_status","hr.group_hr_user",1,1,1,1
"access_hr_holidays_user","hr holidays user","model_hr_holidays","hr.group_hr_user",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
access_hr_holidays_log hr.holidays.log model_hr_holidays_log hr.group_hr_user 1 1 1 1
2 access_hr_holidays_per_user hr.holidays.per.user model_hr_holidays_per_user hr.group_hr_user 1 1 1 1
3 access_hr_holydays_status_user hr.holidays.status user model_hr_holidays_status hr.group_hr_user 1 1 1 1
4 access_hr_holidays_user hr holidays user model_hr_holidays hr.group_hr_user 1 1 1 1

View File

@ -141,7 +141,7 @@ def _state_check(self, cr, uid, data, context):
class wiz_si_so(wizard.interface):
states = {
'init' : {
'actions' : [],
'actions' : [_get_empid],
'result' : {'type' : 'choice', 'next_state': _state_check}
},
'sign_out' : { # this means sign_in...

View File

@ -51,12 +51,12 @@ class invoice_create(wizard.interface):
for account in analytic_account_obj.browse(cr, uid, account_ids, context):
partner = account.partner_id
if (not partner) or not (account.pricelist_id):
raise wizard.except_wizard(_('Analytic account incomplete'),
_('Please fill in the partner and pricelist field in the analytic account:\n%s') % (account.name,))
raise wizard.except_wizard(_('Analytic Account incomplete'),
_('Please fill in the Associate Partner and Sale Pricelist fields in the Analytic Account:\n%s') % (account.name,))
if not partner.address:
raise wizard.except_wizard(_('Partner incomplete'),
_('Please fill in the address field in the partner: %s.') % (partner.name,))
_('Please fill in the Address field in the Partner: %s.') % (partner.name,))
date_due = False
if partner.property_payment_term:
@ -95,7 +95,7 @@ class invoice_create(wizard.interface):
for product_id,factor_id,qty in cr.fetchall():
product = pool.get('product.product').browse(cr, uid, product_id, context2)
if not product:
raise wizard.except_wizard(_('Error'), _('At least on line have no product !'))
raise wizard.except_wizard(_('Error'), _('At least one line has no product !'))
factor_name = ''
factor = pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context2)
if factor.customer_name:
@ -159,7 +159,7 @@ class invoice_create(wizard.interface):
strids = ','.join(map(str, data['ids']))
cr.execute("update account_analytic_line set invoice_id=%%s WHERE account_id = %%s and id IN (%s)" % strids, (last_invoice,account.id,))
pool.get('account.invoice').button_reset_taxes(cr, uid, [last_invoice], context)
return {
'domain': "[('id','in', ["+','.join(map(str,invoices))+"])]",
'name': _('Invoices'),

View File

@ -2,8 +2,8 @@
<openerp>
<data>
<menuitem
id="menu_finance_belgian_statement"
<menuitem
id="menu_finance_belgian_statement"
name="Belgium Statements"
parent="account.menu_finance_legal_statement"/>
@ -34,6 +34,20 @@
type="wizard"
id="account_wizard_vat_declaration"/>
<wizard
string="Partner VAT intra"
model="res.partner"
name="vat.intra.xml"
menu="False"
id="partner_vat_intra"/>
<menuitem
name="Partner VAT intra"
parent="menu_finance_belgian_statement"
action="partner_vat_intra"
type="wizard"
id="partner_intra_vat_menu"/>
<record id="config_call_account_template" model="ir.actions.todo">
<field name="name">Generate Chart of Accounts from a Chart Template</field>
<field name="note">Generate Chart of Accounts from a Chart Template. You will be asked to pass the name of the company, the chart template to follow, the no. of digits to generate the code for your accounts and Bank account, currency to create Journals. Thus,the pure copy of chart Template is generated.

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -21,5 +21,7 @@
##############################################################################
import account_vat_declaration
import partner_vat_listing
import wizard_vat_intra
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,238 @@
##############################################################################
#
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import wizard
import time
import datetime
import pooler
import base64
form_intra = """<?xml version="1.0"?>
<form string="Partner VAT Intra">
<notebook>
<page string="General Information">
<label string="This wizard will create an XML file for Vat Intra" colspan="4"/>
<newline/>
<field name="fyear" />
<newline/>
<field name="mand_id" help="This identifies the representative of the sending company. This is a string of 14 characters"/>
<newline/>
<field name="trimester" help="it will be the first digit of period" />
<newline/>
<field name="test_xml" help="Set the XML output as test file"/>
</page>
<page string="European Countries">
<field name="country_ids" colspan="4" nolabel="1" />
</page>
</notebook>
</form>"""
fields_intra = {
'trimester': {'string': 'Trimester Number', 'type': 'selection', 'selection':[
('1','Jan/Feb/Mar'),
('2','Apr/May/Jun'),
('3','Jul/Aug/Sep'),
('4','Oct/Nov/Dec')], 'required': True},
'test_xml': {'string':'Test XML file', 'type':'boolean'},
'mand_id':{'string':'MandataireId','type':'char','size':'14','required': True},
'fyear': {'string': 'Fiscal Year', 'type': 'many2one', 'relation': 'account.fiscalyear', 'required': True},
'country_ids': {
'string': 'European Countries',
'type': 'many2many',
'relation': 'res.country',
'required': False
},
}
msg_form = """<?xml version="1.0"?>
<form string="Notification">
<separator string="XML File has been Created." colspan="4"/>
<field name="msg" colspan="4" nolabel="1"/>
<field name="file_save" />
</form>"""
msg_fields = {
'msg': {'string':'File created', 'type':'text', 'size':'100','readonly':True},
'file_save':{'string': 'Save File',
'type': 'binary',
'readonly': True,},
}
class parter_vat_intra(wizard.interface):
def _get_europe_country(self, cr, uid, data, context):
country_ids = pooler.get_pool(cr.dbname).get('res.country').search(cr, uid, [('code', 'in', ['AT', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'])])
return {'country_ids': country_ids}
def _create_xml(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
data_cmpny = pool.get('res.users').browse(cr, uid, uid).company_id
data_fiscal = pool.get('account.fiscalyear').browse(cr,uid,data['form']['fyear'])
company_vat = data_cmpny.partner_id.vat
if not company_vat:
raise wizard.except_wizard('Data Insufficient','No VAT Number Associated with Main Company!')
seq_controlref = pool.get('ir.sequence').get(cr, uid,'controlref')
seq_declarantnum = pool.get('ir.sequence').get(cr, uid,'declarantnum')
cref = company_vat + seq_controlref
dnum = cref + seq_declarantnum
if len(data_fiscal.date_start.split('-')[0]) < 4:
raise wizard.except_wizard('Data Insufficient','Trimester year should be length of 4 digits!')
period_trimester = data['form']['trimester'] + data_fiscal.date_start.split('-')[0]
street = zip_city = country = ''
addr = pool.get('res.partner').address_get(cr, uid, [data_cmpny.partner_id.id], ['invoice'])
if addr.get('invoice',False):
ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
zip_city = (ads.city or '') + ' ' + (ads.zip or '')
if zip_city== ' ':
zip_city = ''
if ads.street:
street = ads.street
if ads.street2:
street += ' '
street += ads.street2
if ads.country_id:
country = ads.country_id.code
sender_date = time.strftime('%Y-%m-%d')
data_file = '<?xml version="1.0"?>\n<VatIntra xmlns="http://www.minfin.fgov.be/VatIntra" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" RecipientId="VAT-ADMIN" SenderId="' + str(company_vat) + '"'
data_file +=' ControlRef="' + cref + '" MandataireId="' + data['form']['mand_id'] + '" SenderDate="'+ str(sender_date)+ '"'
if data['form']['test_xml']:
data_file += ' Test="1"'
data_file += ' VersionTech="1.2">'
data_file +='\n\t<AgentRepr DecNumber="1">\n\t\t<CompanyInfo>\n\t\t\t<VATNum>' + str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>'
data_file +='\n\t\t\t<Country>' + str(country) +'</Country>\n\t\t</CompanyInfo>\n\t</AgentRepr>'
data_comp ='\n\t\t<CompanyInfo>\n\t\t\t<VATNum>'+str(company_vat)+'</VATNum>\n\t\t\t<Name>'+str(data_cmpny.name)+'</Name>\n\t\t\t<Street>'+ str(street) +'</Street>\n\t\t\t<CityAndZipCode>'+ str(zip_city) +'</CityAndZipCode>\n\t\t\t<Country>'+ str(country) +'</Country>\n\t\t</CompanyInfo>'
data_period = '\n\t\t<Period>'+ str(period_trimester) +'</Period>' #trimester
error_message = []
seq = 0
amount_sum = 0
p_id_list = pool.get('res.partner').search(cr,uid,[('vat','!=',False)])
if not p_id_list:
raise wizard.except_wizard('Data Insufficient!','No partner has a VAT Number asociated with him.')
nb_period = len(data_fiscal.period_ids)
fiscal_periods = data_fiscal.period_ids
if data['form']['trimester'] == '1':
if nb_period == 12:
start_date = fiscal_periods[0].date_start
end_date = fiscal_periods[2].date_stop
elif nb_period == 4:
start_date = fiscal_periods[0].date_start
end_date = fiscal_periods[0].date_stop
elif data['form']['trimester'] == '2':
if nb_period == 12:
start_date = fiscal_periods[3].date_start
end_date = fiscal_periods[5].date_stop
elif nb_period == 4:
start_date = fiscal_periods[1].date_start
end_date = fiscal_periods[1].date_stop
elif data['form']['trimester'] == '3':
if nb_period == 12:
start_date = fiscal_periods[6].date_start
end_date = fiscal_periods[8].date_stop
elif nb_period == 4:
start_date = fiscal_periods[2].date_start
end_date = fiscal_periods[2].date_stop
elif data['form']['trimester'] == '4':
if nb_period == 12:
start_date = fiscal_periods[9].date_start
end_date = fiscal_periods[11].date_stop
elif nb_period == 4:
start_date = fiscal_periods[3].date_start
end_date = fiscal_periods[3].date_stop
period = "to_date('" + str(start_date) + "','yyyy-mm-dd') and to_date('" + str(end_date) +"','yyyy-mm-dd')"
record = {}
for p_id in p_id_list:
list_partner = []
partner = pool.get('res.partner').browse(cr, uid, p_id)
go_ahead = False
country_code = ''
for ads in partner.address:
if ads.type == 'default' and (ads.country_id and ads.country_id.id in data['form']['country_ids'][0][2]):
go_ahead = True
country_code = ads.country_id.code
break
if not go_ahead:
continue
cr.execute('select sum(debit)-sum(credit) as amount from account_move_line l left join account_account a on (l.account_id=a.id) where a.type in ('"'receivable'"') and l.partner_id=%%s and l.date between %s' % (period,), (p_id,))
res = cr.dictfetchall()
list_partner.append(res[0]['amount'])
list_partner.append('T') #partner.ref ...should be check
list_partner.append(partner.vat)
list_partner.append(country_code)
#...deprecated...
# addr = pool.get('res.partner').address_get(cr, uid, [partner.id], ['invoice'])
# if addr.get('invoice',False):
# ads = pool.get('res.partner.address').browse(cr,uid,[addr['invoice']])[0]
#
# if ads.country_id:
# code_country = ads.country_id.code
# list_partner.append(code_country)
# else:
# error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no country associated with its Invoice address!')
# if len(list_partner)<4:
# list_partner.append('')
# error_message.append('Data Insufficient! : '+ 'The Partner "'+partner.name + '"'' has no Invoice address!')
# list_partner.append(code_country or 'not avail')
record[p_id] = list_partner
if len(error_message):
data['form']['msg'] = 'Exception : \n' +'-'*50+'\n'+ '\n'.join(error_message)
return data['form']
data_clientinfo = ''
for r in record:
seq += 1
amt = record[r][0] or 0
amt = int(amt * 100)
amount_sum += amt
data_clientinfo +='\n\t\t<ClientList SequenceNum="'+str(seq)+'">\n\t\t\t<CompanyInfo>\n\t\t\t\t<VATNum>'+record[r][2] +'</VATNum>\n\t\t\t\t<Country>'+record[r][3] +'</Country>\n\t\t\t</CompanyInfo>\n\t\t\t<Amount>'+str(amt) +'</Amount>\n\t\t\t<Period>'+str(period_trimester) +'</Period>\n\t\t\t<Code>'+str(record[r][1]) +'</Code>\n\t\t</ClientList>'
amount_sum = int(amount_sum)
data_decl = '\n\t<DeclarantList SequenceNum="1" DeclarantNum="'+ dnum + '" ClientNbr="'+ str(seq) +'" AmountSum="'+ str(amount_sum) +'" >'
data_file += str(data_decl) + str(data_comp) + str(data_period) + str(data_clientinfo) + '\n\t</DeclarantList>\n</VatIntra>'
data['form']['msg'] = 'Save the File with '".xml"' extension.'
data['form']['file_save'] = base64.encodestring(data_file)
return data['form']
states = {
'init': {
'actions': [_get_europe_country],
'result': {'type': 'form', 'arch':form_intra, 'fields': fields_intra, 'state':[('end','Cancel'),('go','Create XML') ]}
},
'go': {
'actions': [_create_xml],
'result': {'type':'form', 'arch':msg_form, 'fields':msg_fields, 'state':[('end','Ok')]},
}
}
parter_vat_intra('vat.intra.xml')

View File

@ -1,7 +1,6 @@
<?xml version="1.0"?>
<openerp>
<data>
<wizard
string="Create DTA"
model="payment.order"

View File

@ -281,6 +281,7 @@ class product_pricelist_version(osv.osv):
where.append("((date_end>='%s') or (date_end is null))" % (pricelist_version.date_start,))
if pricelist_version.date_end:
where.append("((date_start<='%s') or (date_start is null))" % (pricelist_version.date_end,))
cursor.execute('SELECT id ' \
'FROM product_pricelist_version ' \
'WHERE '+' and '.join(where) + (where and ' and ' or '')+
@ -294,7 +295,7 @@ class product_pricelist_version(osv.osv):
return True
_constraints = [
(_check_date, 'You can not have 2 pricelist version that overlaps!',
(_check_date, 'You cannot have 2 pricelist versions that overlap!',
['date_start', 'date_end'])
]

View File

@ -24,6 +24,7 @@ from lxml import etree
from mx import DateTime
from mx.DateTime import now
import time
from tools.translate import _
from osv import fields, osv
from tools.translate import _
@ -288,6 +289,7 @@ class task(osv.osv):
'delay_hours': fields.function(_hours_get, method=True, string='Delay Hours', multi='hours', store=True, help="Computed as: Total Time - Estimated Time. It gives the difference of the time estimated by the project manager and the real time to close the task."),
'user_id': fields.many2one('res.users', 'Assigned to'),
'delegated_user_id': fields.related('child_ids','user_id',type='many2one', relation='res.users', string='Delegated To'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'work_ids': fields.one2many('project.task.work', 'task_id', 'Work done'),
}
@ -336,7 +338,7 @@ class task(osv.osv):
if project:
if project.warn_manager and project.manager and (project.manager.id != uid):
request.create(cr, uid, {
'name': "Task '%s' closed" % task.name,
'name': _("Task '%s' closed") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,
@ -346,7 +348,12 @@ class task(osv.osv):
})
self.write(cr, uid, [task.id], {'state': 'done', 'date_close':time.strftime('%Y-%m-%d %H:%M:%S'), 'remaining_hours': 0.0})
if task.parent_id and task.parent_id.state in ('pending','draft'):
self.do_reopen(cr, uid, [task.parent_id.id])
reopen = True
for child in task.parent_id.child_ids:
if child.id != task.id and child.state not in ('done','cancelled'):
reopen = False
if reopen:
self.do_reopen(cr, uid, [task.parent_id.id])
return True
def do_reopen(self, cr, uid, ids, *args):
@ -356,7 +363,7 @@ class task(osv.osv):
project = task.project_id
if project and project.warn_manager and project.manager.id and (project.manager.id != uid):
request.create(cr, uid, {
'name': "Task '%s' set in progress" % task.name,
'name': _("Task '%s' set in progress") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,
@ -375,7 +382,7 @@ class task(osv.osv):
project = task.project_id
if project.warn_manager and project.manager and (project.manager.id != uid):
request.create(cr, uid, {
'name': "Task '%s' cancelled" % task.name,
'name': _("Task '%s' cancelled") % task.name,
'state': 'waiting',
'act_from': uid,
'act_to': project.manager.id,

View File

@ -311,10 +311,11 @@
<tree string="Delegated tasks">
<field name="name"/>
<field name="user_id"/>
<field name="date_deadline"/>
<field name="planned_hours" widget="float_time"/>
<field name="effective_hours" widget="float_time"/>
<field name="state"/>
<field name="effective_hours" widget="float_time"/>
<field name="progress" widget="progressbar"/>
<field name="remaining_hours" widget="float_time"/>
<field name="date_deadline"/>
</tree>
</field>
<field colspan="4" name="parent_id"/>
@ -359,6 +360,28 @@
</field>
</record>
<record id="my_pending_task" model="ir.ui.view">
<field name="name">my.pending.task.tree</field>
<field name="model">project.task</field>
<field name="type">tree</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<tree colors="grey:state in ('cancel','done');blue:remaining_hours&lt;0;red:bool(date_deadline) &amp; (date_deadline&lt;current_date) &amp; (state in ('draft','open'))" string="Tasks">
<field name="sequence"/>
<field name="name"/>
<field name="project_id"/>
<field name="delegated_user_id"/>
<field name="date_deadline"/>
<field name="planned_hours" sum="Planned" widget="float_time"/>
<field name="delay_hours" sum="Delay" widget="float_time"/>
<field name="progress" widget="progressbar"/>
<field name="priority"/>
<field name="state"/>
<field name="remaining_hours" invisible="1"/>
</tree>
</field>
</record>
<record id="view_task_calendar" model="ir.ui.view">
<field name="name">project.task.calendar</field>
<field name="model">project.task</field>
@ -423,6 +446,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph</field>
<field name="domain">[('user_id', '=', uid),('state','=','pending')]</field>
<field name="view_id" ref="my_pending_task"/>
</record>
<menuitem action="action_view_task5_pending" id="menu_tasks_yours_pending" parent="menu_action_view_task4"/>

View File

@ -23,6 +23,7 @@
import wizard
from tools import email_send as email
import pooler
from tools.translate import _
ask_form = """<?xml version="1.0" ?>
<form string="Delegate this task to a user">
@ -30,7 +31,7 @@ ask_form = """<?xml version="1.0" ?>
<field name="user_id" colspan="4"/>
<field name="planned_hours" colspan="4" widget="float_time"/>
<field name="name" colspan="4"/>
<field name="include_info"/>
<field name="new_task_description"/>
<separator string="Validation Task" colspan="4"/>
<field name="planned_hours_me" colspan="4" widget="float_time"/>
<field name="prefix" colspan="4"/>
@ -41,7 +42,7 @@ ask_fields = {
'name': {'string': 'Delegated Title', 'type': 'char', 'required': 'True', 'size':64, 'help':"New title of the task delegated to the user."},
'prefix': {'string': 'Your Task Title', 'type': 'char', 'required': 'True', 'size':64, 'help':"New title of your own task to validate the work done."},
'user_id': {'string':'Assign To', 'type':'many2one', 'relation': 'res.users', 'required':'True', 'help':"User you want to delegate this task to."},
'include_info': {'string':'Copy Description', 'type':'boolean', 'help':"Reinclude the description of the task in the task of the user."},
'new_task_description': {'string':'New Task Description', 'type':'text', 'help':"Reinclude the description of the task in the task of the user."},
'planned_hours': {'string':'Planned Hours', 'type':'float', 'widget':'float_time', 'help':"Estimated time to close this task by the delegated user."},
'planned_hours_me': {'string':'Hours to Validate', 'type':'float', 'widget':'float_time', 'help':"Estimated time for you to validate the work done by the user to whom you delegate this task."},
'state': {'string':'Validation State', 'type':'selection', 'selection': [('pending','Pending'),('done','Done')], 'help':"New state of your own task. Pending will be reopened automatically when the delegated task is closed.", 'required':True},
@ -51,7 +52,6 @@ class wizard_delegate(wizard.interface):
def _do_assign(self, cr, uid, data, context):
task_obj = pooler.get_pool(cr.dbname).get('project.task')
task = task_obj.browse(cr, uid, data['id'], context)
newname = task.name
newname = data['form']['prefix'] or ''
task_obj.copy(cr, uid, data['id'], {
'name': data['form']['name'],
@ -60,7 +60,7 @@ class wizard_delegate(wizard.interface):
'remaining_hours': data['form']['planned_hours'],
'parent_id': data['id'],
'state': 'open',
'description': data['form']['include_info'] and task.description or '',
'description': data['form']['new_task_description'] or '',
'child_ids': [],
'work_ids': []
})
@ -77,13 +77,17 @@ class wizard_delegate(wizard.interface):
def _ask_auto_complete(self, cr, uid, data, context):
task_obj = pooler.get_pool(cr.dbname).get('project.task')
task = task_obj.browse(cr, uid, data['id'], context)
if task.name.startswith(_('CHECK: ')):
newname = task.name.strip(_('CHECK: '))
else:
newname = task.name or ''
return {
'name':task.name,
'name': newname,
'user_id': False,
'planned_hours': task.remaining_hours,
'planned_hours_me': 1.0,
'prefix': 'CHECK: '+ (task.name or ''),
'include_info': 1,
'prefix': _('CHECK: ')+ newname,
'new_task_description': task.description,
'state': 'pending'
}

View File

@ -125,14 +125,13 @@ class project_gtd_timebox(osv.osv):
if rec.col_planned_hours:
res['arch'] += '<field name="planned_hours" widget="float_time" sum="Est. Hours"/>\n'
if rec.col_effective_hours:
res['arch'] += '<field name="effective_hours" widget="float_time" sum="Eff. Hours"/>\n'
res['arch'] += '<field name="effective_hours" widget="float_time" sum="%s"/>\n' % (_('Eff. Hours'),)
res['arch'] += """
<field name="state" readonly="1"/>
</tree>
</field>
</page>
"""
res['arch']+="""
</notebook>
</form>

View File

@ -77,27 +77,32 @@ class project_work(osv.osv):
def write(self, cr, uid, ids, vals, context=None):
vals_line = {}
for task in self.pool.get('project.task.work').browse(cr, uid, ids):
line_id = task.hr_analytic_timesheet_id
if line_id:
obj = self.pool.get('hr.analytic.timesheet')
if 'name' in vals:
vals_line['name'] = '%s: %s' % (tools.ustr(task.name), tools.ustr(vals['name']) or '/')
if 'user_id' in vals:
vals_line['user_id'] = vals['user_id']
if 'date' in vals:
vals_line['date'] = vals['date'][:10]
if 'hours' in vals:
vals_line['unit_amount'] = vals['hours']
vals_line['amount'] = (-1) * vals['hours'] * obj.browse(cr, uid, line_id).product_id.standard_price
obj.write(cr, uid, [line_id], vals_line, {})
task = self.pool.get('project.task.work').browse(cr, uid, ids)[0]
line_id = task.hr_analytic_timesheet_id
# in case,if a record is deleted from timesheet,but we change it from tasks!
list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, [])
if line_id in list_avail_ids:
obj = self.pool.get('hr.analytic.timesheet')
if 'name' in vals:
vals_line['name'] = '%s: %s' % (tools.ustr(task.name), tools.ustr(vals['name']) or '/')
if 'user_id' in vals:
vals_line['user_id'] = vals['user_id']
if 'date' in vals:
vals_line['date'] = vals['date'][:10]
if 'hours' in vals:
vals_line['unit_amount'] = vals['hours']
vals_line['amount'] = (-1) * vals['hours'] * obj.browse(cr, uid, line_id).product_id.standard_price
obj.write(cr, uid, [line_id], vals_line, {})
return super(project_work,self).write(cr, uid, ids, vals, context)
def unlink(self, cr, uid, ids, *args, **kwargs):
for timesheet_id in self.pool.get('project.task.work').browse(cr, uid, ids):
if timesheet_id.hr_analytic_timesheet_id:
obj = self.pool.get('hr.analytic.timesheet').unlink(cr, uid, [timesheet_id.hr_analytic_timesheet_id], *args, **kwargs)
timesheet_id = self.pool.get('project.task.work').browse(cr, uid, ids)[0].hr_analytic_timesheet_id
# delete entry from timesheet too while deleting entry to task.
list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, [])
if timesheet_id in list_avail_ids:
obj = self.pool.get('hr.analytic.timesheet').unlink(cr, uid, [timesheet_id], *args, **kwargs)
return super(project_work,self).unlink(cr, uid, ids, *args, **kwargs)
_columns={

View File

@ -482,8 +482,10 @@ class purchase_order_line(osv.osv):
seller_delay = s.delay
if s.name.id == partner_id:
seller_delay = s.delay
if qty<s.qty:
qty = s.qty
temp_qty = s.qty # supplier _qty assigned to temp
if qty < temp_qty: # If the supplier quantity is greater than entered from user, set minimal.
qty = temp_qty
dt = (DateTime.now() + DateTime.RelativeDateTime(days=seller_delay or 0.0)).strftime('%Y-%m-%d %H:%M:%S')
prod_name = prod.partner_ref

View File

@ -69,8 +69,8 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Aged Receivable">
<field name="name"/>
<field name="balance"/>
<field name="name" select="1"/>
<field name="balance" select="2"/>
</tree>
</field>
</record>
@ -81,5 +81,38 @@
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
</record>
<!-- Created Invoice for random activities of service dashboard -->
<record id="board_view_created_invoice" model="ir.ui.view">
<field name="name">report.invoice.created.tree</field>
<field name="model">report.invoice.created</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree colors="blue:state=='draft'" string="Invoices">
<field name="create_date" select="1"/>
<field name="name" select="1"/>
<field name="type"/>
<field name="number"/>
<field name="partner_id"/>
<field name="amount_untaxed" sum="Untaxed Amount"/>
<field name="amount_total" sum="Total Amount"/>
<field name="currency_id"/>
<field name="date_invoice"/>
<field name="date_due" select="1"/>
<field name="residual"/>
<field name="state" select="2"/>
<field name="origin"/>
</tree>
</field>
</record>
<record id="action_view_created_invoice_dashboard" model="ir.actions.act_window">
<field name="name">Invoices Created Within Past 15 Days</field>
<field name="res_model">report.invoice.created</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="board_view_created_invoice"/>
</record>
</data>
</openerp>

View File

@ -106,5 +106,109 @@ class report_crm_case_categ(osv.osv):
)""")
report_crm_case_categ()
class report_crm_case_section(osv.osv):
_name = "report.crm.case.section"
_description = "Cases by Section"
_auto = False
def _get_data(self, cr, uid, ids, field_name, arg, context={}):
res = {}
state_perc = 0.0
avg_ans = 0.0
for case in self.browse(cr, uid, ids, context):
if field_name != 'avg_answers':
state = field_name[5:]
cr.execute("select count(*) from crm_case where section_id =%s and state='%s'"%(case.section_id.id,state))
state_cases = cr.fetchone()[0]
perc_state = (state_cases / float(case.nbr_cases) ) * 100
res[case.id] = perc_state
else:
cr.execute('select count(*) from crm_case_log l where l.section_id=%s'%(case.section_id.id))
logs = cr.fetchone()[0]
avg_ans = logs / case.nbr_cases
res[case.id] = avg_ans
return res
_columns = {
'name': fields.date('Month', readonly=True),
# 'user_id':fields.many2one('res.users', 'User', readonly=True),
'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
'nbr_cases': fields.integer('# of Cases', readonly=True),
'avg_answers': fields.function(_get_data,string='Avg. Answers', method=True,type="integer"),
'perc_done': fields.function(_get_data,string='%Done', method=True,type="float"),
'perc_cancel': fields.function(_get_data,string='%Cancel', method=True,type="float"),
'delay_close': fields.char('Delay to close', size=20, readonly=True),
}
_order = 'name desc, section_id'
def init(self, cr):
cr.execute("""
create or replace view report_crm_case_section as (
select
min(c.id) as id,
to_char(c.create_date, 'YYYY-MM-01') as name,
c.section_id as section_id,
count(*) as nbr_cases,
0 as avg_answers,
0.0 as perc_done,
0.0 as perc_cancel,
to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
from
crm_case c
group by to_char(c.create_date, 'YYYY-MM-01'),c.section_id
)""")
report_crm_case_section()
class report_crm_case_service_dashboard(osv.osv):
_name = "report.crm.case.service.dashboard"
_description = "Report of Closed and Open CRM Cases within past 15 days"
_auto = False
_columns = {
'date': fields.datetime('Date', readonly=True),
'date_deadline': fields.datetime('Deadline', readonly=True),
'name': fields.char('Description', size=64, readonly=True),
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
'user_id': fields.many2one('res.users', 'Responsible', readonly=True),
'priority': fields.char('Priority', size=64, readonly=True),
'planned_revenue': fields.float('Planned Revenue', readonly=True),
'planned_cost': fields.float('Planned Costs', readonly=True),
'state': fields.selection(AVAILABLE_STATES, 'Status', size=16, readonly=True),
'date_closed' : fields.datetime('Date Closed', readonly=True),
'create_date' : fields.datetime('Create Date', readonly=True)
}
_order = 'date_closed, create_date'
def init(self, cr):
cr.execute("""create or replace view report_crm_case_service_dashboard as (
select
cse.id as id, cse.date as date, cse.date_deadline as date_deadline,
cse.name as name, cse.partner_id as partner_id, cse.user_id as user_id,
cse.priority as priority, cse.planned_revenue as planned_revenue,
cse.planned_cost as planned_cost, cse.state as state,
cse.date_closed as date_closed, cse.create_date as create_date
from
crm_case cse
where
((to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE)
AND
(to_date(to_char(cse.date_closed, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15))
AND
cse.state='done')
OR
((to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE)
AND
(to_date(to_char(cse.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15))
AND
cse.state='open')
)""")
report_crm_case_service_dashboard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -155,5 +155,104 @@
<act_window domain="[('section_id', '=', active_id)]" id="act_crm_case_section_2_report_crm_case_categ" name="Monthly cases by section" res_model="report.crm.case.categ" src_model="crm.case.section"/>
<!-- Cases by Section -->
<record id="view_report_crm_case_section_tree" model="ir.ui.view">
<field name="name">report.crm.case.section.tree</field>
<field name="model">report.crm.case.section</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Cases by Section">
<field name="name" select="1"/>
<field name="section_id" select="1"/>
<field name="nbr_cases" select="1"/>
<field name="avg_answers"/>
<field name="perc_done" select="2"/>
<field name="perc_cancel" select="2"/>
<field name="delay_close"/>
</tree>
</field>
</record>
<record id="view_report_crm_case_section_graph" model="ir.ui.view">
<field name="name">report.crm.case.section.graph</field>
<field name="model">report.crm.case.section</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph orientation="horizontal" string="Cases by Section" type="bar">
<field name="name"/>
<field name="nbr_cases" operator="+"/>
</graph>
</field>
</record>
<record id="action_report_crm_case_section_tree" model="ir.actions.act_window">
<field name="name">Cases by Section</field>
<field name="res_model">report.crm.case.section</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
</record>
<!-- Closed & Open CRM Case view for Random Activities dashboard -->
<record id="board_view_crm_case_open_dashboard_tree" model="ir.ui.view">
<field name="name">report.crm.case.service.dashboard.tree</field>
<field name="model">report.crm.case.service.dashboard</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="CRM Cases">
<field name="create_date" select="1"/>
<field name="date" select="1"/>
<field name="date_deadline"/>
<field name="name" select="1"/>
<field name="partner_id" select="2"/>
<field name="user_id" select="2"/>
<field name="priority"/>
<field name="planned_revenue" sum="Planned revenue"/>
<field name="planned_cost" sum="Planned costs"/>
<field name="state" />
</tree>
</field>
</record>
<record id="board_view_crm_case_done_dashboard_tree" model="ir.ui.view">
<field name="name">report.crm.case.service.dashboard.tree</field>
<field name="model">report.crm.case.service.dashboard</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="CRM Cases">
<field name="date_closed" select="1"/>
<field name="date"/>
<field name="date_deadline"/>
<field name="name"/>
<field name="partner_id" select="2"/>
<field name="user_id" select="2"/>
<field name="priority"/>
<field name="planned_revenue" sum="Planned revenue"/>
<field name="planned_cost" sum="Planned costs"/>
<field name="state" />
</tree>
</field>
</record>
<record id="action_view_closed_crm_case_dashboard" model="ir.actions.act_window">
<field name="name">Closed CRM Cases Within Past 15 Days</field>
<field name="res_model">report.crm.case.service.dashboard</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="board_view_crm_case_done_dashboard_tree"/>
<field name="domain">[('state','=','done')]</field>
</record>
<record id="action_view_open_crm_case_dashboard" model="ir.actions.act_window">
<field name="name">Open CRM Cases Within Past 15 Days</field>
<field name="res_model">report.crm.case.service.dashboard</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="board_view_crm_case_open_dashboard_tree"/>
<field name="domain">[('state','=','open')]</field>
</record>
</data>
</openerp>

View File

@ -110,5 +110,88 @@ class report_sale_order_category(osv.osv):
""")
report_sale_order_category()
class report_turnover_per_month(osv.osv):
_name = "report.turnover.per.month"
_description = "Turnover Per Month"
_auto = False
_columns = {
'name': fields.date('Month', readonly=True),
'turnover': fields.float('Total Turnover', readonly=True),
}
def init(self, cr):
cr.execute("""
create or replace view report_turnover_per_month as (
select min(am.id) as id, sum(credit) as turnover,to_char(am.date, 'YYYY-MM-01') as name from account_move_line am
where am.account_id in (select distinct(account_id) from account_invoice_line)
and
am.move_id in(select distinct(aw.move_id) from account_invoice aw,account_invoice_line l where l.invoice_id=aw.id)
group by to_char(am.date, 'YYYY-MM-01')
)
""")
report_turnover_per_month()
class report_turnover_per_product(osv.osv):
_name = "report.turnover.per.product"
_description = "Turnover Per Product"
_auto = False
_rec_name = 'product_id'
_columns = {
'product_id': fields.many2one('product.product','Product', readonly=True),
'turnover': fields.float('Total Turnover', readonly=True),
}
def init(self, cr):
cr.execute("""
create or replace view report_turnover_per_product as (
select min(am.id) as id, sum(credit) as turnover,am.product_id as product_id
from account_move_line am
group by am.product_id
)
""")
report_turnover_per_product()
class report_sale_order_created(osv.osv):
_name = "report.sale.order.created"
_description = "Report of Created Sale Order"
_auto = False
_columns = {
'date_order':fields.date('Date Ordered', readonly=True),
'name': fields.char('Order Reference', size=64, readonly=True),
'partner_id':fields.many2one('res.partner', 'Customer', readonly=True),
'partner_shipping_id':fields.many2one('res.partner.address', 'Shipping Address', readonly=True),
'amount_untaxed': fields.float('Untaxed Amount', readonly=True),
'state': fields.selection([
('draft','Quotation'),
('waiting_date','Waiting Schedule'),
('manual','Manual In Progress'),
('progress','In Progress'),
('shipping_except','Shipping Exception'),
('invoice_except','Invoice Exception'),
('done','Done'),
('cancel','Cancel')
], 'Order State', readonly=True),
'create_date' : fields.datetime('Create Date', readolnly=True)
}
_order = 'create_date'
def init(self, cr):
cr.execute("""create or replace view report_sale_order_created as (
select
sale.id as id, sale.date_order as date_order, sale.name as name,
sale.partner_id as partner_id,
sale.partner_shipping_id as partner_shipping_id,
sale.amount_untaxed as amount_untaxed, sale.state as state,
sale.create_date as create_date
from
sale_order sale
where
(to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') <= CURRENT_DATE)
AND
(to_date(to_char(sale.create_date, 'YYYY-MM-dd'),'YYYY-MM-dd') > (CURRENT_DATE-15))
)""")
report_sale_order_created()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -166,11 +166,106 @@
<field name="name">Sales by State</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_mode">graph,tree,form</field>
<field name="view_id" ref="view_so_pipeline_graph"/>
<field name="domain">[('state','&lt;&gt;','done')]</field>
</record>
<!-- Turnover Per Month -->
<record model="ir.ui.view" id="view_turnover_month_tree">
<field name="name">report.turnover.per.month.tree</field>
<field name="model">report.turnover.per.month</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Turnover Per Month">
<field name="name" select="1"/>
<field name="turnover" select="2"/>
</tree>
</field>
</record>
<record id="view_turnover_month_graph" model="ir.ui.view">
<field name="name">report.turnover.per.month.graph</field>
<field name="model">report.turnover.per.month</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Turnover Per Month" type="bar">
<field name="name" />
<field name="turnover" />
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_turnover_month_tree">
<field name="type">ir.actions.act_window</field>
<field name="name">Turnover Per Month</field>
<field name="res_model">report.turnover.per.month</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_turnover_month_tree"/>
</record>
<!-- Turnover Per Product -->
<record model="ir.ui.view" id="view_turnover_product_tree">
<field name="name">report.turnover.per.product.tree</field>
<field name="model">report.turnover.per.product</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Turnover Per Product">
<field name="product_id" select="1"/>
<field name="turnover" select="2"/>
</tree>
</field>
</record>
<record id="view_turnover_product_graph" model="ir.ui.view">
<field name="name">report.turnover.per.product.graph</field>
<field name="model">report.turnover.per.product</field>
<field name="type">graph</field>
<field name="arch" type="xml">
<graph string="Turnover Per Product" type="bar">
<field name="product_id" />
<field name="turnover" />
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_turnover_product_tree">
<field name="type">ir.actions.act_window</field>
<field name="name">Turnover Per Product</field>
<field name="res_model">report.turnover.per.product</field>
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="view_id" ref="view_turnover_product_tree"/>
</record>
<!-- Created Sale orders for random activities dashboard -->
<record id="board_view_created_sale_order" model="ir.ui.view">
<field name="name">report.sale.order.created.tree</field>
<field name="model">report.sale.order.created</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Created Sales orders">
<field name="create_date" select="1"/>
<field name="date_order"/>
<field name="name" string="Reference" select="1"/>
<field name="partner_id" select="2"/>
<field name="partner_shipping_id"/>
<field name="amount_untaxed"/>
<field name="state" select="1"/>
</tree>
</field>
</record>
<record id="action_view_created_sale_order_dashboard" model="ir.actions.act_window">
<field name="name">Created Sale Orders</field>
<field name="res_model">report.sale.order.created</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="board_view_created_sale_order"/>
</record>
</data>
</openerp>

View File

@ -27,7 +27,7 @@
'category': 'Generic Modules/Projects & Services',
'description': """Gives statistics on tasks by user on projects to check the pipeline of users.""",
'author': 'Tiny',
'depends': ['base', 'project'],
'depends': ['base', 'project','hr_timesheet_sheet'],
'init_xml': [],
'update_xml': ['security/ir.model.access.csv', 'report_task_view.xml'],
'installable': True,

View File

@ -21,6 +21,7 @@
##############################################################################
from osv import fields,osv
import mx.DateTime
class report_task_user_pipeline_open (osv.osv):
_name = "report.task.user.pipeline.open"
@ -58,7 +59,100 @@ class report_task_user_pipeline_open (osv.osv):
''')
report_task_user_pipeline_open()
class report_closed_task(osv.osv):
_name = "report.closed.task"
_description = "Closed Task Report"
_auto = False
_columns = {
'sequence': fields.integer('Sequence', readonly=True),
'name': fields.char('Task summary', size=128, readonly=True),
'project_id': fields.many2one('project.project', 'Project', readonly=True),
'user_id': fields.many2one('res.users', 'Assigned to', readonly=True),
'date_deadline': fields.datetime('Deadline', readonly=True),
'planned_hours': fields.float('Planned Hours', readonly=True),
'delay_hours': fields.float('Delay Hours', readonly=True),
'progress': fields.float('Progress (%)', readonly=True),
'priority' : fields.selection([('4','Very Low'), ('3','Low'), ('2','Medium'), ('1','Urgent'), ('0','Very urgent')], 'Importance', readonly=True),
'state': fields.selection([('draft', 'Draft'),('open', 'In Progress'),('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'Status', readonly=True),
'remaining_hours': fields.float('Remaining Hours', readonly=True),
'date_close' : fields.datetime('Date Closed', readonly=True)
}
def init(self, cr):
cr.execute('''
create or replace view report_closed_task as (
select
tsk.id as id, tsk.sequence as sequence, tsk.name as name,
tsk.project_id as project_id, tsk.user_id as user_id,
tsk.date_deadline as date_deadline, tsk.planned_hours as planned_hours,
tsk.delay_hours as delay_hours, tsk.progress as progress,
tsk.priority as priority, tsk.state as state,
tsk.remaining_hours as remaining_hours, tsk.date_close as date_close
from
project_task tsk
where
(tsk.date_close <= CURRENT_DATE AND tsk.date_close > (CURRENT_DATE-15))
)
''')
report_closed_task()
class report_timesheet_task_user(osv.osv):
_name = "report.timesheet.task.user"
_auto = False
_order = "name"
def _get_task_hours(self, cr, uid, ids, name,args,context):
result = {}
for record in self.browse(cr, uid, ids,context):
last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
task_obj=self.pool.get('project.task.work')
task_ids = task_obj.search(cr,uid,[('user_id','=',record.user_id.id),('date','>=',record.name),('date','<=',last_date.strftime('%Y-%m-%d'))])
tsk_hrs = task_obj.read(cr,uid,task_ids,['hours','date','user_id'])
total = 0.0
for hrs in tsk_hrs:
total += hrs['hours']
result[record.id] = total
return result
def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
result = {}
sum = 0.0
for record in self.browse(cr, uid, ids, context):
last_date = mx.DateTime.strptime(record.name, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
obj=self.pool.get('hr_timesheet_sheet.sheet.day')
sheet_ids = obj.search(cr,uid,[('sheet_id.user_id','=',record.user_id.id),('name','>=',record.name),('name','<=',last_date.strftime('%Y-%m-%d'))])
data_days = obj.read(cr,uid,sheet_ids,['name','sheet_id.user_id','total_attendance'])
total = 0.0
for day_attendance in data_days:
total += day_attendance['total_attendance']
result[record.id] = total
return result
_columns = {
'name': fields.date('Month',readonly=True),
'user_id': fields.many2one('res.users', 'User',readonly=True),
'timesheet_hrs': fields.function(get_hrs_timesheet, method=True, string="Timesheet Hours"),
'task_hrs': fields.function(_get_task_hours, method=True, string="Task Hours"),
}
def init(self, cr):
cr.execute(""" create or replace view report_timesheet_task_user as (
select
((r.id*12)+to_number(months.m_id,'99'))::integer as id,
months.name as name,
r.id as user_id
from res_users r,
(select to_char(p.date,'YYYY-MM-01') as name,
to_char(p.date,'MM') as m_id
from project_task_work p
union
select to_char(h.name,'YYYY-MM-01') as name,
to_char(h.name,'MM') as m_id
from hr_timesheet_sheet_sheet_day h) as months) """)
report_timesheet_task_user()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -58,5 +58,61 @@
<menuitem id="next_id_57" name="Reporting" parent="project.menu_main" sequence="50"/>
<menuitem id="next_id_58" name="All Months" parent="next_id_57"/><menuitem action="action_project_task" id="menu_project_task_user_tree" parent="next_id_58"/>
<!-- Closed Task in Random Acitivities dashboard -->
<record id="view_task_closed_board_tree" model="ir.ui.view">
<field name="name">report.closed.task.tree</field>
<field name="model">report.closed.task</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Closed Tasks">
<field name="date_close" />
<field name="sequence"/>
<field name="name" select="1"/>
<field name="project_id" select="1"/>
<field name="user_id" select="1"/>
<field name="date_deadline"/>
<field name="planned_hours" sum="Planned" widget="float_time"/>
<field name="delay_hours" sum="Delay" widget="float_time"/>
<field name="progress" widget="progressbar"/>
<field name="priority"/>
<field name="state"/>
<field name="remaining_hours" />
</tree>
</field>
</record>
<record id="action_closed_task_board" model="ir.actions.act_window">
<field name="name">Task Closed Within Past 15 Days</field>
<field name="res_model">report.closed.task</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_task_closed_board_tree"/>
</record>
<!-- Report for Users' Timesheet and Task Hours per Month -->
<record id="view_report_timesheet_task_user_tree" model="ir.ui.view">
<field name="name">report.timesheet.task.user.tree</field>
<field name="model">report.timesheet.task.user</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Timesheet/Task hours Report Per Month" >
<field name="name" select="1"/>
<field name="user_id" select="1"/>
<field name="timesheet_hrs" widget="float_time" />
<field name="task_hrs" widget="float_time"/>
</tree>
</field>
</record>
<record id="action_report_timesheet_task_user" model="ir.actions.act_window">
<field name="name">Timesheet / Task Hours Per Month</field>
<field name="res_model">report.timesheet.task.user</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
</record>
<menuitem id="menu_timesheet_task_user" parent="hr.menu_hr_reporting" action="action_report_timesheet_task_user"/>
</data>
</openerp>

View File

@ -113,7 +113,6 @@ class report_timesheet_account_date(osv.osv):
report_timesheet_account_date()
class report_timesheet_invoice(osv.osv):
_name = "report_timesheet.invoice"
_description = "Costs to invoice"
@ -193,13 +192,49 @@ class report_random_timsheet(osv.osv):
where
(dept.id = dept_user.department_id AND dept_user.user_id=line.user_id AND line.user_id is not null)
AND (dept.manager_id = """ + str(uid) + """ )
AND (line.date < CURRENT_DATE AND line.date >= (CURRENT_DATE-3))
ORDER BY line.name LIMIT 10
AND (line.date <= CURRENT_DATE AND line.date > (CURRENT_DATE-3))
LIMIT 10
)
""" )
report_random_timsheet()
class random_timesheet_lines(osv.osv):
_name = "random.timesheet.lines"
_description = "Random Timesheet Lines"
_auto = False
_columns = {
'date': fields.date('Date', readonly=True),
'name': fields.char('Description', size=64, readonly=True),
'user_id' : fields.many2one('res.users', 'User', readonly=True),
'quantity' : fields.float('Quantity', readonly=True),
'product_id' : fields.many2one('product.product', 'Product', readonly=True),
'analytic_account_id' : fields.many2one('account.analytic.account','Analytic Account', readonly=True),
'uom_id' : fields.many2one('product.uom', 'UoM', readonly=True),
'amount' : fields.float('Amount', readonly=True),
'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Invoicing', readonly=True),
'general_account_id' : fields.many2one('account.account', 'General Account', readonly=True)
}
_order = "date desc"
def init(self, cr):
cr.execute("""create or replace view random_timesheet_lines as (
select
line.id as id, line.date as date, line.name as name, line.unit_amount as quantity,
line.product_id as product_id, line.account_id as analytic_account_id,
line.product_uom_id as uom_id, line.amount as amount, line.to_invoice as to_invoice,
line.general_account_id as general_account_id, line.user_id as user_id
from
account_analytic_line line
where
(line.date <= CURRENT_DATE AND line.date > (CURRENT_DATE-15))
)
""" )
random_timesheet_lines()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -296,12 +296,43 @@
</record>
<record model="ir.actions.act_window" id="action_random_timesheet_board">
<field name="type">ir.actions.act_window</field>
<field name="name">Random Timesheet</field>
<field name="res_model">report.random.timesheet</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_random_timesheet_tree"/>
</record>
<!-- Random Timesheet Lines of random activities -->
<record model="ir.ui.view" id="view_random_timesheet_lines_tree">
<field name="name">random.timesheet.lines.tree</field>
<field name="model">random.timesheet.lines</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Random Timesheets Lines">
<field name="date" select="1"/>
<field name="user_id" />
<field name="name" select="1"/>
<field name="quantity" />
<field name="product_id" select="1"/>
<field name="analytic_account_id" select="1"/>
<field name="uom_id" />
<field name="amount" />
<field name="to_invoice" select="1"/>
<field name="general_account_id" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_random_timesheet_lines_board">
<field name="type">ir.actions.act_window</field>
<field name="name">Random Timesheet Lines</field>
<field name="res_model">random.timesheet.lines</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_random_timesheet_lines_tree"/>
</record>
</data>
</openerp>

View File

@ -17,3 +17,5 @@
"access_sale_order_line_mrp_user","sale.order.line mrp worker","model_sale_order_line","mrp.group_mrp_user",1,0,0,0
"access_sale_order_stock_worker","sale.order stock worker","model_sale_order","stock.group_stock_user",1,0,0,0
"access_sale_order_line_stock_worker","sale.order.line stock worker","model_sale_order_line","stock.group_stock_user",1,0,0,0
"access_sale_order_manager","sale.order.manager","model_sale_order","group_sale_manager",1,1,1,1
"access_sale_order_line_manager","sale.order.line.manager","model_sale_order_line","group_sale_manager",1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
17 access_sale_order_line_mrp_user sale.order.line mrp worker model_sale_order_line mrp.group_mrp_user 1 0 0 0
18 access_sale_order_stock_worker sale.order stock worker model_sale_order stock.group_stock_user 1 0 0 0
19 access_sale_order_line_stock_worker sale.order.line stock worker model_sale_order_line stock.group_stock_user 1 0 0 0
20 access_sale_order_manager sale.order.manager model_sale_order group_sale_manager 1 1 1 1
21 access_sale_order_line_manager sale.order.line.manager model_sale_order_line group_sale_manager 1 1 1 1

View File

@ -760,15 +760,6 @@ stock_picking()
class stock_production_lot(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
if context is None:
context = {}
res = super(stock_production_lot, self).search(cr, uid, args, offset, limit, order, context=context, count=count)
if res:
return [k for k,v in self._get_stock(cr, uid, res, 'stock_available', None, context).items() if v]
return res
def name_get(self, cr, uid, ids, context={}):
if not ids:
return []
@ -804,13 +795,30 @@ class stock_production_lot(osv.osv):
''')
res.update(dict(cr.fetchall()))
return res
def _stock_search(self, cr, uid, obj, name, args):
locations = self.pool.get('stock.location').search(cr, uid, [('usage','=','internal')])
cr.execute('''select
prodlot_id,
sum(name)
from
stock_report_prodlots
where
location_id in ('''+','.join(map(str, locations)) +''')
group by
prodlot_id
having sum(name) ''' + str(args[0][1]) + ''' ''' + str(args[0][2])
)
res = cr.fetchall()
ids = [('id','in',map(lambda x:x[0], res))]
return ids
_columns = {
'name': fields.char('Serial', size=64, required=True),
'ref': fields.char('Internal Ref', size=64),
'product_id': fields.many2one('product.product','Product',required=True),
'date': fields.datetime('Created Date', required=True),
'stock_available': fields.function(_get_stock, method=True, type="float", string="Available", select="2"),
'stock_available': fields.function(_get_stock, fnct_search=_stock_search, method=True, type="float", string="Available", select="2"),
'revisions': fields.one2many('stock.production.lot.revision','lot_id','Revisions'),
}
_defaults = {
@ -1018,6 +1026,7 @@ class stock_move(osv.osv):
def action_chain(self, cr, uid, ids, context={}):
moves = self.browse(cr, uid, ids)
<<<<<<< TREE
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
ptype = self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
@ -1046,9 +1055,46 @@ class stock_move(osv.osv):
self.pool.get('stock.move').write(cr, uid, [move.id], {
'move_dest_id': new_id,
'move_history_ids': [(4, new_id)]
=======
self.write(cr, uid, ids, {'state':'confirmed'})
i=0
def create_chained_picking(self,cr,uid,moves,context):
new_moves=[]
for picking, todo in self._chain_compute(cr, uid, moves, context).items():
ptype = self.pool.get('stock.location').picking_type_get(cr, uid, todo[0][0].location_dest_id, todo[0][1][0])
pickid = self.pool.get('stock.picking').create(cr, uid, {
'name': picking.name,
'origin': str(picking.origin or ''),
'type': ptype,
'note': picking.note,
'move_type': picking.move_type,
'auto_picking': todo[0][1][1]=='auto',
'address_id': picking.address_id.id,
'invoice_state': 'none'
>>>>>>> MERGE-SOURCE
})
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
for move,(loc,auto,delay) in todo:
# Is it smart to copy ? May be it's better to recreate ?
new_id = self.pool.get('stock.move').copy(cr, uid, move.id, {
'location_id': move.location_dest_id.id,
'location_dest_id': loc.id,
'date_moved': time.strftime('%Y-%m-%d'),
'picking_id': pickid,
'state':'waiting',
'move_history_ids':[],
'date_planned': (DateTime.strptime(move.date_planned, '%Y-%m-%d %H:%M:%S') + DateTime.RelativeDateTime(days=delay or 0)).strftime('%Y-%m-%d'),
'move_history_ids2':[]}
)
self.pool.get('stock.move').write(cr, uid, [move.id], {
'move_dest_id': new_id,
'move_history_ids': [(4, new_id)]
})
new_moves.append(self.browse(cr, uid, [new_id])[0])
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)
if new_moves:
create_chained_picking(self, cr, uid, new_moves, context)
create_chained_picking(self, cr, uid, moves, context)
return []
def action_assign(self, cr, uid, ids, *args):

View File

@ -23,18 +23,33 @@
import time
from osv import fields,osv
WARNING_MESSAGE = [
('no-message','No Message'),
('warning','Warning'),
('block','Blocking Message')
]
WARNING_HELP = 'Selecting the "Warning" option will notify user with the message, Selecting "Blocking Message" will throw an exception with the message and block the flow. The Message has to be written in the next field.'
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'sale_warn' : fields.boolean('Sale Order'),
'sale_warn' : fields.selection(WARNING_MESSAGE, 'Sale Order', help=WARNING_HELP),
'sale_warn_msg' : fields.text('Message for Sale Order'),
'purchase_warn' : fields.boolean('Purchase Order'),
'purchase_warn' : fields.selection(WARNING_MESSAGE, 'Purchase Order', help=WARNING_HELP),
'purchase_warn_msg' : fields.text('Message for Purchase Order'),
'picking_warn' : fields.boolean('Stock Picking'),
'picking_warn' : fields.selection(WARNING_MESSAGE, 'Stock Picking', help=WARNING_HELP),
'picking_warn_msg' : fields.text('Message for Stock Picking'),
'invoice_warn' : fields.boolean('Invoice'),
'invoice_warn' : fields.selection(WARNING_MESSAGE, 'Invoice', help=WARNING_HELP),
'invoice_warn_msg' : fields.text('Message for Invoice'),
}
_defaults = {
'sale_warn' : lambda *a: 'no-message',
'purchase_warn' : lambda *a: 'no-message',
'picking_warn' : lambda *a: 'no-message',
'invoice_warn' : lambda *a: 'no-message',
}
res_partner()
@ -44,19 +59,24 @@ class sale_order(osv.osv):
if not part:
return {'value':{'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False, 'payment_term' : False}}
warning = {}
title=False
message=False
title = False
message = False
partner = self.pool.get('res.partner').browse(cr, uid, part)
if partner.sale_warn:
warning={
'title': "Message",
'message': partner.sale_warn_msg
}
if partner.sale_warn != 'no-message':
if partner.sale_warn == 'block':
raise osv.except_osv(_('Alert for ' + partner.name +' !'), partner.sale_warn_msg)
warning = {
'title': "Warning for " + partner.name,
'message': partner.sale_warn_msg
}
result = super(sale_order, self).onchange_partner_id(cr, uid, ids, part)['value']
if result.get('warning',False):
warning['title']=title and title+' & '+result['warning']['title'] or result['warning']['title']
warning['message']=message and message +' '+result['warning']['message'] or result['warning']['message']
warning['title'] = title and title +' & '+ result['warning']['title'] or result['warning']['title']
warning['message'] = message and message + ' ' + result['warning']['message'] or result['warning']['message']
return {'value': result, 'warning':warning}
sale_order()
@ -68,11 +88,14 @@ class purchase_order(osv.osv):
return {'value':{'partner_address_id': False}}
warning = {}
partner = self.pool.get('res.partner').browse(cr, uid, part)
if partner.purchase_warn:
warning={
'title': "Message",
'message': partner.purchase_warn_msg
}
if partner.purchase_warn != 'no-message':
if partner.purchase_warn == 'block':
raise osv.except_osv(_('Alert for ' + partner.name +' !'), partner.purchase_warn_msg)
warning = {
'title': "Warning for " + partner.name,
'message': partner.purchase_warn_msg
}
result = super(purchase_order, self).onchange_partner_id(cr, uid, ids, part)['value']
return {'value': result, 'warning':warning}
@ -83,6 +106,7 @@ class account_invoice(osv.osv):
_inherit = 'account.invoice'
def onchange_partner_id(self, cr, uid, ids, type, partner_id,
date_invoice=False, payment_term=False, partner_bank_id=False):
if not partner_id:
return {'value': {
'address_contact_id': False ,
@ -93,11 +117,13 @@ class account_invoice(osv.osv):
}
warning = {}
partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
if partner.invoice_warn:
warning={
'title': "Message",
'message': partner.invoice_warn_msg
}
if partner.invoice_warn != 'no-message':
if partner.invoice_warn == 'block':
raise osv.except_osv(_('Alert for ' + partner.name +' !'), partner.invoice_warn_msg)
warning = {
'title': "Warning for " + partner.name,
'message': partner.invoice_warn_msg
}
result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id,
date_invoice=False, payment_term=False, partner_bank_id=False)['value']
return {'value': result, 'warning':warning}
@ -112,9 +138,11 @@ class stock_picking(osv.osv):
return {}
partner = self.pool.get('res.partner.address').browse(cr, uid, [partner_id])[0].partner_id
warning = {}
if partner.picking_warn:
warning={
'title': "Message",
if partner.picking_warn != 'no-message':
if partner.picking_warn == 'block':
raise osv.except_osv(_('Alert for ' + partner.name +' !'), partner.picking_warn_msg)
warning = {
'title': "Warning for " + partner.name,
'message': partner.picking_warn_msg
}
result = super(stock_picking, self).onchange_partner_in(cr, uid, context, partner_id)
@ -125,11 +153,17 @@ stock_picking()
class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
'sale_line_warn' : fields.boolean('Sale Order Line'),
'sale_line_warn' : fields.selection(WARNING_MESSAGE,'Sale Order Line', help=WARNING_HELP),
'sale_line_warn_msg' : fields.text('Message for Sale Order Line'),
'purchase_line_warn' : fields.boolean('Purchase Order Line'),
'purchase_line_warn' : fields.selection(WARNING_MESSAGE,'Purchase Order Line', help=WARNING_HELP),
'purchase_line_warn_msg' : fields.text('Message for Purchase Order Line'),
}
_defaults = {
'sale_line_warn' : lambda *a: 'no-message',
'purchase_line_warn' : lambda *a: 'no-message',
}
product_product()
class sale_order_line(osv.osv):
@ -145,20 +179,28 @@ class sale_order_line(osv.osv):
'product_uos': []}}
product_obj = self.pool.get('product.product')
product_info = product_obj.browse(cr, uid, product)
title=False
message=False
if product_info.sale_line_warn:
title= "Message",
message= product_info.sale_line_warn_msg
title = False
message = False
if product_info.sale_line_warn != 'no-message':
if product_info.sale_line_warn == 'block':
raise osv.except_osv(_('Alert for ' + product_info.name +' !'), product_info.sale_line_warn_msg)
title = "Warning for " + product_info.name
message = product_info.sale_line_warn_msg
warning['title'] = title
warning['message'] = message
result = super(sale_order_line, self).product_id_change( cr, uid, ids, pricelist, product, qty,
uom, qty_uos, uos, name, partner_id,
lang, update_tax, date_order, packaging, fiscal_position, flag)
if title and message:
warning['title']=title[0]
warning['message']=message
if result.get('warning',False):
warning['title']= title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
warning['message']=message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
warning['title'] = title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
return {'value': result['value'], 'warning':warning}
sale_order_line()
@ -172,20 +214,24 @@ class purchase_order_line(osv.osv):
return {'value': {'price_unit': 0.0, 'name':'','notes':'', 'product_uom' : False}, 'domain':{'product_uom':[]}}
product_obj = self.pool.get('product.product')
product_info = product_obj.browse(cr, uid, product)
title=False
message=False
if product_info.purchase_line_warn:
title = "Message"
message = product_info.purchase_line_warn_msg
title = False
message = False
if product_info.purchase_line_warn != 'no-message':
if product_info.purchase_line_warn == 'block':
raise osv.except_osv(_('Alert for ' + product_info.name +' !'), product_info.purchase_line_warn_msg)
title = "Warning for " + product_info.name
message = product_info.purchase_line_warn_msg
warning['title'] = title
warning['message'] = message
result = super(purchase_order_line, self).product_id_change(cr, uid, ids, pricelist, product, qty, uom,
partner_id, date_order, fiscal_position)
if title and message:
warning['title']=title[0]
warning['message']=message
if result.get('warning',False):
warning['title']= title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
warning['message']=message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
warning['title'] = title and title[0]+' & '+result['warning']['title'] or result['warning']['title']
warning['message'] = message and message +'\n\n'+result['warning']['message'] or result['warning']['message']
return {'value': result['value'], 'warning':warning}
purchase_order_line()

View File

@ -10,18 +10,26 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Warnings">
<separator string="Warning on the sale order" colspan="4"/>
<field name="sale_warn"/>
<field name="sale_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning on the purchase order" colspan="4"/>
<field name="purchase_warn"/>
<field name="purchase_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning on the picking" colspan="4"/>
<field name="picking_warn"/>
<field name="picking_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning on the invoice" colspan="4"/>
<field name="invoice_warn"/>
<field name="invoice_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning on the Sale Order" colspan="4"/>
<group colspan="1" col="1">
<field name="sale_warn" />
</group>
<field name="sale_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('sale_warn','!=','no-message')]}"/>
<separator string="Warning on the Purchase Order" colspan="4"/>
<group colspan="1" col="1">
<field name="purchase_warn" />
</group>
<field name="purchase_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('purchase_warn','!=','no-message')]}"/>
<separator string="Warning on the Picking" colspan="4"/>
<group colspan="1" col="1">
<field name="picking_warn" />
</group>
<field name="picking_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('picking_warn','!=','no-message')]}"/>
<separator string="Warning on the Invoice" colspan="4"/>
<group colspan="1" col="1">
<field name="invoice_warn" />
</group>
<field name="invoice_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('invoice_warn','!=','no-message')]}"/>
</page>
</notebook>
</field>
@ -35,12 +43,16 @@
<field name="arch" type="xml">
<notebook position="inside">
<page string="Warnings">
<separator string="Warning when selling this product" colspan="4"/>
<field name="sale_line_warn"/>
<field name="sale_line_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning when purchasing this product" colspan="4"/>
<field name="purchase_line_warn"/>
<field name="purchase_line_warn_msg" colspan="4" nolabel="1"/>
<separator string="Warning when Selling this Product" colspan="4"/>
<group colspan="1" col="1">
<field name="sale_line_warn"/>
</group>
<field name="sale_line_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('sale_line_warn','!=','no-message')]}"/>
<separator string="Warning when Purchasing this Product" colspan="4" />
<group colspan="1" col="1">
<field name="purchase_line_warn"/>
</group>
<field name="purchase_line_warn_msg" colspan="3" nolabel="1" attrs="{'required':[('purchase_line_warn','!=','no-message')]}"/>
</page>
</notebook>
</field>

View File

@ -29,7 +29,7 @@ FAQs, quality manuals, technical references, etc.
==To get more information==
* [[Basic Wiki Editing]]
* [[Wiki Documentation]]
* [[The Open ERP website]]
* [http://openerp.com The Open ERP website]
</field>