Skip to content

Commit

Permalink
FIRST COMMIT FOR v17
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 3, 2023
1 parent b282904 commit 0270cf7
Show file tree
Hide file tree
Showing 73 changed files with 632 additions and 509 deletions.
4 changes: 2 additions & 2 deletions activity_validation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
"name": "Activity Validation",
"version": "17.0.1",
"version": "17.0.0.1",
"author": "OmniaSolutions",
"website": "https://github.com/OmniaGit/odooplm",
"category": "Custom",
Expand All @@ -45,7 +45,7 @@
"qweb": ["static/src/xml/*.xml"],
'assets': {
'web.assets_backend': [
"activity_validation/static/src/js/systray_activity_menu.js",
#"activity_validation/static/src/js/systray_activity_menu.js",
]
},
"installable": True,
Expand Down
2 changes: 1 addition & 1 deletion plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "Product Lifecycle Management",
"version": "17.0.1",
"version": "17.0.0.1",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
2 changes: 1 addition & 1 deletion plm/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def koo_fields_view_get(self, view_id=None, view_type='form', toolbar=False, sub
def sanitize(dict_from):
return json.loads(json.dumps(dict_from, default=json_serial).replace("null", "false"))
f = super(Base, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
for key in ['field_parent', 'name', 'type', 'view_id', 'base_model', 'fields', 'toolbar']:
for key in ['name', 'type', 'view_id', 'base_model', 'fields', 'toolbar']:
if key in f:
f[key] = sanitize(f.get(key))
return f
Expand Down
55 changes: 0 additions & 55 deletions plm/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2293,61 +2293,6 @@ def getCheckedOutAttrs(self, vals):
break
outDict[file_path] = outLocalDict
return outDict

@api.model
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
# add res_field=False in domain if not present; the arg[0] trick below
# works for domain items and '&'/'|'/'!' operators too
if not any(arg[0] in ('id', 'res_field') for arg in args):
args.insert(0, ('res_field', '=', False))

ids = super(models.Model, self)._search(args, offset=offset, limit=limit, order=order,
count=False, access_rights_uid=access_rights_uid)

if self.env.user and (self.env.user._is_admin() or self.env.user._is_superuser()):
# rules do not apply for the superuser
return len(ids) if count else ids

if not ids:
return 0 if count else []

# Work with a set, as list.remove() is prohibitive for large lists of documents
# (takes 20+ seconds on a db with 100k docs during search_count()!)
orig_ids = ids
ids = set(ids)

# For attachments, the permissions of the document they are attached to
# apply, so we must remove attachments for which the user cannot access
# the linked document.
# Use pure SQL rather than read() as it is about 50% faster for large dbs (100k+ docs),
# and the permissions are checked in super() and below anyway.
model_attachments = defaultdict(lambda: defaultdict(set)) # {res_model: {res_id: set(ids)}}
self._cr.execute("""SELECT id, res_model, res_id, public FROM ir_attachment WHERE id IN %s""", [tuple(ids)])
for row in self._cr.dictfetchall():
if not row['res_model'] or row['public']:
continue
# model_attachments = {res_model: {res_id: set(ids)}}
model_attachments[row['res_model']][row['res_id']].add(row['id'])

# To avoid multiple queries for each attachment found, checks are
# performed in batch as much as possible.
for res_model, targets in model_attachments.items():
if res_model not in self.env:
continue
if not self.env[res_model].check_access_rights('read', False):
# remove all corresponding attachment ids
ids.difference_update(itertools.chain(*targets.values()))
continue
# filter ids according to what access rules permit
target_ids = list(targets)
allowed = self.env[res_model].with_context(active_test=False).search([('id', 'in', target_ids)])
for res_id in set(target_ids).difference(allowed.ids):
ids.difference_update(targets[res_id])

# sort result according to the original sort ordering
result = [id for id in orig_ids if id in ids]
return len(result) if count else list(result)


def open_related_document_revisions(self):
ir_attachment_ids = self.search([('engineering_code', '=', self.engineering_code)])
Expand Down
5 changes: 3 additions & 2 deletions plm/models/ir_ui_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class IrUiView(models.Model):
_inherit = 'ir.ui.view'

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
@api.returns('self')
def search(self, args, offset=0, limit=None, order=None):
if self.env.context.get('odooPLM'):
self = self.sudo()
return super(IrUiView, self).search(args, offset, limit, order, count)
return super(IrUiView, self).search(args, offset, limit, order)
3 changes: 3 additions & 0 deletions plm/models/plm_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ def get_all_revision(self):
def write(self, vals):
if 'engineering_code' in vals and vals['engineering_code'] not in [False, '-','']:
vals['engineering_code_editable']=False
else:
if self.engineering_code and self.engineering_code_editable==True:
vals['engineering_code_editable']=False
return super(RevisionBaseMixin, self).write(vals)

def create(self, vals):
Expand Down
17 changes: 12 additions & 5 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from odoo.exceptions import AccessError
from odoo.exceptions import UserError
import odoo.tools as tools
from odoo.osv import expression

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1790,11 +1791,17 @@ def name_get(self):
return result

@api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
if not args:
args = []
product_ids = list(self._search([('engineering_code', operator, name)] + args, limit=limit, access_rights_uid=name_get_uid))
product_ids += list(super(ProductProduct, self)._name_search(name, args, operator, limit, name_get_uid))
def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):
if not domain:
domain=[('engineering_code', 'ilike', name)]
else:
domain = expression.OR([domain,
[('engineering_code', 'ilike', name)]])
product_ids = list(super(ProductProduct, self)._name_search(name,
domain,
operator,
limit,
order=None))
return list(set(product_ids))

@api.model
Expand Down
5 changes: 3 additions & 2 deletions plm/models/res_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class ResGroups(models.Model):
_inherit = 'res.groups'

@api.model
def search(self, args, offset=0, limit=None, order=None, count=False):
@api.returns('self')
def search(self, args, offset=0, limit=None, order=None):
if self.env.context.get('odooPLM'):
available_types = [
self.env.ref('plm.group_plm_view_user').id,
Expand All @@ -56,6 +57,6 @@ def search(self, args, offset=0, limit=None, order=None, count=False):
if additional_obj:
available_types.append(additional_obj.id)
args = AND([args, [('id', 'in', available_types)]])
return super(ResGroups, self).search(args, offset, limit, order, count)
return super(ResGroups, self).search(args, offset, limit, order)

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
3 changes: 2 additions & 1 deletion plm/tests/test_plm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#

#
@tagged('-standard', 'odoo_plm','post_install', '-at_install')
@tagged('-standard', 'odoo_plm')
class PlmDateBom(TransactionCase, PlmEntityCreator):

def test_1_some_wk(cls):
Expand Down Expand Up @@ -145,6 +145,7 @@ def test_1_some_wk(cls):

def test_2_attachment_wk(self):
attachment = self.create_document('document_wk_test')
attachment.is_plm=True
#
assert attachment.engineering_revision==0
assert attachment.ischecked_in()==True
Expand Down
Loading

0 comments on commit 0270cf7

Please sign in to comment.