Skip to content

Commit

Permalink
Merge branch '14.0' of https://github.com/OmniaGit/odooplm.git into 14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 7, 2024
2 parents a9e4a5c + f817d23 commit 6354e5c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
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": "14.0.4",
"version": "14.0.7",
"author": "OmniaSolutions",
"website": "https://github.com/OmniaGit/odooplm",
"category": "Manufacturing/Product Lifecycle Management",
Expand Down
24 changes: 14 additions & 10 deletions plm/models/mrp_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _explode_bom(self, bids, check=True, last_rev=False):
output.append([prod_id, inner_ids])
return output


def get_last_comp_id(self, comp_id):
prod_prod_obj = self.env['product.product']
comp_brws = prod_prod_obj.browse(comp_id)
Expand Down Expand Up @@ -367,7 +367,7 @@ def GetWhereUsedSum(self, res_ids):
prt_datas = self._get_pack_datas(rel_datas)
return rel_datas, prt_datas, self._get_pack_rel_datas(rel_datas, prt_datas)


def get_exploded_bom(self, level=0, curr_level=0):
"""
Return a list of all children in a Bom ( level = 0 one level only, level = 1 all levels)
Expand Down Expand Up @@ -601,7 +601,7 @@ def rebase_bom_weight(self):
def read(self, fields=[], load='_classic_read'):
fields = self.plm_sanitize(fields)
return super(MrpBomExtension, self).read(fields=fields, load=load)

def write(self, vals, check=True):
vals = self.plm_sanitize(vals)
ret = super(MrpBomExtension, self).write(vals)
Expand All @@ -616,27 +616,31 @@ def create(self, vals):
ret.rebase_bom_weight()
return ret


def copy(self, default={}):
"""
Return new object copied (removing source_id)
"""
new_bom_brws = super(MrpBomExtension, self).copy(default)
if new_bom_brws:
for bom_line in new_bom_brws.bom_line_ids:
if not bom_line.product_id.product_tmpl_id.engineering_code:
bom_line.sudo().write({'state': 'draft',
'source_id': False,})
continue
late_rev_id_c = self.env['product.product'].GetLatestIds([
(bom_line.product_id.product_tmpl_id.engineering_code,
False,
False)
]) # Get Latest revision of each Part
bom_line.sudo().write({'state': 'draft'})
write_vals = {
'state': 'draft',
'source_id': False,
'name': bom_line.product_id.product_tmpl_id.name,
}
if late_rev_id_c:
write_vals['product_id'] = late_rev_id_c[0]
bom_line.write(write_vals)
bom_line.sudo().write(write_vals)
new_bom_brws.sudo().with_context({'check': False}).write({
'source_id': False,
'name': new_bom_brws.product_tmpl_id.name
Expand Down Expand Up @@ -698,7 +702,7 @@ def recursion(bom_brws_list):
'context': {"group_by": ['bom_id']},
}


def open_related_bom_revisions(self):
bom_ids = self.search([('product_tmpl_id', 'in', self.product_tmpl_id.getAllVersionTemplate().ids)])
return {'name': _('B.O.M.S'),
Expand Down Expand Up @@ -749,7 +753,7 @@ def saveRelationNew(self,
product_tmpl_id = parent_product_product_id.product_tmpl_id.id
ir_attachment_relation.removeChildRelation(parent_ir_attachment_id) # perform default unlink to HiTree, need to perform RfTree also
ir_attachment_relation.removeChildRelation(parent_ir_attachment_id, linkType='RfTree')

mrp_bom_found_id = self.saveRelationNewGetBom(product_tmpl_id, bomType, parent_product_product_id)
if mrp_bom_found_id:
mrp_bom_found_id.delete_child_row(parent_ir_attachment_id)
Expand Down Expand Up @@ -804,11 +808,11 @@ def plm_sanitize(self, vals):
@api.model
def _bom_find_domain(self, product_tmpl=None, product=None, picking_type=None, company_id=False, bom_type=False):
domain = super(MrpBomExtension, self)._bom_find_domain(product_tmpl=product_tmpl,
product=product,
product=product,
picking_type=picking_type,
company_id=company_id,
bom_type=bom_type)
if not bom_type:
available_types = ['engineering', 'spare']
domain = AND([domain, [('type', 'not in', available_types)]])
return domain
return domain
30 changes: 12 additions & 18 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,25 +411,25 @@ def open_boms(self):
}

@api.model
def _getChildrenBom(self, component, level=0, currlevel=0, bom_type=False):
def _getChildrenBom(self, product_product_id, level=0, currlevel=0, bom_type=False):
"""
Return a flat list of each child, listed once, in a Bom ( level = 0 one level only, level = 1 all levels)
"""
result = []
bufferdata = []
if level <= currlevel and level > 0:
return bufferdata
for bomid in component.product_tmpl_id.bom_ids:
for mrp_bom_id in product_product_id.product_tmpl_id.bom_ids:
if bom_type:
if bomid.type != bom_type:
if mrp_bom_id.type != bom_type:
continue
for bomline in bomid.bom_line_ids:
children = self._getChildrenBom(component=bomline.product_id,
level=level,
currlevel=currlevel + 1,
bom_type=bom_type)
bufferdata.extend(children)
bufferdata.append(bomline.product_id.id)
for mrp_bom_line_id in mrp_bom_id.bom_line_ids:
children_product_product_id = self._getChildrenBom(product_product_id=mrp_bom_line_id.product_id,
level=level,
currlevel=currlevel + 1,
bom_type=bom_type)
bufferdata.extend(children_product_product_id)
bufferdata.append(mrp_bom_line_id.product_id.id)
result.extend(bufferdata)
return list(set(result))

Expand Down Expand Up @@ -664,18 +664,12 @@ def _checkWorkflow(attachment_ids):
if ir_attachment_id.is3D():
for lay_attachment_id in ir_attachment_id.getRelatedLyTree(ir_attachment_id.id):
if lay_attachment_id not in docIDs:
self._checkWorkflow(attachment.browse(lay_attachment_id),
to_state,
allowed_state
)
_checkWorkflow(attachment.browse(lay_attachment_id))
#
raw_doc_ids = ir_attachment_id.getRelatedRfTree(ir_attachment_id.id,
recursion=True)
#
self._checkWorkflow(attachment.browse(raw_doc_ids),
to_state,
allowed_state
)
_checkWorkflow(attachment.browse(raw_doc_ids))
_checkWorkflow(linkeddocuments)
return list(set(docIDs)), docInError

Expand Down
2 changes: 1 addition & 1 deletion plm/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def clearBrokenComponents():
brokenComp.unlink()

if not default.get('name', False):
default['name'] = '-' # If field is required super of clone will fail returning False, this is the case
#default['name'] = '-' # If field is required super of clone will fail returning False, this is the case
default['engineering_code'] = False
default['engineering_revision'] = 0
clearBrokenComponents()
Expand Down
2 changes: 1 addition & 1 deletion plm_engineering/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
##############################################################################
{
"name": "PLM Engineering",
"version": "14.0.1.0.0",
"version": "14.0.1.0.1",
"author": "OmniaSolutions",
"website": "https://github.com/OmniaGit/odooplm",
"category": "Product Lifecycle Management",
Expand Down
9 changes: 9 additions & 0 deletions plm_engineering/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def get_previous_normal_bom(bomBrws, exclude_bom_id=False):
if new_bom_type not in ['normal', 'phantom']:
raise UserError(_("Could not convert source bom to %r" % new_bom_type))
product_template_id = obj_product_product_brw.product_tmpl_id.id
if bom_type.search_count([('product_tmpl_id', '=', product_template_id),
('type', '=', 'phantom')]):
return []
bom_brws_list = bom_type.search([('product_tmpl_id', '=', product_template_id),
('type', '=', new_bom_type)], order='engineering_revision DESC', limit=1)
if bom_brws_list:
Expand Down Expand Up @@ -239,6 +242,12 @@ def action_create_normalBom(self):
('type', '=', 'normal')])
if obj_boms:
raise UserError(_("Normal BoM for Part '%s' and revision '%s' already exists." % (obj_boms.product_tmpl_id.engineering_code, obj_boms.product_tmpl_id.engineering_revision)))

if obj_brws.env['mrp.bom'].search_count([('product_tmpl_id', '=', id_template),
('type', '=', 'phantom')]):
raise UserError(_("""Normal BoM for Part '%s' and revision '%s' have a kit bom present.\n"""
"""If you whant to create the normal bom please delete the kit bom first !
""" % (product_browse.engineering_code, obj_boms.product_tmpl_id.engineering_revision)))
line_messages_list = product_product_type_object.create_bom_from_ebom(
product_browse, 'normal',
obj_brws.summarize,
Expand Down

0 comments on commit 6354e5c

Please sign in to comment.