From 67a66d0ca47ec4a39c80182a192ea4c57ca704a0 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 28 Oct 2012 11:33:28 +0100 Subject: [PATCH] [IMP] Useability: contracts bzr revid: fp@openerp.com-20121028103328-qjqeznq9a95mcdpe --- .../account_analytic_analysis_view.xml | 22 ++++++--- addons/analytic/analytic.py | 2 +- .../analytic_user_function.py | 45 ++++++++++--------- .../analytic_user_function_view.xml | 41 ++++++++++++----- .../hr_timesheet_invoice.py | 3 +- 5 files changed, 71 insertions(+), 42 deletions(-) diff --git a/addons/account_analytic_analysis/account_analytic_analysis_view.xml b/addons/account_analytic_analysis/account_analytic_analysis_view.xml index 7678dc59f75..e1708cdd018 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis_view.xml +++ b/addons/account_analytic_analysis/account_analytic_analysis_view.xml @@ -116,13 +116,21 @@ - - +

+ When invoicing on timesheet, OpenERP uses the + pricelist of the contract which uses the price + defined on the product related to each employee to + define the customer invoice price rate. +

+ + + +
diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index 5ea8c59b848..369dbc829c2 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -156,7 +156,7 @@ class account_analytic_account(osv.osv): 'debit': fields.function(_debit_credit_bal_qtty, type='float', string='Debit', multi='debit_credit_bal_qtty', digits_compute=dp.get_precision('Account')), 'credit': fields.function(_debit_credit_bal_qtty, type='float', string='Credit', multi='debit_credit_bal_qtty', digits_compute=dp.get_precision('Account')), 'quantity': fields.function(_debit_credit_bal_qtty, type='float', string='Quantity', multi='debit_credit_bal_qtty'), - 'quantity_max': fields.float('Prepaid Units', help='Sets the higher limit of time to work on the contract.'), + 'quantity_max': fields.float('Prepaid Units', help='Sets the higher limit of time to work on the contract, based on the timesheet.'), 'partner_id': fields.many2one('res.partner', 'Customer'), 'user_id': fields.many2one('res.users', 'Project Manager'), 'manager_id': fields.many2one('res.users', 'Account Manager'), diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 9233845f7eb..c3338cd3c84 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -21,39 +21,51 @@ from osv import fields,osv from tools.translate import _ +import decimal_precision as dp class analytic_user_funct_grid(osv.osv): - _name="analytic.user.funct.grid" - _description= "Relation table between users and products on a analytic account" + _description= "Price per User" _columns={ 'user_id': fields.many2one("res.users", "User", required=True,), - 'product_id': fields.many2one("product.product", "Product", 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 {} -analytic_user_funct_grid() + value = {} + 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 product_id: + prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context) + 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.'), } -account_analytic_account() - class hr_analytic_timesheet(osv.osv): - _inherit = "hr.analytic.timesheet" - - # 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): - temp=self.pool.get('analytic.user.funct.grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) account=self.pool.get('account.analytic.account').browse(cr, uid, account_id) if temp: @@ -64,7 +76,6 @@ class hr_analytic_timesheet(osv.osv): else: return False - def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0): res = {} if not (account_id): @@ -106,12 +117,6 @@ class hr_analytic_timesheet(osv.osv): return res def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0): - res = {} - if not (user_id): - #avoid a useless call to super - return res - - #get the old values from super res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id) if account_id: @@ -143,5 +148,3 @@ class hr_analytic_timesheet(osv.osv): hr_analytic_timesheet() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/analytic_user_function/analytic_user_function_view.xml b/addons/analytic_user_function/analytic_user_function_view.xml index 6fa141f480d..490b3026d7f 100644 --- a/addons/analytic_user_function/analytic_user_function_view.xml +++ b/addons/analytic_user_function/analytic_user_function_view.xml @@ -7,9 +7,11 @@ analytic_user_funct_grid.tree analytic.user.funct.grid - - - + + + + + @@ -18,9 +20,13 @@ analytic_user_funct_grid.form analytic.user.funct.grid -
- - + + + + + + + @@ -29,13 +35,26 @@ account.analytic.account.form account.analytic.account + - - - - - + +
+ +

+ 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. +

+

+ OpenERP 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. +

+ +
+
diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 67fcb100468..88094b4a0e0 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -70,8 +70,7 @@ class account_analytic_account(osv.osv): 'amount_invoiced': fields.function(_invoiced_calc, string='Invoiced Amount', help="Total invoiced"), 'to_invoice': fields.many2one('hr_timesheet_invoice.factor', 'Timesheet Invoicing Ratio', - help="This field allows you to define the rate in case you plan to reinvoice " \ - "the costs in this analytic account: timesheets, expenses, ..."), + help="You usually invoice 100% of the timesheets. But if you mix fixed price and timesheet invoicing, you may use another ratio. For instance, if you do a 20% advance invoice (fixed price, based on a sale order), you should invoice the rest on timesheet with a 80% ratio."), } _defaults = { 'pricelist_id': lambda self, cr, uid, ctx: ctx.get('pricelist_id', False),