[IMP]add expense line and add depend expense of hr in contract for calculation
bzr revid: sgo@tinyerp.com-20120530125641-w27mjp97b981yrpd
This commit is contained in:
parent
e886a135ed
commit
11bf57f1bf
|
@ -35,7 +35,7 @@ user-wise as well as month wise.
|
|||
"author": "Camptocamp",
|
||||
"website": "http://www.camptocamp.com/",
|
||||
"images": ["images/bill_tasks_works.jpeg","images/overpassed_accounts.jpeg"],
|
||||
"depends": ["hr_timesheet_invoice", "sale"], #although sale is technically not required to install this module, all menuitems are located under 'Sales' application
|
||||
"depends": ["hr_expense","hr_timesheet_invoice", "sale"], #although sale is technically not required to install this module, all menuitems are located under 'Sales' application
|
||||
"init_xml": [],
|
||||
"update_xml": [
|
||||
"security/ir.model.access.csv",
|
||||
|
|
|
@ -98,7 +98,7 @@ class account_analytic_account(osv.osv):
|
|||
WHERE account_analytic_account.id IN %s \
|
||||
AND account_analytic_line.invoice_id IS NULL \
|
||||
AND account_analytic_line.to_invoice IS NOT NULL \
|
||||
AND account_analytic_journal.type IN ('purchase','general') \
|
||||
AND account_analytic_journal.type = 'sale' \
|
||||
GROUP BY account_analytic_account.id;""", (parent_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
if account_id not in res:
|
||||
|
@ -224,7 +224,45 @@ class account_analytic_account(osv.osv):
|
|||
res[account_id] = round(sum,2)
|
||||
res_final = res
|
||||
return res_final
|
||||
|
||||
def _expense_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res_final = {}
|
||||
child_ids = tuple(ids) #We don't want consolidation for each of these fields because those complex computation is resource-greedy.
|
||||
for i in child_ids:
|
||||
res[i] = 0.0
|
||||
if not child_ids:
|
||||
return res
|
||||
|
||||
if child_ids:
|
||||
cr.execute("select hel.analytic_account,SUM(hel.unit_amount*hel.unit_quantity) from hr_expense_line as hel\
|
||||
LEFT JOIN hr_expense_expense as he ON he.id = hel.expense_id\
|
||||
where he.state = 'paid' and hel.analytic_account IN %s \
|
||||
GROUP BY hel.analytic_account",(child_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
res_final = res
|
||||
return res_final
|
||||
|
||||
def _expense_to_invoice_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res_final = {}
|
||||
child_ids = tuple(ids) #We don't want consolidation for each of these fields because those complex computation is resource-greedy.
|
||||
for i in child_ids:
|
||||
res[i] = 0.0
|
||||
if not child_ids:
|
||||
return res
|
||||
|
||||
if child_ids:
|
||||
cr.execute("select hel.analytic_account, SUM(hel.unit_amount*hel.unit_quantity) from hr_expense_line as hel\
|
||||
LEFT JOIN hr_expense_expense as he ON he.id = hel.expense_id\
|
||||
where he.state = 'invoiced' and hel.analytic_account IN %s \
|
||||
GROUP BY hel.analytic_account",(child_ids,))
|
||||
for account_id, sum in cr.fetchall():
|
||||
res[account_id] = sum
|
||||
res_final = res
|
||||
return res_final
|
||||
|
||||
def _total_cost_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
res_final = {}
|
||||
|
@ -301,6 +339,17 @@ class account_analytic_account(osv.osv):
|
|||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _remaining_expnse_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
if account.expense_max != 0:
|
||||
res[account.id] = account.expense_max - account.expense_invoiced
|
||||
else:
|
||||
res[account.id]=0.0
|
||||
for id in ids:
|
||||
res[id] = round(res.get(id, 0.0),2)
|
||||
return res
|
||||
|
||||
def _real_margin_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
|
@ -385,9 +434,12 @@ class account_analytic_account(osv.osv):
|
|||
'month_ids': fields.function(_analysis_all, multi='analytic_analysis', type='many2many', relation='account_analytic_analysis.summary.month', string='Month'),
|
||||
'user_ids': fields.function(_analysis_all, multi='analytic_analysis', type="many2many", relation='account_analytic_analysis.summary.user', string='User'),
|
||||
'template_id':fields.many2one('account.analytic.account', 'Template Of Contract'),
|
||||
'expense_invoiced' : fields.function(_expense_invoiced_calc, type="float"),
|
||||
'expense_to_invoice' : fields.function(_expense_to_invoice_calc, type='float'),
|
||||
'remaining_expense' : fields.function(_remaining_expnse_calc, type="float"),
|
||||
#'fix_exp_max' : fields.float('Max. amt'),
|
||||
#'timesheet_max': fields.float('max_timesheet'),
|
||||
#'expense_max': fields.float('expenses'),
|
||||
'expense_max': fields.float('expenses'),
|
||||
}
|
||||
def on_change_template(self, cr, uid, id, template_id):
|
||||
if not template_id:
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
</xpath>
|
||||
<xpath expr='//separator[@name="description"]' position='before'>
|
||||
<separator colspan="4" string="Invoicing" name="invoicing"/>
|
||||
<group colspan="4">
|
||||
<!-- <group colspan="4">
|
||||
<group col="2" colspan="1" class="oe_form_group_label_border">
|
||||
<label string=" "/><label string=" "/>
|
||||
<field name="fix_price_invoices"/>
|
||||
|
@ -89,11 +89,9 @@
|
|||
<button name="%(hr_timesheet_invoice.act_acc_analytic_acc_2_report_acc_analytic_line_to_invoice)d" string="Invoice Timesheets" type="action" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/>
|
||||
|
||||
</group>
|
||||
</group>
|
||||
</group> -->
|
||||
|
||||
|
||||
|
||||
<!--<group colspan="4" name="contract_lines" class="oe_form_group_label_border">
|
||||
<group colspan="4" name="contract_lines" class="oe_form_group_label_border">
|
||||
<table name="contract_data">
|
||||
<tr name="title" >
|
||||
<th ><div class="oe_field_label" ></div></th>
|
||||
|
@ -105,31 +103,31 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th><div class="oe_field_label">Fix price Invoices</div></th>
|
||||
<td><div><field name="so_visible" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view"><field name="amount_max" nolabel="1" attrs="{'invisible': [('so_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view"><field name="ca_invoiced" nolabel="1" attrs="{'invisible': [('so_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view"><field name="remaining_ca" nolabel="1" attrs="{'invisible': [('so_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_float_field_view"><field name="ca_to_invoice" nolabel="1" attrs="{'invisible': [('so_visible','=',0)]}"/></div></td>
|
||||
<td><button class="oe_title_button_right" name="%(action_sales_order_line)d" string="Sales" type="action" context="{'default_project_id': active_id,'search_default_project_id': active_id}" attrs="{'invisible': [('so_visible','=',0)]}"/></td>
|
||||
<td><button class="oe_title_button_left" name="%(sale.action_order_line_tree2)d" string="Lines To Invoice" type="action" context="{'default_project_id': active_id,'search_default_project_id': active_id}" attrs="{'invisible': [('so_visible','=',0)]}"/></td>
|
||||
<td><div><field name="fix_price_invoices" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view"><field name="amount_max" nolabel="1" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view"><field name="ca_invoiced" nolabel="1" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view"><field name="remaining_ca" nolabel="1" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></div></td>
|
||||
<td><div class="oe_float_field_view"><field name="ca_to_invoice" nolabel="1" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></div></td>
|
||||
<td><button class="oe_title_button_right" name="%(action_sales_order_line)d" string="Sales" type="action" context="{'default_project_id': active_id,'search_default_project_id': active_id}" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></td>
|
||||
<td><button class="oe_title_button_left" name="%(sale.action_order_line_tree2)d" string="Lines To Invoice" type="action" context="{'default_project_id': active_id,'search_default_project_id': active_id}" attrs="{'invisible': [('fix_price_invoices','=',0)]}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><div class="oe_field_label">Invoice on timesheet</div></th>
|
||||
<td><div><field name="timsheet_visible" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="quantity_max" nolabel="1" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="hours_qtt_invoiced" nolabel="1" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="remaining_hours" nolabel="1" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="hours_qtt_non_invoiced" nolabel="1" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></div></td>
|
||||
<td><button class="oe_title_button_right" name="%(account.action_account_tree1)d" string="Timesheets" type="action" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></td>
|
||||
<td><button class="oe_title_button_left" name="%(hr_timesheet_invoice.act_acc_analytic_acc_2_report_acc_analytic_line_to_invoice)d" string="Invoice Timesheets" type="action" attrs="{'invisible': [('timsheet_visible','=',0)]}"/></td>
|
||||
<td><div><field name="invoice_on_timesheets" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="quantity_max" nolabel="1" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="hours_qtt_invoiced" nolabel="1" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="remaining_hours" nolabel="1" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="hours_qtt_non_invoiced" nolabel="1" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></div></td>
|
||||
<td><button class="oe_title_button_right" name="%(account.action_account_tree1)d" string="Timesheets" type="action" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></td>
|
||||
<td><button class="oe_title_button_left" name="%(hr_timesheet_invoice.act_acc_analytic_acc_2_report_acc_analytic_line_to_invoice)d" string="Invoice Timesheets" type="action" attrs="{'invisible': [('invoice_on_timesheets','=',0)]}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><div class="oe_field_label" >Charge Expenses</div></th>
|
||||
<td><div><field name="expense_visible" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="expense_max" nolabel="1" attrs="{'invisible': [('expense_visible','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ></div></td>
|
||||
<td><div class="oe_field_view" ></div></td>
|
||||
<td><div class="oe_float_field_view"></div></td>
|
||||
<td><div><field name="charge_expenses" nolabel="1"/></div></td>
|
||||
<td><div class="oe_float_field_view" ><field name="expense_max" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="expense_invoiced" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></div></td>
|
||||
<td><div class="oe_field_view" ><field name="remaining_expense" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></div></td>
|
||||
<td><div class="oe_float_field_view"><field name="expense_to_invoice" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></div></td>
|
||||
</tr>
|
||||
<tr name="total">
|
||||
<th><div class="oe_field_label" >Total</div></th>
|
||||
|
@ -140,7 +138,7 @@
|
|||
<td><div class="oe_totals" ></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
</group>-->
|
||||
</group>
|
||||
<group colspan="4" class="oe_form_group_label_border">
|
||||
<field name="pricelist_id" />
|
||||
<field name="to_invoice" widget="selection" />
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<field name="date_value"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field domain="[('type','=','normal'), ('parent_id','!=',False)]" name="analytic_account" groups="analytic.group_analytic_accounting"/>
|
||||
<field domain="[('type','in',['normal','contract']), ('parent_id','!=',False)]" name="analytic_account" groups="analytic.group_analytic_accounting"/>
|
||||
<field name="unit_amount"/>
|
||||
<field name="unit_quantity"/>
|
||||
<field name="total_amount" sum="Total"/>
|
||||
|
@ -102,7 +102,7 @@
|
|||
</group>
|
||||
<group colspan="2" col="2" groups="analytic.group_analytic_accounting">
|
||||
<separator string="Customer Project" colspan="2"/>
|
||||
<field domain="[('type','=','normal')]" name="analytic_account"/>
|
||||
<field domain="[('type','in',['normal','contract'])]" name="analytic_account"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="References" colspan="2"/>
|
||||
|
|
Loading…
Reference in New Issue