Browse Source

Jul 31 [FIX] : Bug Fixed 'readonly_unit_price_cybrosys'

pull/268/head
AjmalCybro 2 years ago
parent
commit
17385c0c3f
  1. 2
      readonly_unit_price_cybrosys/doc/RELEASE_NOTES.md
  2. 1
      readonly_unit_price_cybrosys/models/__init__.py
  3. 20
      readonly_unit_price_cybrosys/models/account_move.py
  4. 17
      readonly_unit_price_cybrosys/models/res_users.py
  5. 20
      readonly_unit_price_cybrosys/models/sale_order.py

2
readonly_unit_price_cybrosys/doc/RELEASE_NOTES.md

@ -1,6 +1,6 @@
## Module <readonly_unit_price_cybrosys> ## Module <readonly_unit_price_cybrosys>
#### 6.1.2023 #### 31.07.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
Initial Commit for Price Unit Readonly for Sale and Invoice. Initial Commit for Price Unit Readonly for Sale and Invoice.

1
readonly_unit_price_cybrosys/models/__init__.py

@ -19,7 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from . import res_users from . import res_users
from . import sale_order from . import sale_order
from . import account_move from . import account_move

20
readonly_unit_price_cybrosys/models/account_move.py

@ -20,22 +20,22 @@
# #
############################################################################# #############################################################################
from odoo import api, fields, models, _ from odoo import fields, models
class AccountMoveLine(models.Model): class AccountMoveLine(models.Model):
_inherit = 'account.move.line' _inherit = 'account.move.line'
price_unit_boolean = fields.Boolean(default=False, price_unit_boolean = fields.Boolean(
compute='_compute_price_unit_boolean') string="price unit boolean",
help="This field used to readonly for price unite",
default=lambda self: self.env.user.readonly_unit_price_invoicing,
compute='_compute_price_unit_boolean')
def _compute_price_unit_boolean(self): def _compute_price_unit_boolean(self):
""" Compute function for price_unit_boolean. """ Compute function for price_unit_boolean.
This function will check the boolean field of the currently logged user is true or false. This function will check the boolean field of the currently
And it will pass the value to price_unit_boolean.""" logged user is true or false.
And it will pass the value to price_unit_boolean."""
for rec in self: for rec in self:
u_id = self.env['res.users'].search([('id', '=', self._uid)]) rec.price_unit_boolean = self.env.user.readonly_unit_price_invoicing
if u_id.readonly_unit_price_invoicing == False:
rec.price_unit_boolean = False
else:
rec.price_unit_boolean = True

17
readonly_unit_price_cybrosys/models/res_users.py

@ -20,23 +20,22 @@
# #
############################################################################# #############################################################################
from odoo import api, fields, models, _ from odoo import fields, models, _
class ResUsers(models.Model): class ResUsers(models.Model):
_inherit = 'res.users' _inherit = 'res.users'
readonly_unit_price_sales = fields.Boolean('Readonly Unit Price for Sales', readonly_unit_price_sales = fields.Boolean(
help='If enabled, the Unit Price in the Sale Order Line will be readonly for this user.') string='Readonly Unit Price for Sales',
help="This field used to enable readonly or not for sales ")
readonly_unit_price_invoicing = fields.Boolean( readonly_unit_price_invoicing = fields.Boolean(
'Readonly Unit Price for Invoice', 'Readonly Unit Price for Invoice',
help='If enabled, the Unit Price in the Invoice Lines will be readonly for this user.') help='If enabled, the Unit Price in the Invoice Lines will be readonly '
'for this user.')
is_admin_boolean = fields.Boolean(compute='_compute_is_admin_boolean') is_admin_boolean = fields.Boolean(compute='_compute_is_admin_boolean')
def _compute_is_admin_boolean(self): def _compute_is_admin_boolean(self):
""" checks if the currently logged user is admin or not""" """ checks if the currently logged user is admin or not"""
u_id = self.search([('id','=',self._uid)]) for rec in self:
if u_id._is_admin() == True: rec.is_admin_boolean = rec.env.user._is_admin()
self.is_admin_boolean = True
else:
self.is_admin_boolean = False

20
readonly_unit_price_cybrosys/models/sale_order.py

@ -20,22 +20,22 @@
# #
############################################################################# #############################################################################
from odoo import api, fields, models, _ from odoo import fields, models, _
class SaleOrderLine(models.Model): class SaleOrderLine(models.Model):
_inherit = 'sale.order.line' _inherit = 'sale.order.line'
price_unit_boolean = fields.Boolean(default=False, price_unit_boolean = fields.Boolean(
compute='_compute_price_unit_boolean') string='Price unite boolean',
help="This field check whether readonly for user on not ",
default=lambda self: self.env.user.readonly_unit_price_sales,
compute='_compute_price_unit_boolean')
def _compute_price_unit_boolean(self): def _compute_price_unit_boolean(self):
""" Compute function for price_unit_boolean. """ Compute function for price_unit_boolean.
This function will check the boolean field of the currently logged user is true or false. This function will check the boolean field of the currently
And it will pass the value to price_unit_boolean.""" logged user is true or false.
And it will pass the value to price_unit_boolean."""
for rec in self: for rec in self:
u_id = self.env['res.users'].search([('id', '=', self._uid)]) rec.price_unit_boolean = self.env.user.readonly_unit_price_sales
if u_id.readonly_unit_price_sales == False:
rec.price_unit_boolean = False
else:
rec.price_unit_boolean = True

Loading…
Cancel
Save