From b11004ad35c799bcd5ee17fb0fb4191d2a373e15 Mon Sep 17 00:00:00 2001 From: eslam Date: Sun, 28 Jul 2024 07:58:06 +0300 Subject: [PATCH] Revert "Purchase req chgs" --- .../models/purchase_request.py | 50 +------------------ .../data/purchase_request_seq.xml | 5 -- 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/odex25_purchase/purchase_custom_stock/models/purchase_request.py b/odex25_purchase/purchase_custom_stock/models/purchase_request.py index 399358abc..6c04b493b 100644 --- a/odex25_purchase/purchase_custom_stock/models/purchase_request.py +++ b/odex25_purchase/purchase_custom_stock/models/purchase_request.py @@ -44,7 +44,7 @@ class PurchaseRequest(models.Model): raise ValidationError(_("Please Select department for employee")) direct_manager = self.sudo().department_id.manager_id if direct_manager and direct_manager.user_id and self.env.user.id != direct_manager.user_id.id: - raise ValidationError(_("only %s Direct Manager can approve the order"%self.sudo().employee_id.name)) + raise ValidationError(_("You should be The Direct Manager")) if any(self.line_ids.filtered(lambda line: line.product_id.type == "product")): self.write({'state': 'warehouse'}) else: @@ -54,7 +54,6 @@ class PurchaseRequest(models.Model): - def create_requisition(self): """inherit for take in considiration available qty """ self.is_requisition = True @@ -212,53 +211,6 @@ class PurchaseRequest(models.Model): [('product_id', '=', line.product_id.id), ('location_id', '=', rec.location_id.id)], limit=1).available_quantity line.qty_purchased=line.qty-line.available_qty - def write(self,vals): - - """Ovveride Send Notification On state""" - res=super(PurchaseRequest,self).write(vals) - if 'state' in vals : - if vals['state'] =='direct_manager': - direct_manager = self.sudo().department_id.manager_id - if direct_manager and direct_manager.user_id: - self.message_post(body='Dear %s your approval is required on %s ' % (direct_manager.name, self.name), - message_type='notification', - author_id=self.env.user.partner_id.id, sticky=True, - subtype_id=self.env.ref("mail.mt_comment").id, - partner_ids=[direct_manager.user_id.partner_id.id]) - elif vals['state'] == 'warehouse': - stock_group = self.env.ref('stock.group_stock_user') - stock_users = self.env['res.users'].search([('groups_id', '=', stock_group.id)]) - for user in stock_users: - stock_employee=self.env['hr.employee'].search([('user_id','=',user.id)],limit=1) - if stock_employee and user.partner_id.id: - self.message_post(body='Dear %s your approval is required on %s ' % (stock_employee.name, self.name), - message_type='notification', - author_id=self.env.user.partner_id.id, sticky=True, - subtype_id=self.env.ref("mail.mt_comment").id, - partner_ids=[user.partner_id.id]) - elif vals['state'] == 'waiting': - purchase_group = self.env.ref('purchase.group_purchase_user') - purchase_users = self.env['res.users'].search([('groups_id', '=', purchase_group.id)]) - for user in purchase_users: - purchase_employee = self.env['hr.employee'].search([('user_id', '=', user.id)], limit=1) - if purchase_employee and user.partner_id.id: - self.message_post(body='Dear %s your approval is required on %s ' % (purchase_employee.name, self.name), - message_type='notification', - author_id=self.env.user.partner_id.id, sticky=True, - subtype_id=self.env.ref("mail.mt_comment").id, - partner_ids=[user.partner_id.id]) - elif vals['state'] == 'employee': - print("employee") - if self.sudo().employee_id and self.sudo().employee_id.user_id: - self.message_post( - body='Dear %s please confirm your Delivery on %s ' % (self.sudo().employee_id.name, self.name), - message_type='notification', - author_id=self.env.user.partner_id.id, sticky=True, - subtype_id=self.env.ref("mail.mt_comment").id, - partner_ids=[self.sudo().employee_id.user_id.partner_id.id]) - return res - - diff --git a/odex25_purchase/purchase_requisition_custom/data/purchase_request_seq.xml b/odex25_purchase/purchase_requisition_custom/data/purchase_request_seq.xml index 5a5f6122e..f348357f6 100644 --- a/odex25_purchase/purchase_requisition_custom/data/purchase_request_seq.xml +++ b/odex25_purchase/purchase_requisition_custom/data/purchase_request_seq.xml @@ -9,10 +9,5 @@ 1 1 - - - - -