diff options
Diffstat (limited to 'addons/analytic_user_function')
5 files changed, 0 insertions, 231 deletions
diff --git a/addons/analytic_user_function/__init__.py b/addons/analytic_user_function/__init__.py deleted file mode 100644 index d6b45b8a442..00000000000 --- a/addons/analytic_user_function/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -import analytic_user_function diff --git a/addons/analytic_user_function/__openerp__.py b/addons/analytic_user_function/__openerp__.py deleted file mode 100644 index a2eb25da4e4..00000000000 --- a/addons/analytic_user_function/__openerp__.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - - -{ - 'name': 'Jobs on Contracts', - 'version': '1.0', - 'category': 'Sales Management', - 'description': """ -This module allows you to define what is the default function of a specific user on a given account. -==================================================================================================== - -This is mostly used when a user encodes his timesheet: the values are retrieved -and the fields are auto-filled. But the possibility to change these values is -still available. - -Obviously if no data has been recorded for the current account, the default -value is given as usual by the employee data so that this module is perfectly -compatible with older configurations. - - """, - 'website': 'https://www.odoo.com/page/employees', - 'depends': ['hr_timesheet_sheet'], - 'data': ['analytic_user_function_view.xml', 'security/ir.model.access.csv'], - 'demo': [], - 'installable': True, - 'auto_install': False, -} diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py deleted file mode 100644 index bd3d70e5de7..00000000000 --- a/addons/analytic_user_function/analytic_user_function.py +++ /dev/null @@ -1,120 +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 _ -import openerp.addons.decimal_precision as dp -from openerp.exceptions import UserError - - -class analytic_user_funct_grid(osv.osv): - _name = "analytic.user.funct.grid" - _description = "Price per User" - _rec_name = "user_id" - _columns = { - 'user_id': fields.many2one("res.users", "User", required=True,), - 'product_id': fields.many2one("product.product", "Service", required=True,), - 'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,), - 'uom_id': fields.related("product_id", "uom_id", relation="product.uom", string="Unit of Measure", type="many2one", readonly=True), - 'price': fields.float('Price', digits_compute=dp.get_precision('Product Price'), help="Price per hour for this user.", required=True), - } - - def onchange_user_product_id(self, cr, uid, ids, user_id, product_id, context=None): - if not user_id: - return {} - emp_obj = self.pool.get('hr.employee') - emp_id = emp_obj.search(cr, uid, [('user_id', '=', user_id)], context=context) - if not emp_id: - return {} - - value = {} - prod = False - if product_id: - prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - emp = emp_obj.browse(cr, uid, emp_id[0], context=context) - if emp.product_id and not product_id: - value['product_id'] = emp.product_id.id - prod = emp.product_id - if prod: - value['price'] = prod.list_price - value['uom_id'] = prod.uom_id.id - return {'value': value} - - -class account_analytic_account(osv.osv): - _inherit = "account.analytic.account" - _columns = { - 'user_product_ids': fields.one2many('analytic.user.funct.grid', 'account_id', 'Users/Products Rel.', copy=True), - } - - -class account_analytic_line(osv.osv): - _inherit = "account.analytic.line" - - # Look in account, if no value for the user => look in parent until there is no more parent to look - # Take the first found... if nothing found => return False - def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id, context=None): - user_function_id = self.pool.get('analytic.user.funct.grid').search(cr, uid, [('user_id', '=', user_id), ('account_id', '=', account_id)], context=context) - account = self.pool['account.analytic.account'].browse(cr, uid, account_id, context=context) - if user_function_id: - return user_function_id - elif account.parent_id: - return self._get_related_user_account_recursiv(cr, uid, user_id, account.parent_id.id, context) - else: - return False - - def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0, is_timesheet=False, context=None): - res = {} - if not (account_id): - return res - if not (user_id): - return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context) - - # get the browse record related to user_id and account_id - user_function_id = self._get_related_user_account_recursiv(cr, uid, user_id, account_id, context) - if not user_function_id: - # if there isn't any record for this user_id and account_id - return super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context) - else: - # get the old values from super and add the value from the new relation analytic_user_funct_grid - res['value'] = super(account_analytic_line, self).on_change_account_id(cr, uid, ids, account_id, user_id, unit_amount, is_timesheet, context)['value'] - res['value'].update(self._get_values_based_on_user_function(cr, uid, ids, user_function_id, unit_amount, context=context)) - return res - - def on_change_user_id(self, cr, uid, ids, user_id, unit_amount=0, account_id=None, is_timesheet=False, context=None): - res = {} - res = super(account_analytic_line, self).on_change_user_id(cr, uid, ids, user_id, is_timesheet, context=context) - - if account_id: - # get the browse record related to user_id and account_id - user_function_id = self._get_related_user_account_recursiv(cr, uid, user_id, account_id, context) - if user_function_id: - res['value'].update(self._get_values_based_on_user_function(cr, uid, ids, user_function_id, unit_amount, context=context)) - return res - - # Returns appropriate values for an analytic line if the user has a specific user_function - def _get_values_based_on_user_function(self, cr, uid, ids, user_function_id, unit_amount=0, context=None): - res = {} - user_function = self.pool['analytic.user.funct.grid'].browse(cr, uid, user_function_id, context=context) - product = user_function.product_id - res['product_id'] = product.id - res['uom_id'] = product.uom_id.id - - expense_account = product.property_account_expense_id.id - if not expense_account: - expense_account = product.categ_id.property_account_expense_categ_id.id - if not expense_account: - raise UserError(_('There is no expense account defined for this product: "%s" (id:%d)') % (product.name, product.id,)) - res['general_account_id'] = expense_account - - if unit_amount: - new_amount = self.on_change_unit_amount(cr, uid, ids, product.id, unit_amount, False, product.uom_id.id) - res['amount'] = new_amount['value']['amount'] - - return res - - def _get_invoice_price(self, cr, uid, account, product_id, user_id, qty, context={}): - for grid in account.user_product_ids: - if grid.user_id.id == user_id: - return grid.price - return super(account_analytic_line, self)._get_invoice_price(cr, uid, account, product_id, user_id, qty, context) diff --git a/addons/analytic_user_function/analytic_user_function_view.xml b/addons/analytic_user_function/analytic_user_function_view.xml deleted file mode 100644 index 00743547e80..00000000000 --- a/addons/analytic_user_function/analytic_user_function_view.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0" ?> -<openerp> - <data> - - <!-- analytic_user_funct_grid views --> - <record model="ir.ui.view" id="analytic_user_funct_grid_tree"> - <field name="name">analytic_user_funct_grid.tree</field> - <field name="model">analytic.user.funct.grid</field> - <field name="arch" type="xml"> - <tree string="Invoicing Data" editable="bottom"> - <field name="user_id" on_change="onchange_user_product_id(user_id, product_id)" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_salesman']}"/> - <field name="product_id" on_change="onchange_user_product_id(user_id, product_id)" domain="[('type','=','service')]"/> - <field name="price"/> - <field name="uom_id" groups="product.group_uom"/> - </tree> - </field> - </record> - - <record model="ir.ui.view" id="analytic_user_funct_grid_form"> - <field name="name">analytic_user_funct_grid.form</field> - <field name="model">analytic.user.funct.grid</field> - <field name="arch" type="xml"> - <form string="Invoicing Data"> - <group> - <field name="user_id" on_change="onchange_user_product_id(user_id, product_id)" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'base.group_sale_salesman']}"/> - <field name="product_id" domain="[('type','=','service')]" on_change="onchange_user_product_id(user_id, product_id)"/> - <field name="price"/> - <field name="uom_id" groups="product.group_uom"/> - </group> - </form> - </field> - </record> - - <!-- account.analytic.account inherited view --> - <record model="ir.ui.view" id="view_account_analytic_account_form_inherit"> - <field name="name">account.analytic.account.form</field> - <field name="model">account.analytic.account</field> - <field eval="60" name="priority"/> - <field name="inherit_id" ref="analytic.view_account_analytic_account_form"/> - <field name="arch" type="xml"> - <separator name="description" position="before"> - <div name="user_function_price" attrs="{'invisible': ['|',('invoice_on_timesheets','=',False),('contract_type','!=','regular')]}"> - <separator string="Invoice Price Rate per User"/> - <p class="oe_grey oe_edit_only"> - Define a specific service (e.g. Senior Consultant) - and price for some users to use these data instead - of the default values when invoicing the customer. - </p> - <p class="oe_grey oe_edit_only"> - Odoo will recursively search on parent accounts - to check if specific conditions are defined for a - specific user. This allows to set invoicing - conditions for a group of contracts. - </p> - <field name="user_product_ids"/> - </div> - </separator> - </field> - </record> - - <record model="ir.ui.view" id="hr_timesheet_line_tree_inherit"> - <field name="name">account.analytic.line.tree</field> - <field name="model">account.analytic.line</field> - <field name="inherit_id" ref="hr_timesheet_invoice.hr_timesheet_line_tree"/> - <field name="arch" type="xml"> - <xpath expr="/tree/field[@name='user_id']" position="replace"> - <field name="user_id" required="1" on_change="on_change_user_id(user_id, unit_amount, account_id, is_timesheet, context)" context="{'default_groups_ref': ['base.group_user']}"/> - </xpath> - </field> - </record> - </data> -</openerp> diff --git a/addons/analytic_user_function/security/ir.model.access.csv b/addons/analytic_user_function/security/ir.model.access.csv deleted file mode 100644 index e97dc28bca7..00000000000 --- a/addons/analytic_user_function/security/ir.model.access.csv +++ /dev/null @@ -1,7 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_analytic_user_funct_user,analytic user funct user,model_analytic_user_funct_grid,account.group_account_manager,1,0,0,0
-access_analytic_user_funct_manager,analytic user funct manager,model_analytic_user_funct_grid,account.group_account_manager,1,1,1,1
-access_analytic_user_funct_account_manager,analytic user funct account manager,model_analytic_user_funct_grid,account.group_account_manager,1,1,1,1
-access_analytic_user_funct_grid_hr_user,analytic user funct grid hr user,model_analytic_user_funct_grid,base.group_hr_user,1,0,0,0
-access_analytic_user_funct_grid_hr_manager,analytic user funct grid hr manager,model_analytic_user_funct_grid,base.group_hr_manager,1,1,1,1
-access_analytic_user_funct_grid_all,analytic user funct grid,model_analytic_user_funct_grid,base.group_user,1,0,0,0
|
