[IMP]account,project,project_issue: changed as per new spec

bzr revid: sgo@tinyerp.com-20120913053540-atfsrw8bkf16qo3t
This commit is contained in:
Sanjay Gohel (Open ERP) 2012-09-13 11:05:40 +05:30
parent ce39ffe927
commit 6f0b8abe31
10 changed files with 109 additions and 108 deletions

View File

@ -395,23 +395,18 @@ class account_invoice(osv.osv):
template_id = template and template[1] or False
res = mod_obj.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')
res_id = res and res[1] or False
ctx = dict(context)
ctx.update({
'default_model': 'account.invoice',
'default_res_id': ids[0],
'default_use_template': True,
'default_template_id': template_id,
})
ctx = dict(context, active_model='account.invoice', active_id=ids[0])
ctx.update({'mail.compose.template_id': template_id})
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(res_id, 'form')],
'view_id': res_id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': ctx,
'nodestroy': True,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(res_id, 'form')],
'view_id': res_id,
'type': 'ir.actions.act_window',
'target': 'new',
'context': ctx,
'nodestroy': True,
}
def confirm_paid(self, cr, uid, ids, context=None):
@ -1306,15 +1301,15 @@ class account_invoice(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_post(cr, uid, [obj.id],body=_("%s <b>created</b>.") % (self._get_document_type(obj.type)), subtype="new", context=context)
self.message_post(cr, uid, [obj.id],body=_("%s <b>created</b>.") % (self._get_document_type(obj.type)), subtype_xml_id="analytic_subtype_new", context=context)
def confirm_paid_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_post(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)), subtype="paid", context=context)
self.message_post(cr, uid, [obj.id], body=_("%s <b>paid</b>.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_paid", context=context)
def invoice_cancel_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_post(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context)
self.message_post(cr, uid, [obj.id], body=_("%s <b>cancelled</b>.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context)
account_invoice()
class account_invoice_line(osv.osv):

View File

@ -560,28 +560,24 @@
<field name="name">Invoice</field>
<field name="object">account.invoice</field>
</record>
<record id="mail.mail_subtype_new" model="mail.message.subtype">
<record id="mail.analytic_subtype_new" model="mail.message.subtype">
<field name="name">new</field>
<field name="model_ids" eval="[(4,ref('analytic.model_account_analytic_account')),(4,ref('account.model_account_invoice'))]"/>
<field name="res_model">account.analytic.account</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_paid" model="mail.message.subtype">
<record id="mail.invoice_subtype_new" model="mail.message.subtype">
<field name="name">new</field>
<field name="res_model">account.invoice</field>
<field name="default" eval="False"/>
</record>
<record id="mail.invoice_subtype_paid" model="mail.message.subtype">
<field name="name">paid</field>
<field name="model_ids" eval="[(4,ref('account.model_account_invoice'))]"/>
<field name="res_model">account.invoice</field>
</record>
<record id="mail.mail_subtype_cancelled" model="mail.message.subtype">
<record id="mail.invoice_subtype_cancelled" model="mail.message.subtype">
<field name="name">cancelled</field>
<field name="model_ids" eval="[(4,ref('account.model_account_invoice'))]"/>
<field name="res_model">account.invoice</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_email" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account.model_account_invoice')), (4,ref('analytic.model_account_analytic_account'))]"/>
</record>
<record id="mail.mail_subtype_comment" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account.model_account_invoice')), (4,ref('analytic.model_account_analytic_account'))]"/>
</record>
<record id="mail.mail_subtype_other" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account.model_account_invoice')), (4,ref('analytic.model_account_analytic_account'))]"/>
</record>
</data>
</openerp>

View File

@ -1045,8 +1045,6 @@ class account_voucher(osv.osv):
# if the amount encoded in voucher is equal to the amount unreconciled, we need to compute the
# currency rate difference
if line.amount == line.amount_unreconciled:
if not line.move_line_id.amount_residual:
raise osv.except_osv(_('Wrong bank statement line'),_("You have to delete the bank statement line which the payment was reconciled to manually. Please check the payment of the partner %s by the amount of %s.")%(line.voucher_id.partner_id.name, line.voucher_id.amount))
currency_rate_difference = line.move_line_id.amount_residual - amount
else:
currency_rate_difference = 0.0
@ -1295,17 +1293,17 @@ class account_voucher(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s <b>created</b>." % self._document_type[obj.type or False]
self.message_post(cr, uid, [obj.id], body=message, subtype="new", context=context)
self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_new", context=context)
def post_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s '%s' is <b>posted</b>." % (self._document_type[obj.type or False], obj.move_id.name)
self.message_post(cr, uid, [obj.id], body=message, subtype="post", context=context)
self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_post", context=context)
def reconcile_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
message = "%s <b>reconciled</b>." % self._document_type[obj.type or False]
self.message_post(cr, uid, [obj.id], body=message, subtype="reconcile", context=context)
self.message_post(cr, uid, [obj.id], body=message, subtype_xml_id="voucher_subtype_reconcile", context=context)
account_voucher()

View File

@ -13,27 +13,18 @@ If you want to use advanced accounting features, you should install the "Account
<value>Module eInvoicing &amp; Payments has been installed.</value>
</function>
<!-- Message Sub Type -->
<record id="mail.mail_subtype_new" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
<record id="mail.voucher_subtype_new" model="mail.message.subtype">
<field name="res_model">account.voucher</field>
</record>
<record id="mail.mail_subtype_post" model="mail.message.subtype">
<record id="mail.voucher_subtype_post" model="mail.message.subtype">
<field name="name">post</field>
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
<field name="res_model">account.voucher</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_reconcile" model="mail.message.subtype">
<record id="mail.voucher_subtype_reconcile" model="mail.message.subtype">
<field name="name">reconcile</field>
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
<field name="res_model">account.voucher</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_email" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
</record>
<record id="mail.mail_subtype_comment" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
</record>
<record id="mail.mail_subtype_other" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('account_voucher.model_account_voucher'))]"/>
</record>
</data>
</openerp>

View File

@ -96,6 +96,22 @@ class account_analytic_account(osv.osv):
res[row['id']][field] = row[field]
return self._compute_level_tree(cr, uid, ids, child_ids, res, fields, context)
def name_get(self, cr, uid, ids, context=None):
if isinstance(ids, (int, long)):
ids=[ids]
if not ids:
return []
res = []
for account in self.browse(cr, uid, ids, context=context):
data = []
acc = account
while acc:
data.insert(0, acc.name)
acc = acc.parent_id
data = ' / '.join(data)
res.append((account.id, data))
return res
def _complete_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
res = self.name_get(cr, uid, ids)
return dict(res)
@ -281,7 +297,7 @@ class account_analytic_account(osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_post(cr, uid, [obj.id], body=_("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), subtype="new", context=context)
self.message_post(cr, uid, [obj.id], body=_("Contract for <em>%s</em> has been <b>created</b>.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context)
account_analytic_account()

View File

@ -362,17 +362,27 @@ class base_stage(object):
msg = _('%s has been <b>opened</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_post(cr, uid, [id], body=msg, context=context)
return True
def find_xml_id(self,cr,uid,ids,name,context=None):
subtype_obj = self.pool.get('mail.message.subtype')
irmodel_obj = self.pool.get('ir.model.data')
subtype_id = subtype_obj.search(cr,uid,[('res_model','=',self._name),('name','=',name)])
ir_ids = irmodel_obj.search(cr,uid,[('model','=','mail.message.subtype'),('res_id','=',subtype_id)])
ir_model_browse = irmodel_obj.browse(cr,uid,ir_ids)
return ir_model_browse.name
def case_close_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>closed</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_post(cr, uid, [id], body=msg, subtype="closed", context=context)
xml_id = self.find_xml_id(cr, uid, ids, name="closed", context)
self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context)
return True
def case_cancel_send_note(self, cr, uid, ids, context=None):
for id in ids:
msg = _('%s has been <b>cancelled</b>.') % (self.case_get_note_msg_prefix(cr, uid, id, context=context))
self.message_post(cr, uid, [id], body=msg, subtype="cancelled", context=context)
xml_id = self.find_xml_id(cr, uid, ids, name="cancelled", context)
self.message_post(cr, uid, [id], body=msg, subtype_xml_id=xml_id, context=context)
return True
def case_pending_send_note(self, cr, uid, ids, context=None):

View File

@ -41,9 +41,8 @@ class project_task_type(osv.osv):
'case_default': fields.boolean('Common to All Projects',
help="If you check this field, this stage will be proposed by default on each new project. It will not assign this stage to existing projects."),
'project_ids': fields.many2many('project.project', 'project_task_type_rel', 'type_id', 'project_id', 'Projects'),
'state': fields.selection(_TASK_STATE, 'Related Status', required=True,
help="The status of your document is automatically changed regarding the selected stage. " \
"For example, if a stage is related to the status 'Close', when your document reaches this stage, it is automatically closed."),
'state': fields.selection(_TASK_STATE, 'State', required=True,
help="The related state for the stage. The state of your document will automatically change regarding the selected stage. Example, a stage is related to the state 'Close', when your document reach this stage, it will be automatically closed."),
'fold': fields.boolean('Hide in views if empty',
help="This stage is not visible, for example in status bar or kanban view, when there are no records in that stage to display."),
}
@ -514,23 +513,23 @@ def Project():
return project_id
def create_send_note(self, cr, uid, ids, context=None):
return self.message_post(cr, uid, ids, body=_("Project has been <b>created</b>."), subtype="new", context=context)
return self.message_post(cr, uid, ids, body=_("Project has been <b>created</b>."), subtype_xml_id="project_subtype_new", context=context)
def set_open_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>opened</b>.")
return self.message_post(cr, uid, ids, body=message, subtype="open", context=context)
return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_open", context=context)
def set_pending_send_note(self, cr, uid, ids, context=None):
message = _("Project is now <b>pending</b>.")
return self.message_post(cr, uid, ids, body=message, subtype="pending", context=context)
return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_pending", context=context)
def set_cancel_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>cancelled</b>.")
return self.message_post(cr, uid, ids, body=message, subtype="cancelled", context=context)
return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_cancelled", context=context)
def set_close_send_note(self, cr, uid, ids, context=None):
message = _("Project has been <b>closed</b>.")
return self.message_post(cr, uid, ids, body=message, subtype="closed", context=context)
return self.message_post(cr, uid, ids, body=message, subtype_xml_id="project_subtype_closed", context=context)
def write(self, cr, uid, ids, vals, context=None):
# if alias_model has been changed, update alias_model_id accordingly
@ -728,7 +727,7 @@ class task(base_stage, osv.osv):
When the case is over, the state is set to \'Done\'.\
If the case needs to be reviewed then the state is \
set to \'Pending\'.'),
'categ_ids': fields.many2many('project.category', string='Tags'),
'categ_ids': fields.many2many('project.category', string='Categories'),
'kanban_state': fields.selection([('normal', 'Normal'),('blocked', 'Blocked'),('done', 'Ready To Pull')], 'Kanban State',
help="A task's kanban state indicates special situations affecting it:\n"
" * Normal is the default situation\n"
@ -1231,10 +1230,10 @@ class task(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), subtype="stage change", context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), subtype_xml_id="task_subtype_stage_change", context=context)
def create_send_note(self, cr, uid, ids, context=None):
return self.message_post(cr, uid, ids, body=_("Task has been <b>created</b>."), subtype="new", context=context)
return self.message_post(cr, uid, ids, body=_("Task has been <b>created</b>."), subtype_xml_id="task_subtype_new", context=context)
def case_draft_send_note(self, cr, uid, ids, context=None):
msg = _('Task has been set as <b>draft</b>.')

View File

@ -85,43 +85,48 @@
</record>
<!-- SUBTYPE -->
<record id="mail.mail_subtype_new" model="mail.message.subtype">
<record id="mail.project_subtype_new" model="mail.message.subtype">
<field name="name">new</field>
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_open" model="mail.message.subtype">
<record id="mail.task_subtype_new" model="mail.message.subtype">
<field name="name">new</field>
<field name="res_model">project.task</field>
<field name="default" eval="False"/>
</record>
<record id="mail.project_subtype_open" model="mail.message.subtype">
<field name="name">open</field>
<field name="model_ids" eval="[(4,ref('project.model_project_project'))]"/>
<field name="res_model">project.project</field>
</record>
<record id="mail.mail_subtype_pending" model="mail.message.subtype">
<record id="mail.project_subtype_pending" model="mail.message.subtype">
<field name="name">pending</field>
<field name="model_ids" eval="[(4,ref('project.model_project_project'))]"/>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_closed" model="mail.message.subtype">
<record id="mail.project_subtype_closed" model="mail.message.subtype">
<field name="name">closed</field>
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
<field name="res_model">project.project</field>
</record>
<record id="mail.mail_subtype_cancelled" model="mail.message.subtype">
<record id="mail.task_subtype_closed" model="mail.message.subtype">
<field name="name">closed</field>
<field name="res_model">project.task</field>
</record>
<record id="mail.project_subtype_cancelled" model="mail.message.subtype">
<field name="name">cancelled</field>
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_stage_change" model="mail.message.subtype">
<record id="mail.task_subtype_cancelled" model="mail.message.subtype">
<field name="name">cancelled</field>
<field name="res_model">project.task</field>
<field name="default" eval="False"/>
</record>
<record id="mail.task_subtype_stage_change" model="mail.message.subtype">
<field name="name">stage change</field>
<field name="model_ids" eval="[(4,ref('project.model_project_task'))]"/>
<field name="res_model">project.task</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_email" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
</record>
<record id="mail.mail_subtype_comment" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
</record>
<record id="mail.mail_subtype_other" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project.model_project_project')),(4,ref('project.model_project_task'))]"/>
</record>
<!-- notify all employees of module installation -->
<record model="mail.message" id="module_install_notification">

View File

@ -503,7 +503,7 @@ class project_issue(base_stage, osv.osv):
def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
""" Override of the (void) default notification method. """
stage_name = self.pool.get('project.task.type').name_get(cr, uid, [stage_id], context=context)[0][1]
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), subtype="stage change", context=context)
return self.message_post(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), subtype_xml_id="issue_subtype_stage_change", context=context)
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
""" Override of default prefix for notifications. """
@ -515,7 +515,7 @@ class project_issue(base_stage, osv.osv):
def create_send_note(self, cr, uid, ids, context=None):
message = _("Project issue <b>created</b>.")
return self.message_post(cr, uid, ids, body=message, subtype="new", context=context)
return self.message_post(cr, uid, ids, body=message, subtype_xml_id="issue_subtype_new", context=context)
def case_escalate_send_note(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):

View File

@ -32,33 +32,24 @@
</record>
<!--Sub type Data -->
<record id="mail.mail_subtype_new" model="mail.message.subtype">
<record id="mail.issue_subtype_new" model="mail.message.subtype">
<field name="name">new</field>
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
<field name="res_model">project.issue</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_stage_change" model="mail.message.subtype">
<record id="mail.issue_subtype_stage_change" model="mail.message.subtype">
<field name="name">stage change</field>
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
<field name="res_model">project.issue</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_cancelled" model="mail.message.subtype">
<record id="mail.issue_subtype_cancelled" model="mail.message.subtype">
<field name="name">cancelled</field>
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
<field name="res_model">project.issue</field>
<field name="default" eval="False"/>
</record>
<record id="mail.mail_subtype_closed" model="mail.message.subtype">
<record id="mail.issue_subtype_closed" model="mail.message.subtype">
<field name="name">closed</field>
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
</record>
<record id="mail.mail_subtype_email" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
</record>
<record id="mail.mail_subtype_comment" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
</record>
<record id="mail.mail_subtype_other" model="mail.message.subtype">
<field name="model_ids" eval="[(4,ref('project_issue.model_project_issue'))]"/>
<field name="res_model">project.issue</field>
</record>
<!-- notify all employees of module installation -->
<record model="mail.message" id="module_install_notification">