bzr revid: stephane@tinyerp.com-20090319155542-9q0s8ru7pne1yjpf
This commit is contained in:
Stephane Wirtel
2009-03-19 16:55:42 +01:00
23 changed files with 471 additions and 491 deletions
+1 -1
View File
@@ -2275,7 +2275,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)
+4 -4
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>
+26 -5
View File
@@ -382,13 +382,14 @@ class account_invoice(osv.osv):
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):
@@ -917,8 +918,14 @@ 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):
res[line.id] = round(line.price_unit * line.quantity * (1-(line.discount or 0.0)/100.0),2)
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):
@@ -1111,9 +1118,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 = {
+21 -83
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,19 +93,18 @@ 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':
ctx['date_from'] = form['date_from']
ctx['date_to'] = form['date_to']
self.transform_date_into_date_array(form)
elif form['state'] == 'all' :
self.transform_both_into_date_array(form)
elif form['state'] == 'none' :
self.transform_none_into_date_array(form)
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)
@@ -189,39 +159,7 @@ class account_balance(report_sxw.rml_parse):
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
+60 -55
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>
+109 -101
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>
+4 -148
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
@@ -86,10 +86,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']
@@ -97,9 +97,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):
@@ -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>
@@ -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>
@@ -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>
+1 -2
View File
@@ -81,8 +81,7 @@ class board_board(osv.osv):
'type': 'form',
'arch': self.create_view(cr, user, id, context),
})
vals['view_id'] = view_id
super(board_board, self).write(cr, user, [id], vals, 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):
+46 -2
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:
+19 -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>
+10 -1
View File
@@ -113,7 +113,16 @@
<field name="notes" colspan="4" select="2"/>
</page>
<page string="Holidays" >
<field name="holiday_ids" nolabel="1"/>
<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>
+4 -1
View File
@@ -482,7 +482,10 @@ class purchase_order_line(osv.osv):
seller_delay = s.delay
if s.name.id == partner_id:
seller_delay = s.delay
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
+1 -1
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,
+59 -38
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"
@@ -95,44 +96,64 @@ class report_closed_task(osv.osv):
''')
report_closed_task()
#class report_timesheet_task(osv.osv):
# _name = "report.timesheet.task"
# _description = "Report on Timesheets and Tasks per User Per Month"
# _auto = False
#
# def get_hrs_timesheet(self, cr, uid, ids, name,args,context):
# result = {}
#
# for record in self.browse(cr, uid, ids, context):
# last_date = mx.DateTime.strptime(record.month, '%Y-%m-%d') + mx.DateTime.RelativeDateTime(months=1) - 1
# obj=self.pool.get('hr_timesheet_sheet.sheet')
# sheet_ids = obj.search(cr,uid,[('user_id','=',record.user_id.id),('date_current','>=',record.month),('date_current','<=',last_date.strftime('%Y-%m-%d'))])
# data_days = obj.read(cr,uid,sheet_ids,['total_attendance_day','date_current','user_id'])
# total = 0.0
# for day_attendance in data_days:
# total += day_attendance['total_attendance_day']
# result[record.id] = total
#
# return result
#
# _columns = {
# 'month': fields.date('Month', required=True,readonly=True),
# 'user_id': fields.many2one('res.users', 'User' ,readonly=True, required=True),
# 'timesheet_hrs': fields.function(get_hrs_timesheet,method=True, string="Timesheet Hrs" ),
# 'task_hrs': fields.float('Task Hrs', readonly=True, required=True),
# }
#
#
# def init(self, cr):
# cr.execute("""create or replace view report_timesheet_task as (
# select min(p.id) as id, to_char(p.date, 'YYYY-MM-01') as month, min(r.id) as user_id, sum(p.hours) as task_hrs,0.0 as timesheet_hrs
# from project_task_work p,res_users r
# where (r.id=p.user_id)
# group by to_char(p.date, 'YYYY-MM-01'))""")
#
#
#
#report_timesheet_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:
+24
View File
@@ -90,5 +90,29 @@
<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>
@@ -296,7 +296,6 @@
</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>
+55 -31
View File
@@ -800,13 +800,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 = {
@@ -1011,36 +1028,43 @@ class stock_move(osv.osv):
# ids = map(lambda m: m.id, moves)
moves = self.browse(cr, uid, ids)
self.write(cr, uid, ids, {'state':'confirmed'})
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'
})
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)]
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'
})
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):
+1 -1
View File
@@ -97,7 +97,7 @@ def _track_lines(self, cr, uid, data, context):
new_move.append(current_move)
else:
current_move = move.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx})
new_prodlot = prodlot_obj.create(cr, uid, {'name': sequence, 'ref': '%d'%idx}, {'product_id': move.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
+14
View File
@@ -105,6 +105,20 @@ class Wiki(osv.osv):
def copy_data(self, cr, uid, id, default=None, context=None):
return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id':False}, context)
def create(self, cr, uid, vals, context=None):
id = super(Wiki,self).create(cr, uid, vals, context)
history = self.pool.get('wiki.wiki.history')
if vals.get('text_area'):
res = {
'minor_edit':vals.get('minor_edit', True),
'text_area':vals.get('text_area',''),
'write_uid':uid,
'wiki_id' : id,
'summary':vals.get('summary','')
}
history.create(cr, uid, res)
return id
def write(self, cr, uid, ids, vals, context=None):
result = super(Wiki,self).write(cr, uid, ids, vals, context)
history = self.pool.get('wiki.wiki.history')