diff --git a/odex25_project/project_base/models/project_invoice.py b/odex25_project/project_base/models/project_invoice.py index b7c95ba76..55c8b90cb 100644 --- a/odex25_project/project_base/models/project_invoice.py +++ b/odex25_project/project_base/models/project_invoice.py @@ -119,15 +119,6 @@ class ProjectInvoice(models.Model): action = self.env["ir.actions.actions"]._for_xml_id("account.action_move_out_invoice_type") form_view = [(self.env.ref('account.view_move_form').id, 'form')] - # if self.invoice_type == 'project': - # for line in self.project_invline_ids: - # line.order_line_id.phase_qty = line.product_uom_qty - # for line in self.project_downinv_ids: - # line.order_line_id.phase_qty = line.product_uom_qty > 0 and (line.product_uom_qty*-1) or line.product_uom_qty - # invoice_id = self.project_id.sale_order_id.\ - # with_context(due_date=self.plan_payment_date, analytic_account_id=self.project_id.analytic_account_id.id).\ - # _create_invoices(final=False) - # else: invoice_vals = self.with_company(self.company_id)._prepare_invoice() invoice_line_vals = [] for line in self.project_invline_ids: @@ -236,6 +227,18 @@ class ProjectInvoice(models.Model): raise ValidationError(_("You cannot Request Invoice for Project that is not in Open status!")) self._set_qty_invoiced() self.state = 'request' + user_ids = self.env.ref('project_base.group_project_create_invoice').users + self.env['mail.message'].create({ + 'message_type': "notification", + 'body': _("Invoice request created for project %s and need your action") % self.project_id.project_no, + 'subject': _("Invoice Request "), + 'partner_ids': [(6, 0, user_ids.mapped('partner_id').ids)], + 'notification_ids': [(0, 0, {'res_partner_id': user.partner_id.id, 'notification_type': 'inbox'}) + for user in user_ids if user_ids], + 'model': self._name, + 'res_id': self.id, + 'author_id': self.env.user.partner_id and self.env.user.partner_id.id + }) diff --git a/odex25_project/project_base/models/project_task.py b/odex25_project/project_base/models/project_task.py index ac9fe59d3..517c0120b 100644 --- a/odex25_project/project_base/models/project_task.py +++ b/odex25_project/project_base/models/project_task.py @@ -22,7 +22,7 @@ class ProjectTask(models.Model): allowed_internal_user_ids = fields.Many2many('res.users', 'project_task_allowed_internal_users_rel', string="Allowed Internal Users", default=lambda self: self.env.user, domain=[('share', '=', False)]) allowed_portal_user_ids = fields.Many2many('res.users', 'project_task_allowed_portal_users_rel', string="Allowed Portal Users", domain=[('share', '=', True)]) - + isdone= fields.Boolean(string='',compute='_compute_stage') @api.constrains('task_progress' , 'weight') def _check_task_weight_progress(self): @@ -56,6 +56,32 @@ class ProjectTask(models.Model): _("Total planned hours for all tasks in stage %s must not exceed Total stage hours %s") % ( record.phase_id.display_name, record.phase_hours)) + @api.depends('stage_id','stage_id.is_closed') + def _compute_stage(self): + self.isdone=False + for rec in self: + if rec.stage_id.is_closed: + # Get users from both groups + manager_users = self.env.ref('project.group_project_manager').users + department_manager_users = self.env.ref('project_base.group_project_department_manager').users + + # Combine both user sets + user_ids = manager_users | department_manager_users + + # Create a mail notification for users in both groups + self.env['mail.message'].create({ + 'message_type': "notification", + 'body': _("Invoice request created for project %s and needs your action") % rec.project_id.project_no, + 'subject': _("Invoice Request"), + 'partner_ids': [(6, 0, user_ids.mapped('partner_id').ids)], + 'notification_ids': [(0, 0, {'res_partner_id': user.partner_id.id, 'notification_type': 'inbox'}) + for user in user_ids if user.partner_id], + 'model': rec._name, + 'res_id': rec.id, + 'author_id': self.env.user.partner_id.id if self.env.user.partner_id else False + }) + + diff --git a/odex25_project/project_base/views/project_task_views.xml b/odex25_project/project_base/views/project_task_views.xml index 333a1f3eb..741c238bb 100644 --- a/odex25_project/project_base/views/project_task_views.xml +++ b/odex25_project/project_base/views/project_task_views.xml @@ -52,6 +52,7 @@ +