[IMP] Analytic, hr_timesheet_invoice: moved chatter and subtypes for analytic into analytic; removed salesteam-related subtypes.

bzr revid: tde@openerp.com-20121219173127-xcz1j92p46sn6qu3
This commit is contained in:
Thibault Delavallée 2012-12-19 18:31:27 +01:00
parent 86200b4d9c
commit d53a63d563
3 changed files with 12 additions and 49 deletions

View File

@ -31,6 +31,13 @@ class account_analytic_account(osv.osv):
_name = 'account.analytic.account'
_inherit = ['mail.thread']
_description = 'Analytic Account'
_track = {
'state': {
'analytic.mt_account_pending': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'pending',
'analytic.mt_account_closed': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'close',
'analytic.mt_account_opened': lambda self, cr, uid, obj, ctx=None: obj['state'] == 'open',
},
}
def _compute_level_tree(self, cr, uid, ids, child_ids, res, field_names, context=None):
currency_obj = self.pool.get('res.currency')
@ -189,7 +196,7 @@ class account_analytic_account(osv.osv):
'date_start': fields.date('Start Date'),
'date': fields.date('Date End', select=True),
'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.
'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','To Renew'),('close','Closed')], 'Status', required=True,),
'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','To Renew'),('close','Closed')], 'Status', required=True, track_visibility=1),
'currency_id': fields.function(_currency, fnct_inv=_set_company_currency, #the currency_id field is readonly except if it's a view account and if there is no company
store = {
'res.company': (_get_analytic_account, ['currency_id'], 10),

View File

@ -87,30 +87,16 @@ class account_analytic_account(osv.osv):
return res
def set_close(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'close'}, context=context)
message = _("Contract has been <b>closed</b>.")
self.message_post(cr, uid, ids, body=message, subtype="hr_timesheet_invoice.mt_account_closed", context=context)
return True
return self.write(cr, uid, ids, {'state': 'close'}, context=context)
def set_cancel(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'cancelled'}, context=context)
message = _("Contract has been <b>canceled</b>.")
self.message_post(cr, uid, ids, body=message, context=context)
return True
return self.write(cr, uid, ids, {'state': 'cancelled'}, context=context)
def set_open(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'open'}, context=context)
message = _("Contract has been <b>opened</b>.")
self.message_post(cr, uid, ids, body=message, subtype="hr_timesheet_invoice.mt_account_renewed", context=context)
return True
return self.write(cr, uid, ids, {'state': 'open'}, context=context)
def set_pending(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'pending'}, context=context)
message = _("Contract has been set as <b>pending</b>.")
self.message_post(cr, uid, ids, body=message, subtype="hr_timesheet_invoice.mt_account_renew", context=context)
return True
account_analytic_account()
return self.write(cr, uid, ids, {'state': 'pending'}, context=context)
class account_analytic_line(osv.osv):

View File

@ -22,35 +22,5 @@
<field name="factor">20.0</field>
</record>
<!-- Analytic-account-related subtypes for messaging / Chatter -->
<record id="mt_account_renew" model="mail.message.subtype">
<field name="name">Contract to Renew</field>
<field name="res_model">account.analytic.account</field>
</record>
<record id="mt_account_closed" model="mail.message.subtype">
<field name="name">Contract Finished</field>
<field name="res_model">account.analytic.account</field>
</record>
<record id="mt_account_renewed" model="mail.message.subtype">
<field name="name">Contract Renewed</field>
<field name="res_model">account.analytic.account</field>
</record>
<!-- Salesteam-related subtypes for messaging / Chatter -->
<record id="mt_salesteam_renew" model="mail.message.subtype">
<field name="name">Contract to Renew</field>
<field name="res_model">crm.case.section</field>
<field name="default" eval="False"/>
</record>
<record id="mt_salesteam_finished" model="mail.message.subtype">
<field name="name">Contract Finished</field>
<field name="res_model">crm.case.section</field>
<field name="default" eval="False"/>
</record>
<record id="mt_salesteam_renewed" model="mail.message.subtype">
<field name="name">Contract Renewed</field>
<field name="res_model">crm.case.section</field>
<field name="default" eval="False"/>
</record>
</data>
</openerp>