Skip to content

Commit

Permalink
Merge branch '18.0' of https://github.com/OmniaGit/odooplm.git into 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 22, 2024
2 parents 2a84ea1 + 07482f5 commit e895ff7
Show file tree
Hide file tree
Showing 50 changed files with 1,045 additions and 920 deletions.
402 changes: 240 additions & 162 deletions plm/models/plm_mixin.py

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ProductProduct(models.Model):
_name='product.product'
_inherit = ['product.product']
_description ="Product Product"

def onchange(self, values, field_names, fields_spec):
values = self.plm_sanitize(values)
if 'product_tmpl_id' in values:
Expand Down Expand Up @@ -152,7 +152,7 @@ def _father_part_compute(self, name='', arg={}):
# Don't overload std_umc1, std_umc2, std_umc3 setting them related to std_description because odoo try to set value
# of related fields and integration users doesn't have write permissions in std_description. The result is that
# integration users can't create products if in changed values there is std_description

show_std_field1 = fields.Boolean(_('Show std field 1'),
compute='_computeStd')
show_std_field2 = fields.Boolean(_('Show std field 2'),
Expand All @@ -163,16 +163,16 @@ def _father_part_compute(self, name='', arg={}):
readonly_std_umc1 = fields.Boolean(_("put readOnly the field standard description 1"))
readonly_std_umc2 = fields.Boolean(_("put readOnly the field standard description 2"))
readonly_std_umc3 = fields.Boolean(_("put readOnly the field standard description 3"))

linkeddocuments = fields.Many2many('ir.attachment',
'plm_component_document_rel',
'component_id',
'document_id',
_('Linked Docs'),
ondelete='cascade')

kit_bom = fields.Boolean(_('KIT Bom Type'))

def _computeStd(self):
for product_product_id in self:
product_product_id.show_std_field1 = False
Expand All @@ -185,7 +185,7 @@ def _computeStd(self):
product_product_id.show_std_field2 = True
if product_product_id.std_description.umc3 or product_product_id.std_description.fmt3:
product_product_id.show_std_field3 = True

@api.onchange("std_description")
def _showStd(self):
for product_product_id in self:
Expand All @@ -206,7 +206,7 @@ def _showStd(self):
product_product_id.show_std_field1 = True
else:
product_product_id.std_value1 = False

if product_product_id.std_umc2:
product_product_id.readonly_std_umc2=True
product_product_id.show_std_field2 = True
Expand Down Expand Up @@ -268,7 +268,7 @@ def getLatestReleasedRevision(self):
if product_id.engineering_state in [RELEASED_STATUS, 'undermodifie']:
return product_id
return self

# Internal methods
def _packfinalvalues(self, fmt, value=False, value2=False, value3=False):
"""
Expand Down Expand Up @@ -395,7 +395,7 @@ def product_template_open(self):
'res_id': product_id,
'views': [(form_id, 'form')],
}

#def open_report_component(self):
# action = self.env.ref('plm.action_report_prod_structure').report_action(self)
# action.update({'close_on_report_download': True})
Expand All @@ -422,7 +422,7 @@ def _getChildrenBom(self,
currlevel=0,
bom_type=False):
"""
Return a flat list of each child, listed once, in a Bom
Return a flat list of each child, listed once, in a Bom
:level = [ 0 one level only, 1 all levels]
:currlevel starting level for the bom
:bom_type type bom calculation
Expand Down Expand Up @@ -452,11 +452,11 @@ def get_flat_children(product_product_id,
return out
#
result = get_flat_children(product_product_id,
level,
currlevel,
level,
currlevel,
bom_type)
return list(set(result))

def getLeafBom(self, bom_type='normal'):
"""
get only the leaf of the bom
Expand All @@ -481,7 +481,7 @@ def _getLeafBom(parent_product_ids, bom_type='normal'):
out.append(product_product_id)
_getLeafBom(self)
return out

def summarize_level(self, recursion=False, flat=False, level=1, summarize=False, parentQty=1, bom_type=False):
out = {}
for product_product_id in self:
Expand Down Expand Up @@ -684,13 +684,13 @@ def action_create_normalBom_WF(self):
self._create_normalBom(prodId, processedIds)
self.message_post(body=_('Created Normal Bom.'))
return False

def _jump_document_wf(self,
documentBrws,
check_state):
"""
this function is here in order to customize the document workflow
:documentBrws <ir_attachment>
:documentBrws <ir_attachment>
:check_in_check bool shuld I move also the document
:return: True will jump the workflow for the current document / False will performe the workflow
"""
Expand Down Expand Up @@ -728,7 +728,7 @@ def checkWorkflow(self,
return list(set(docIDs))

def _action_ondocuments(self,
action_name,
action_name,
include_statuses=[],
check_in_check=True):
"""
Expand Down Expand Up @@ -776,8 +776,8 @@ def moveDocumentWorkflow(self, docIDs, status):
else:
self.customMoveDocumentWorkflow(ir_attachment_ids, status)
return docIDs


def customMoveDocumentWorkflow(self,
ir_attachment_ids,
status):
Expand Down Expand Up @@ -857,7 +857,7 @@ def action_confirm(self):
for product_product_id in self:
product_product_id.commonWFAction(CONFIRMED_STATUS, [START_STATUS], recursive=True)
return True

def action_release(self):
for product_product_id in self:
product_product_id.commonWFAction(RELEASED_STATUS,
Expand Down Expand Up @@ -885,7 +885,7 @@ def action_reactivate(self):
product_product_id.commonWFAction(RELEASED_STATUS,
[OBSOLATED_STATUS])
return True

def commonWFAction(self,
status,
include_statuses=[],
Expand Down Expand Up @@ -1007,7 +1007,7 @@ def create(self, vals):
name = vals_dict.get('name')
if not name and eng_code:
vals_dict['name'] = eng_code

eng_rev = vals_dict.get('engineering_revision', 0)
eng_code = vals_dict.get('engineering_code')
if eng_code:
Expand Down Expand Up @@ -1040,7 +1040,7 @@ def create(self, vals):
raise Exception(msg)
logging.error("(%s). It has tried to create with values : (%s)." % (str(ex), str(vals)))
raise Exception(_(" (%r). It has tried to create with values : (%r).") % (ex, vals))

def write(self, vals):
for product in self:
if 'is_engcode_editable' not in vals and product.engineering_code not in ['-',False]:
Expand All @@ -1059,7 +1059,7 @@ def write(self, vals):
product.with_context(ctx).on_change_tmpsurface()
product.with_context(ctx).on_change_tmptreatment()
for product_id in self:
if product_id._origin.id:
if product_id._origin.id:
product_id.checkFromOdooPlm()
return res

Expand All @@ -1068,7 +1068,7 @@ def read(self, fields=[], load='_classic_read'):
if self.env.context.get('odooPLM'):
if not fields:
fields = list(self._fields.keys())
cleaned_up_fields = []
cleaned_up_fields = []
for field_name, field_attrs in self.fields_get(fields).items():
if field_attrs['type']=='properties':
continue
Expand All @@ -1092,7 +1092,7 @@ def fieldsToKeep(self, to_write=[]):
for vals in self.read(to_write):
return vals
return {}

def readMany2oneFields(self, readVals, fields):
return self._readMany2oneFields(self.env['product.product'], readVals, fields)

Expand Down Expand Up @@ -1124,13 +1124,13 @@ def checkFromOdooPlm(self):
new_revision = self.env.context.get('new_revision', False)
if self.env.context.get('odooPLM', False) and not new_revision:
for product_product_id in self:
if not product_product_id.engineering_code:
if not product_product_id.engineering_code:
raise UserError("Missing engineering code for plm data")
return True

def checkMany2oneClient(self, vals, force_create=False):
return self._checkMany2oneClient(self.env['product.product'], vals, force_create)

@api.model
def _checkMany2oneClient(self, obj, vals, force_create=False):
out = {}
Expand Down Expand Up @@ -1200,11 +1200,11 @@ def translateForClient(self, values=[], forcedLang=''):
readDict = translationBrwsList[0].read(['value'])
values[fieldName] = readDict.get('value', '')
return values

@api.model
def get_all_translation(self, object_id, fields):
return self.product_tmpl_id.get_all_translation(object_id, fields)

def action_rev_docs(self):
"""
This function is called by the button on component view, section LinkedDocuments
Expand Down Expand Up @@ -1819,11 +1819,11 @@ def _name_search(self, name, domain=None, operator='ilike', limit=None, order=No
limit,
order=None))
return list(set(product_ids + engineering_code_products.ids))

@api.model
def getExpodedBom(self, ids):
"""
function used in the client to retrieve the exploded bom
function used in the client to retrieve the exploded bom
"""
mrp_bom = self.env['mrp.bom']
out = []
Expand All @@ -1842,13 +1842,13 @@ def getProductData(product_tmpl_id):
'engineering_revision': product_tmpl_id.engineering_revision,
'name': product_tmpl_id.name,
}
#
#
def getBomLineData(mrpBomLine):
return {
'qty': mrpBomLine.product_qty,
'qty': mrpBomLine.product_qty,
'source_name': mrpBomLine.source_id.name
}
#
#
def getDictData(mrpBomLine):
out = getProductData(mrpBomLine.product_id.product_tmpl_id)
out.update(getBomLineData(mrpBomLine))
Expand All @@ -1865,14 +1865,14 @@ def computeChildLevel(product_tmpl_id):
for mrp_bom_line_id in mrp_bom_id.bom_line_ids:
children.append((getDictData(mrp_bom_line_id),
computeChildLevel(mrp_bom_line_id.product_id.product_tmpl_id)))
return children
#
return children
#
for product_id in self.browse(ids):
product_tmpl_id = product_id.product_tmpl_id
out.append((getProductData(product_tmpl_id), computeChildLevel(product_tmpl_id)))
#
return (header, out)

def get_product_bom_flat_ids(self, bom_type='normal'):
"""
get the product browser flat list
Expand All @@ -1882,12 +1882,12 @@ def get_product_bom_flat_ids(self, bom_type='normal'):
#
def populate(product_id):
if product_id in out:
return
return
out.append(product_id)
for bom_id in product_id.product_tmpl_id.bom_ids.filtered(lambda x:x.type==bom_type):
for line_id in bom_id.bom_line_ids:
populate(line_id.product_id)
#
#
populate(self)
return out

Expand All @@ -1913,8 +1913,8 @@ def fillUpSrvPath(p_p_id):
for product_id in brw_product_product_id.get_product_bom_flat_ids():
fillUpSrvPath(product_id)
return list(set(out_src))


class PlmTemporayMessage(models.TransientModel):
_name = "plm.temporary.message"
_description = "Temporary Class"
Expand Down
Loading

0 comments on commit e895ff7

Please sign in to comment.