[IMP] Useability: contracts
bzr revid: fp@openerp.com-20121028103328-qjqeznq9a95mcdpe
This commit is contained in:
parent
a1b8d8c72c
commit
67a66d0ca4
|
@ -116,13 +116,21 @@
|
|||
</tr>
|
||||
</table>
|
||||
<group name='invoice_on_timesheets' attrs="{'invisible': [('invoice_on_timesheets','=',False)]}">
|
||||
<field name="pricelist_id"
|
||||
class="oe_inline"
|
||||
attrs="{'required': [('invoice_on_timesheets', '=', True)]}"/>
|
||||
<field name="to_invoice"
|
||||
class="oe_inline"
|
||||
widget="selection"
|
||||
attrs="{'required': [('invoice_on_timesheets', '=', True)]}"/>
|
||||
<p class="oe_grey oe_edit_only" colspan="2">
|
||||
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.
|
||||
</p>
|
||||
<group>
|
||||
<field name="pricelist_id"
|
||||
class="oe_inline"
|
||||
attrs="{'required': [('invoice_on_timesheets', '=', True)]}"/>
|
||||
<field name="to_invoice"
|
||||
class="oe_inline"
|
||||
widget="selection"
|
||||
attrs="{'required': [('invoice_on_timesheets', '=', True)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
|
|
|
@ -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'),
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
<field name="name">analytic_user_funct_grid.tree</field>
|
||||
<field name="model">analytic.user.funct.grid</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="User's Product for this Analytic Account" editable="bottom">
|
||||
<field name="user_id" required="1"/>
|
||||
<field name="product_id" required="1" />
|
||||
<tree string="Invoicing Data" editable="bottom">
|
||||
<field name="user_id" on_change="onchange_user_product_id(user_id, product_id)"/>
|
||||
<field name="product_id" on_change="onchange_user_product_id(user_id, product_id)" domain="[('type','=','service')]"/>
|
||||
<field name="price"/>
|
||||
<field name="uom_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -18,9 +20,13 @@
|
|||
<field name="name">analytic_user_funct_grid.form</field>
|
||||
<field name="model">analytic.user.funct.grid</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="User's Product for this Analytic Account">
|
||||
<field name="user_id" required="1"/>
|
||||
<field name="product_id" required="1"/>
|
||||
<form string="Invoicing Data">
|
||||
<group>
|
||||
<field name="user_id" on_change="onchange_user_product_id(user_id, product_id)"/>
|
||||
<field name="product_id" domain="[('type','=','service')]" on_change="onchange_user_product_id(user_id, product_id)"/>
|
||||
<field name="price"/>
|
||||
<field name="uom_id"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -29,13 +35,26 @@
|
|||
<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">
|
||||
<xpath expr="//notebook/page" position="after">
|
||||
<page string="Users/Products Rel.">
|
||||
<field name="user_product_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</xpath>
|
||||
<separator name="description" position="before">
|
||||
<div name="user_function_price" attrs="{'invisible': [('invoice_on_timesheets','=',False)]}">
|
||||
<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">
|
||||
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.
|
||||
</p>
|
||||
<field name="user_product_ids"/>
|
||||
</div>
|
||||
</separator>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue