diff options
Diffstat (limited to 'addons/analytic')
| -rw-r--r-- | addons/analytic/models/analytic.py | 21 | ||||
| -rw-r--r-- | addons/analytic/views/analytic_view.xml | 41 |
2 files changed, 34 insertions, 28 deletions
diff --git a/addons/analytic/models/analytic.py b/addons/analytic/models/analytic.py index 411476b1823..346d1d00877 100644 --- a/addons/analytic/models/analytic.py +++ b/addons/analytic/models/analytic.py @@ -156,6 +156,11 @@ class account_analytic_account(osv.osv): result[rec.id] = rec.currency_id.id return result + def _get_contract_type_selection(self, cr, uid, context=None): + return [('regular', 'Regular'), ('prepaid', 'Prepaid Support Hours')] + + _contract_type_selection = lambda self, *args, **kwargs: self._get_contract_type_selection(*args, **kwargs) + _columns = { 'name': fields.char('Account/Contract Name', required=True, track_visibility='onchange'), 'complete_name': fields.function(_get_full_name, type='char', string='Full Name'), @@ -178,7 +183,7 @@ class account_analytic_account(osv.osv): 'quantity_max': fields.float('Prepaid Service Units', help='Sets the higher limit of time to work on the contract, based on the timesheet. (for instance, number of hours in a limited support contract.)'), 'partner_id': fields.many2one('res.partner', 'Customer'), 'user_id': fields.many2one('res.users', 'Project Manager', track_visibility='onchange'), - 'manager_id': fields.many2one('res.users', 'Account Manager', track_visibility='onchange'), + 'manager_id': fields.many2one('res.users', 'Sales Rep', track_visibility='onchange'), 'date_start': fields.date('Start Date'), 'date': fields.date('Expiration Date', select=True, track_visibility='onchange'), 'company_id': fields.many2one('res.company', 'Company', required=False), #not required because we want to allow different companies to use the same chart of account, except for leaf accounts. @@ -188,6 +193,7 @@ class account_analytic_account(osv.osv): store = { 'res.company': (_get_analytic_account, ['currency_id'], 10), }, string='Currency', type='many2one', relation='res.currency'), + 'contract_type': fields.selection(_contract_type_selection, 'Type of Contract', required=True), } def create(self, cr, uid, vals, context=None): @@ -217,6 +223,7 @@ class account_analytic_account(osv.osv): res['value']['quantity_max'] = template.quantity_max res['value']['parent_id'] = template.parent_id and template.parent_id.id or False res['value']['description'] = template.description + res['value']['contract_type'] = template.contract_type return res def on_change_partner_id(self, cr, uid, ids,partner_id, name, context=None): @@ -249,6 +256,7 @@ class account_analytic_account(osv.osv): 'manager_id': lambda self, cr, uid, ctx: ctx.get('manager_id', False), 'date_start': lambda *a: time.strftime('%Y-%m-%d'), 'currency_id': _get_default_currency, + 'contract_type': 'regular', } def check_recursion(self, cr, uid, ids, context=None, parent=None): @@ -335,6 +343,7 @@ class account_analytic_line(osv.osv): 'user_id': fields.many2one('res.users', 'User'), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True), 'journal_id': fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='restrict', select=True), + 'partner_id': fields.related('account_id', 'partner_id', type='many2one', relation='res.partner', string='Partner', store=True), } @@ -364,7 +373,6 @@ class account_analytic_line(osv.osv): (_check_no_view, 'You cannot create analytic line on view account.', ['account_id']), ] - class account_analytic_journal(osv.osv): _name = 'account.analytic.journal' _description = 'Analytic Journal' @@ -384,3 +392,12 @@ class account_analytic_journal(osv.osv): 'type': 'general', 'company_id': lambda self, cr, uid, c=None: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id, } + +class res_partner(osv.osv): + """ Inherits partner and adds contract information in the partner form """ + _inherit = 'res.partner' + + _columns = { + 'contract_ids': fields.one2many('account.analytic.account', \ + 'partner_id', 'Contracts', readonly=True), + } diff --git a/addons/analytic/views/analytic_view.xml b/addons/analytic/views/analytic_view.xml index 22620c0d7c3..a848b3d0a24 100644 --- a/addons/analytic/views/analytic_view.xml +++ b/addons/analytic/views/analytic_view.xml @@ -6,7 +6,7 @@ <field name="name">analytic.analytic.account.form</field> <field name="model">account.analytic.account</field> <field name="arch" type="xml"> - <form string="Analytic Account" version="7.0"> + <form string="Analytic Account"> <sheet string="Analytic Account"> <div class="oe_button_box" name="button_box"/> @@ -20,39 +20,28 @@ <group name="main"> <group> - <field name="partner_id" on_change="on_change_partner_id(partner_id, name)"/> - <field name="manager_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_manager']}"/> - <field name="currency_id" attrs="{'invisible': ['|',('type', '<>', 'view'), ('company_id', '<>', False)]}"/> + <field name="partner_id" on_change="on_change_partner_id(partner_id, name)" attrs="{'invisible': [('type','in',['view','normal','template'])]}"/> + <field name="manager_id" context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'account.group_account_manager']}" attrs="{'invisible': [('type','in',['view','normal','template'])]}"/> + <field name="contract_type" widget="radio" attrs="{'invisible': ['|',('template_id','!=',False),('type','in',['view','normal'])]}"/> </group> <group> <field name="type" invisible="context.get('default_type', False)"/> - <field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/> - <field name="code"/> - <field name="parent_id" on_change="on_change_parent(parent_id)"/> + <field name="template_id" on_change="on_change_template(template_id, date_start)" domain="[('type','=','template'),('state','=','open')]" attrs="{'invisible': [('type','in',['view', 'normal','template'])]}" context="{'default_type' : 'template'}"/> + <field name="code" attrs="{'invisible': [('type','=','template')]}"/> + <field name="parent_id" on_change="on_change_parent(parent_id)" attrs="{'invisible': [('type','in',['contract'])]}"/> + <field name="currency_id" attrs="{'invisible': ['|',('type', '<>', 'view'), ('company_id', '<>', False)]}"/> <field name="company_id" on_change="on_change_company(company_id)" options="{'no_create': True}" groups="base.group_multi_company" attrs="{'required': [('type','<>','view')]}"/> + <field name="date_start" attrs="{'invisible': [('type','in',['view','normal','template'])]}"/> + <label for="date" string="End Date" attrs="{'invisible': [('type','in',['view','normal','template'])]}"/> + <div name="duration" attrs="{'invisible': [('type','=','template')]}"> + <field name="date" class="oe_inline"/> + </div> </group> </group> <notebook> - <page string="Contract Information" name="contract_page" attrs="{'invisible':[('type','not in',['contract', 'template'])]}"> - <group string="Renewal" name="contract"> - <p colspan="2" class="oe_grey oe_edit_only"> - Once the end date of the contract is - passed or the maximum number of service - units (e.g. support contract) is - reached, the account manager is notified - by email to renew the contract with the - customer. - </p> - <field name="date_start"/> - <label for="date" string="End Date"/> - <div name="duration"> - <field name="date" class="oe_inline"/> - </div> - </group> - <separator string="Terms and Conditions" name="description"/> - <field name="description"/> - </page> </notebook> + <separator string="Terms and Conditions" name="description" attrs="{'invisible': [('type','in',['view','normal'])]}"/> + <field name="description" attrs="{'invisible': [('type','in',['view','normal'])]}"/> </sheet> <div class="oe_chatter"> <field name="message_follower_ids" widget="mail_followers"/> |
