[DEL] analytic_contract_hr_expense: deprecated module
Reason: complete rewrite of the Sale module. Invoicing is now managed completely from the Sale module. Responsible: fp, dbo, nim
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import analytic_contract_hr_expense
|
||||
@@ -1,20 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
|
||||
{
|
||||
'name': 'Contracts Management: hr_expense link',
|
||||
'version': '1.1',
|
||||
'category': 'Hidden',
|
||||
'description': """
|
||||
This module is for modifying account analytic view to show some data related to the hr_expense module.
|
||||
======================================================================================================
|
||||
""",
|
||||
'author': 'OpenERP S.A.',
|
||||
'website': 'https://www.odoo.com/',
|
||||
'depends': ['hr_expense','sale_contract'],
|
||||
'data': ['analytic_contract_hr_expense_view.xml'],
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
|
||||
from openerp.addons.decimal_precision import decimal_precision as dp
|
||||
|
||||
class account_analytic_account(osv.osv):
|
||||
_name = "account.analytic.account"
|
||||
_inherit = "account.analytic.account"
|
||||
|
||||
def _get_total_estimation(self, account):
|
||||
tot_est = super(account_analytic_account, self)._get_total_estimation(account)
|
||||
if account.charge_expenses:
|
||||
tot_est += account.est_expenses
|
||||
return tot_est
|
||||
|
||||
def _get_total_invoiced(self, account):
|
||||
total_invoiced = super(account_analytic_account, self)._get_total_invoiced(account)
|
||||
if account.charge_expenses:
|
||||
total_invoiced += account.expense_invoiced
|
||||
return total_invoiced
|
||||
|
||||
def _get_total_remaining(self, account):
|
||||
total_remaining = super(account_analytic_account, self)._get_total_remaining(account)
|
||||
if account.charge_expenses:
|
||||
total_remaining += account.remaining_expense
|
||||
return total_remaining
|
||||
|
||||
def _get_total_toinvoice(self, account):
|
||||
total_toinvoice = super(account_analytic_account, self)._get_total_toinvoice(account)
|
||||
if account.charge_expenses:
|
||||
total_toinvoice += account.expense_to_invoice
|
||||
return total_toinvoice
|
||||
|
||||
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.est_expenses != 0:
|
||||
res[account.id] = max(account.est_expenses - account.expense_invoiced, account.expense_to_invoice)
|
||||
else:
|
||||
res[account.id]=0.0
|
||||
return res
|
||||
|
||||
def _expense_to_invoice_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
res = {}
|
||||
#We don't want consolidation for each of these fields because those complex computation is resource-greedy.
|
||||
for account in self.pool.get('account.analytic.account').browse(cr, uid, ids, context=context):
|
||||
cr.execute("""
|
||||
SELECT product_id, sum(amount), user_id, to_invoice, sum(unit_amount), product_uom_id, line.name
|
||||
FROM account_analytic_line line
|
||||
LEFT JOIN account_analytic_journal journal ON (journal.id = line.journal_id)
|
||||
WHERE account_id = %s
|
||||
AND journal.type = 'purchase'
|
||||
AND invoice_id IS NULL
|
||||
AND to_invoice IS NOT NULL
|
||||
GROUP BY product_id, user_id, to_invoice, product_uom_id, line.name""", (account.id,))
|
||||
|
||||
res[account.id] = 0.0
|
||||
for product_id, total_amount, user_id, factor_id, qty, uom, line_name in cr.fetchall():
|
||||
#the amount to reinvoice is the real cost. We don't use the pricelist
|
||||
total_amount = -total_amount
|
||||
factor = self.pool.get('hr_timesheet_invoice.factor').browse(cr, uid, factor_id, context=context)
|
||||
res[account.id] += total_amount * (100 - factor.factor or 0.0) / 100.0
|
||||
return res
|
||||
|
||||
def _expense_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
lines_obj = self.pool.get('account.analytic.line')
|
||||
res = {}
|
||||
for account in self.browse(cr, uid, ids, context=context):
|
||||
res[account.id] = 0.0
|
||||
line_ids = lines_obj.search(cr, uid, [('account_id','=', account.id), ('invoice_id','!=',False), ('to_invoice','!=', False), ('journal_id.type', '=', 'purchase')], context=context)
|
||||
#Put invoices in separate array in order not to calculate them double
|
||||
invoices = []
|
||||
for line in lines_obj.browse(cr, uid, line_ids, context=context):
|
||||
if line.invoice_id not in invoices:
|
||||
invoices.append(line.invoice_id)
|
||||
for invoice in invoices:
|
||||
res[account.id] += invoice.amount_untaxed
|
||||
return res
|
||||
|
||||
def _ca_invoiced_calc(self, cr, uid, ids, name, arg, context=None):
|
||||
result = super(account_analytic_account, self)._ca_invoiced_calc(cr, uid, ids, name, arg, context=context)
|
||||
for acc in self.browse(cr, uid, result.keys(), context=context):
|
||||
result[acc.id] = result[acc.id] - (acc.expense_invoiced or 0.0)
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'charge_expenses' : fields.boolean('Charge Expenses'),
|
||||
'expense_invoiced' : fields.function(_expense_invoiced_calc, string="Expenses invoiced", type="float"),
|
||||
'expense_to_invoice' : fields.function(_expense_to_invoice_calc, string="Expenses to invoice", type='float'),
|
||||
'remaining_expense' : fields.function(_remaining_expnse_calc, string="Remaining Expenses", type="float"),
|
||||
'est_expenses': fields.float('Estimation of Expenses to Invoice'),
|
||||
'ca_invoiced': fields.function(_ca_invoiced_calc, type='float', string='Invoiced Amount',
|
||||
help="Total customer invoiced amount for this account.",
|
||||
digits=0),
|
||||
}
|
||||
|
||||
def on_change_template(self, cr, uid, ids, template_id, date_start=False, context=None):
|
||||
res = super(account_analytic_account, self).on_change_template(cr, uid, ids, template_id, date_start=date_start, context=context)
|
||||
if template_id and 'value' in res:
|
||||
template = self.browse(cr, uid, template_id, context=context)
|
||||
res['value']['charge_expenses'] = template.charge_expenses
|
||||
res['value']['est_expenses'] = template.est_expenses
|
||||
return res
|
||||
|
||||
def open_hr_expense(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool['ir.model.data']
|
||||
act_obj = self.pool['ir.actions.act_window']
|
||||
|
||||
dummy, act_window_id = mod_obj.get_object_reference(cr, uid, 'hr_expense', 'expense_all')
|
||||
result = act_obj.read(cr, uid, [act_window_id], context=context)[0]
|
||||
|
||||
line_ids = self.pool['hr.expense.line'].search(cr, uid, [('analytic_account', 'in', ids)], context=context)
|
||||
result['domain'] = [('line_ids', 'in', line_ids)]
|
||||
names = [account.name for account in self.browse(cr, uid, ids, context=context)]
|
||||
result['name'] = _('Expenses of %s') % ','.join(names)
|
||||
result['context'] = {'analytic_account': ids[0]}
|
||||
result['view_type'] = 'form'
|
||||
return result
|
||||
|
||||
def hr_to_invoice_expense(self, cr, uid, ids, context=None):
|
||||
domain = [('invoice_id','=',False),('to_invoice','!=',False), ('journal_id.type', '=', 'purchase'), ('account_id', 'in', ids)]
|
||||
names = [record.name for record in self.browse(cr, uid, ids, context=context)]
|
||||
name = _('Expenses to Invoice of %s') % ','.join(names)
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': name,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'domain' : domain,
|
||||
'res_model': 'account.analytic.line',
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="account_analytic_account_form_expense_form" model="ir.ui.view">
|
||||
<field name="name">account.analytic.account.form.expense.inherit</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field eval="60" name="priority"/>
|
||||
<field name="inherit_id" ref="sale_contract.account_analytic_account_form_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//tr[@name="total"]' position='before'>
|
||||
<tr>
|
||||
<td class="oe_timesheet_grey">
|
||||
<label for="charge_expenses"/>
|
||||
</td><td class="oe_timesheet_grey">
|
||||
<field name="charge_expenses"/>
|
||||
</td><td>
|
||||
<field class="oe_form_inline" name="est_expenses" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
|
||||
</td><td>
|
||||
<field class="oe_form_inline" name="expense_invoiced" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
|
||||
</td><td>
|
||||
<field class="oe_form_inline" name="remaining_expense" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
|
||||
</td><td>
|
||||
<field class="oe_form_inline" name="expense_to_invoice" attrs="{'invisible': [('charge_expenses','=',False)]}"/>
|
||||
</td><td attrs="{'invisible': [('charge_expenses','=',False)]}" class="oe_timesheet_action">
|
||||
<span attrs="{'invisible': [('expense_to_invoice','=',0)]}" class="oe_grey">
|
||||
<button
|
||||
name="hr_to_invoice_expense"
|
||||
class="oe_link"
|
||||
string="⇒ Invoice" type="object"
|
||||
/>
|
||||
or view
|
||||
</span>
|
||||
<span attrs="{'invisible': [('expense_to_invoice','<>',0)]}" class="oe_grey">
|
||||
Nothing to invoice, create
|
||||
</span>
|
||||
<button
|
||||
name="open_hr_expense"
|
||||
class="oe_link"
|
||||
string="Expenses" type="object"/>
|
||||
</td>
|
||||
</tr>
|
||||
</xpath>
|
||||
<xpath expr="//p[@name='invoice_on_timesheets_label']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('invoice_on_timesheets','=',False),('charge_expenses','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='pricelist_id']" position="attributes">
|
||||
<attribute name="attrs">{'required': ['|',('invoice_on_timesheets','=',True),('charge_expenses','=',True)], 'invisible':[('invoice_on_timesheets','=',False), ('charge_expenses','=',False)]}</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='to_invoice']" position="attributes">
|
||||
<attribute name="attrs">{'required': ['|',('invoice_on_timesheets','=',True),('charge_expenses','=',True)]}</attribute>
|
||||
<attribute name="string">Expenses and Timesheet Invoicing Ratio</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!--<record id="project_form_expense_form" model="ir.ui.view">
|
||||
<field name="name">project.project.form.expense.inherit</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="inherit_id" ref="analytic_contract_project.project_account_analytic_account_form"/>
|
||||
<field eval="20" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//div[@name="end_of_tabl_hook"]' position='before'>
|
||||
<tr>
|
||||
<th class="oe_border_right">Charge Expenses</th>
|
||||
<td><field name="charge_expenses" nolabel="1"/></td>
|
||||
<td><field class="oe_th_110px" name="est_expenses" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
<td class="oe_th_110px"><field name="expense_invoiced" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
<td class="oe_th_110px oe_border_right"><field name="remaining_expense" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
<td class="oe_th_110px"><field name="expense_to_invoice" nolabel="1" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
<td width="10px"></td>
|
||||
<td><button icon="gtk-select-all" class= "oe_btn_width" name="open_hr_expense" string="Expenses" type="object" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
<td><button icon="terp-dolar" class= "oe_btn_width" name="hr_to_invoiced_expense" string="Invoice Expenses" type="object" attrs="{'invisible': [('charge_expenses','=',0)]}"/></td>
|
||||
</tr>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>-->
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user