diff options
| author | Damien Bouvy <dbo@odoo.com> | 2015-03-03 14:25:44 +0100 |
|---|---|---|
| committer | Damien Bouvy <dbo@odoo.com> | 2015-07-23 11:40:30 +0200 |
| commit | ecdb8a60cb8645d400a06bcf80f49484bbe671b7 (patch) | |
| tree | 0d30644fc280f043d9ea7b1e78222dce0fb30427 /addons/analytic/models/analytic.py | |
| parent | d8f0231afc5ce94e2feb91b11fbfb45c52ae849e (diff) | |
[IMP] sale_contract: recurring view refactoring, new fields and unit of measure
- add contract_type field on account.analytic.account and real_quantity on account.analytic.invoice.line
- refactor contract form and list views for better clarity (hide unnecessary fields depending on the type of contract)
- divide account_analityc_account class according to contract type for future work
- divide contract template menu in 3 menus depending on contract_type
- add on_change_uom behaviour on account recurring lines
- rewrite tests in python
- add new report (pivot & graph)
- end date of contract is now computed from the template recurring rules
- small fixes & usability improvements
Diffstat (limited to 'addons/analytic/models/analytic.py')
| -rw-r--r-- | addons/analytic/models/analytic.py | 21 |
1 files changed, 19 insertions, 2 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), + } |
