From 6f0b8abe3159831e67434c5938bc867a98b462dd Mon Sep 17 00:00:00 2001 From: "Sanjay Gohel (Open ERP)" Date: Thu, 13 Sep 2012 11:05:40 +0530 Subject: [PATCH] [IMP]account,project,project_issue: changed as per new spec bzr revid: sgo@tinyerp.com-20120913053540-atfsrw8bkf16qo3t --- addons/account/account_invoice.py | 33 +++++++--------- addons/account/data/account_data.xml | 26 ++++++------- addons/account_voucher/account_voucher.py | 8 ++-- addons/account_voucher/account_voucher_data.xml | 21 +++------- addons/analytic/analytic.py | 18 ++++++++- addons/base_status/base_stage.py | 14 ++++++- addons/project/project.py | 21 +++++----- addons/project/project_data.xml | 47 +++++++++++++---------- addons/project_issue/project_issue.py | 4 +- addons/project_issue/project_issue_data.xml | 25 ++++-------- 10 files changed, 109 insertions(+), 108 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 9dcbd87..8a7251b 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -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 created.") % (self._get_document_type(obj.type)), subtype="new", context=context) + self.message_post(cr, uid, [obj.id],body=_("%s created.") % (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 paid.") % (self._get_document_type(obj.type)), subtype="paid", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s paid.") % (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 cancelled.") % (self._get_document_type(obj.type)), subtype="cancelled", context=context) + self.message_post(cr, uid, [obj.id], body=_("%s cancelled.") % (self._get_document_type(obj.type)), subtype_xml_id="invoice_subtype_cancelled", context=context) account_invoice() class account_invoice_line(osv.osv): diff --git a/addons/account/data/account_data.xml b/addons/account/data/account_data.xml index bf3b315..22849a9 100644 --- a/addons/account/data/account_data.xml +++ b/addons/account/data/account_data.xml @@ -560,28 +560,24 @@ Invoice account.invoice - + new - + account.analytic.account - + + new + account.invoice + + + paid - + account.invoice - + cancelled - + account.invoice - - - - - - - - - diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index ae670b3..d297688 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -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 created." % 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 posted." % (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 reconciled." % 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() diff --git a/addons/account_voucher/account_voucher_data.xml b/addons/account_voucher/account_voucher_data.xml index a99a873..dd46a83 100644 --- a/addons/account_voucher/account_voucher_data.xml +++ b/addons/account_voucher/account_voucher_data.xml @@ -13,27 +13,18 @@ If you want to use advanced accounting features, you should install the "Account Module eInvoicing & Payments has been installed. - - + + account.voucher - + post - + account.voucher - + reconcile - + account.voucher - - - - - - - - - diff --git a/addons/analytic/analytic.py b/addons/analytic/analytic.py index a44fcb0..776df71 100644 --- a/addons/analytic/analytic.py +++ b/addons/analytic/analytic.py @@ -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 %s has been created.") % (obj.partner_id.name), subtype="new", context=context) + self.message_post(cr, uid, [obj.id], body=_("Contract for %s has been created.") % (obj.partner_id.name), subtype_xml_id="analytic_subtype_new", context=context) account_analytic_account() diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index 9bb2764..f72168c 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -362,17 +362,27 @@ class base_stage(object): msg = _('%s has been opened.') % (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 closed.') % (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 cancelled.') % (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): diff --git a/addons/project/project.py b/addons/project/project.py index e1dea8e..412e14f 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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 created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Project has been created."), subtype_xml_id="project_subtype_new", context=context) def set_open_send_note(self, cr, uid, ids, context=None): message = _("Project has been opened.") - 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 pending.") - 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 cancelled.") - 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 closed.") - 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 %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (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 created."), subtype="new", context=context) + return self.message_post(cr, uid, ids, body=_("Task has been created."), 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 draft.') diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index 34608d3..0544b6d 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -85,42 +85,47 @@ - + new - + project.project - + + new + project.task + + + open - + project.project - + pending - + project.project - + closed - + project.project - + + closed + project.task + + cancelled - + project.project - - stage change - + + cancelled + project.task - - - - - - - - + + stage change + project.task + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index d3f47ba..83eddb8 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -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 %s.") % (stage_name), subtype="stage change", context=context) + return self.message_post(cr, uid, ids, body= _("Stage changed to %s.") % (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 created.") - 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): diff --git a/addons/project_issue/project_issue_data.xml b/addons/project_issue/project_issue_data.xml index 6ee704c..f6c225a 100644 --- a/addons/project_issue/project_issue_data.xml +++ b/addons/project_issue/project_issue_data.xml @@ -32,33 +32,24 @@ - + new - + project.issue - + stage change - + project.issue - + cancelled - + project.issue - + closed - - - - - - - - - - + project.issue -- 1.7.10.4