[ADD]ADD notify for done task+add request in project invoice
This commit is contained in:
parent
d217898452
commit
8bb4059dce
|
|
@ -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
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
<xpath expr="//notebook" position="inside">
|
||||
<page string="Settings Allowed Users" groups="project.group_project_manager">
|
||||
<group>
|
||||
<field invisible="0" name="isdone"/>
|
||||
<field name="allowed_internal_user_ids" widget="many2many_tags" groups="project.group_project_manager"/>
|
||||
<field name="allowed_portal_user_ids" widget="many2many_tags" groups="project.group_project_manager" options="{'no_create': True}" />
|
||||
</group>
|
||||
|
|
|
|||
Loading…
Reference in New Issue