Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3028 Widoki

Scenario.
Sales Team, Purchase Team, Manufacturing Team. (imagine each is a user)

i want, receipts to validated (allowed to validated) by only purchase guy, ideally rest should be able to view, but shouldn't be able to validate.
similarly
delivery orders (transfers) allowed to be validated by sales team.
internal transfers (should be allowed to validated by manufacturing team/user.


any ideas / psudo steps will help, thanks, haseeb.

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Haseeb,

You can validate the button_validate method and check for user groups and raise a warning if the user not belongs to that group. For example for the purchase transfer Try this: 

def button_validate(self):
if self.picking_type_id.code == 'incoming':
if not self.env.user.has_group('purchase.group_purchase_user'):
raise ValidationError(_('You are not allowed to validate this picking/transfer'))

res = super(StockPicking, self).button_validate()
return res

For other transfer like sales and internal transfer use respective picking type code and user groups for checking the conditions and raise warning

Hope this will help you

Thank you

Awatar
Odrzuć
Autor

Hi Mehjabin.
1- thanks for guidance, really means a lot.
2- while trying doing that. below is my sample code from (models.py) and module is loaded but function is not getting called. unable to see any log msg in terminal. few more suggestions will help me go through.(thanks in advance)

from odoo import models, fields, api, loglevels

class rhein_validator(models.Model):
_name = 'rhein_validator.rhein_validator'
_description = 'rhein_validator.rhein_validator'
_inherit = 'stock.picking'

@api.multi
def button_validate(self):
loglevels.LOG_WARNING("=======MY METHOD RUNNING AS WELL========")
if self.picking_type_id.code == 'incoming':
if not self.env.user.has_group('purchase.group_purchase_user'):
raise ValidationError(_('You are not authorized to validate this picking'))
res = super(rhein_validator, self).button_validate()
return res

Hi,
In your class definition try as this by removing _name :
class rhein_validator(models.Model):
_inherit = 'stock.picking'
// Add function here

Autor

final code, that worked, hopefully it might help someone in same trouble. cheers.
==============================

# -*- coding: utf-8 -*-

# from xml.dom import ValidationErr
from odoo import models, fields, api
from odoo import _
from odoo.exceptions import ValidationError

class rhein_validator(models.Model):
_inherit = 'stock.picking'
def button_validate(self):
# logging.WARNING('THIS IS A WARNING MESSAGE'
print ("THIS IS A TEST MSG")
if self.picking_type_id.code == 'incoming':
if not self.env.user.has_group('purchase.group_purchase_user'):
raise ValidationError(_('You are not authorized to validate this picking'))
res = super(rhein_validator, self).button_validate()
return res

Najlepsza odpowiedź

You can override button_validate method of stock picking where you can check if user belongs to any of the above group and operation type. Based on that, you can raise warning or can call super method.

Thanks & Regards,



CandidRoot Solutions Pvt. Ltd.

Mobile: (+91) 8849036209
Email: info@candidroot.com
Skype: live:candidroot
Web: https://www.candidroot.com
Address: 1229-1230, Iconic Shyamal, Near Shyamal Cross Road, Ahmedabad, Gujarat 380015
    

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lis 20
2335
4
sie 18
15893
2
maj 24
1830
1
lis 22
2647
1
wrz 22
2037