diff --git a/shopinvader_api_unit_member/security/res_partner.xml b/shopinvader_api_unit_member/security/res_partner.xml index 1e7df244e9..1104199958 100644 --- a/shopinvader_api_unit_member/security/res_partner.xml +++ b/shopinvader_api_unit_member/security/res_partner.xml @@ -14,9 +14,15 @@ name="groups" eval="[(4, ref('shopinvader_api_unit_member.shopinvader_unit_management_user_group'))]" /> - ['|', ('unit_id.manager_ids','=',authenticated_partner_id), ('manager_ids','=',authenticated_partner_id)] + [ + '|', + ('manager_ids','=',authenticated_partner_id), + '|', + ('unit_id.manager_ids','=',authenticated_partner_id), + '|', + ('parent_id.manager_ids','=',authenticated_partner_id), + ('parent_id.unit_id.manager_ids','=',authenticated_partner_id) + ] diff --git a/shopinvader_api_unit_request/models/sale_order.py b/shopinvader_api_unit_request/models/sale_order.py index 840739422c..7f8ea536cb 100644 --- a/shopinvader_api_unit_request/models/sale_order.py +++ b/shopinvader_api_unit_request/models/sale_order.py @@ -69,29 +69,44 @@ def action_confirm(self): ] |= line for partner, lines in request_lines_by_partner.items(): - message = "" - if lines["accepted"]: - message += _("Your following requests have been accepted:\n") - for line in lines["accepted"]: - message += f"{line.product_id.name} - {line.product_uom_qty}\n" - - if lines["rejected"]: - message += _("Your following requests have been rejected:\n") - for line in lines["rejected"]: - message += f"{line.product_id.name} - {line.product_uom_qty}" - if line.request_rejection_reason: - message += f": {line.request_rejection_reason}" - message += "\n" - if not message: + if not lines["accepted"] and not lines["rejected"]: continue - partner.message_post( - body=message, - subject=_("Request feedback for order %s") % record.name, - subtype_id=self.env.ref("mail.mt_comment").id, + self._notify_partner_on_request_feedback( + partner, lines["accepted"], lines["rejected"] ) return res + def _notify_partner_on_request_feedback( + self, partner, accepted_lines, rejected_lines + ): + """Override this method to customize the notification message. + Sending a mail template for example. + + :param partner: res.partner record Concerned partner + :param accepted_lines: sale.order.line recordset Accepted lines + :param rejected_lines: sale.order.line recordset Rejected lines + """ + message = "" + if accepted_lines: + message += _("Your following requests have been accepted:\n") + for line in accepted_lines: + message += f"{line.product_id.name} - {line.product_uom_qty}\n" + + if rejected_lines: + message += _("Your following requests have been rejected:\n") + for line in rejected_lines: + message += f"{line.product_id.name} - {line.product_uom_qty}" + if line.request_rejection_reason: + message += f": {line.request_rejection_reason}" + message += "\n" + + partner.message_post( + body=message, + subject=_("Request feedback"), + subtype_id=self.env.ref("mail.mt_comment").id, + ) + def action_request_cart(self): for record in self: if record.typology == "request": diff --git a/shopinvader_unit_management/models/res_partner.py b/shopinvader_unit_management/models/res_partner.py index be1714bb02..4fd403ec89 100644 --- a/shopinvader_unit_management/models/res_partner.py +++ b/shopinvader_unit_management/models/res_partner.py @@ -85,5 +85,5 @@ def _delete_shopinvader_unit_member(self, member_id): self._ensure_same_unit(member) if member.unit_profile not in ["collaborator", "manager"]: raise AccessError(_("Cannot perform this action on this member")) - member.active = False + member.sudo().active = False return member