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>
#### 6.1.2023
#### 31.07.2023
#### Version 16.0.1.0.0
#### ADD
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/>.
#
#############################################################################
from . import res_users
from . import sale_order
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):
_inherit = 'account.move.line'
price_unit_boolean = fields.Boolean(default=False,
compute='_compute_price_unit_boolean')
price_unit_boolean = fields.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):
""" Compute function for price_unit_boolean.
This function will check the boolean field of the currently logged user is true or false.
And it will pass the value to price_unit_boolean."""
This function will check the boolean field of the currently
logged user is true or false.
And it will pass the value to price_unit_boolean."""
for rec in self:
u_id = self.env['res.users'].search([('id', '=', self._uid)])
if u_id.readonly_unit_price_invoicing == False:
rec.price_unit_boolean = False
else:
rec.price_unit_boolean = True
rec.price_unit_boolean = self.env.user.readonly_unit_price_invoicing

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):
_inherit = 'res.users'
readonly_unit_price_sales = fields.Boolean('Readonly Unit Price for Sales',
help='If enabled, the Unit Price in the Sale Order Line will be readonly for this user.')
readonly_unit_price_sales = fields.Boolean(
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 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')
def _compute_is_admin_boolean(self):
""" checks if the currently logged user is admin or not"""
u_id = self.search([('id','=',self._uid)])
if u_id._is_admin() == True:
self.is_admin_boolean = True
else:
self.is_admin_boolean = False
for rec in self:
rec.is_admin_boolean = rec.env.user._is_admin()

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):
_inherit = 'sale.order.line'
price_unit_boolean = fields.Boolean(default=False,
compute='_compute_price_unit_boolean')
price_unit_boolean = fields.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):
""" Compute function for price_unit_boolean.
This function will check the boolean field of the currently logged user is true or false.
And it will pass the value to price_unit_boolean."""
This function will check the boolean field of the currently
logged user is true or false.
And it will pass the value to price_unit_boolean."""
for rec in self:
u_id = self.env['res.users'].search([('id', '=', self._uid)])
if u_id.readonly_unit_price_sales == False:
rec.price_unit_boolean = False
else:
rec.price_unit_boolean = True
rec.price_unit_boolean = self.env.user.readonly_unit_price_sales

Loading…
Cancel
Save