Skip to content

Commit

Permalink
migrate the below module.
Browse files Browse the repository at this point in the history
    -->  plm_cutted_parts
    -->  plm_pack_and_go
Issue Fix :
    --> plm(constraint)
    --> plm_web_revision(Revision BoM issue)
  • Loading branch information
jayraj-omnia committed Nov 19, 2024
1 parent 313dbb1 commit df3d35b
Show file tree
Hide file tree
Showing 27 changed files with 1,395 additions and 733 deletions.
12 changes: 6 additions & 6 deletions plm/models/plm_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class RevisionBaseMixin(models.AbstractModel):
engineering_sub_revision_letter = fields.Char("Sub revision path")
engineering_revision_count = fields.Integer(compute='_engineering_revision_count')

# _sql_constraints = [
# ('engineering_uniq',
# "unique (engineering_code, engineering_revision) WHERE (engineering_code is not null)",
# _('Part Number has to be unique!'))
# ]
_sql_constraints = [
('engineering_uniq',
"unique (engineering_code, engineering_revision) WHERE (engineering_code is not null)",
_('Part Number has to be unique!'))
]

def init(self):
"""Ensure there is at most one active variant for each combination.
Expand Down Expand Up @@ -475,4 +475,4 @@ def get_possible_status(self):
ir_model_fields_selection.value))
return out



5 changes: 4 additions & 1 deletion plm_cutted_parts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OmniaSolutions, Open Source Management Solution
# OmniaSolutions, Open Source Management Solution
# Copyright (C) 2010-2011 OmniaSolutions (<http://www.omniasolutions.eu>). All Rights Reserved
# $Id$
#
Expand All @@ -20,4 +21,6 @@
##############################################################################
from . import models
from . import report
from . import wizard

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
16 changes: 7 additions & 9 deletions plm_cutted_parts/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OmniaSolutions, Open Source Management Solution
Expand All @@ -17,27 +18,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#######################True#######################################################
##############################################################################
{
"name": "PLM Cutted Parts",
"version": "18.0.0.1",
"version": "18.0.1.0.0",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
"sequence": 15,
"summary": "Manage bom explosion for cutted parts",
"images": [],
"license": "AGPL-3",
"depends": ["mrp",
"plm"],
"depends": ["mrp", "plm"],
"data": [
"security/base_plm_security.xml",
"report/mrp_bom.xml",
"wizard/plm_temporary.xml",
"views/product.xml",
"views/mrp_bom_lines.xml",
"report/mrp_bom.xml",
"security/base_plm_security.xml",
],
"demo": [],
"test": [],
"installable": True,
"application": False,
"auto_install": False,
Expand Down
4 changes: 2 additions & 2 deletions plm_cutted_parts/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OmniaSolutions, Open Source Management Solution
# OmniaSolutions, Open Source Management Solution
# Copyright (C) 2010-2011 OmniaSolutions (<http://www.omniasolutions.eu>). All Rights Reserved
# $Id$
#
Expand All @@ -21,4 +22,3 @@
from . import product_product
from . import product_template
from . import mrp_bom_line
from . import plm_temporary
67 changes: 34 additions & 33 deletions plm_cutted_parts/models/mrp_bom_line.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OmniaSolutions, Your own solutions
Expand All @@ -23,46 +24,42 @@
@author: mboscolo
"""

from odoo import models
from odoo import fields
from odoo import api
from odoo import _
from odoo import _, api, fields, models


class MrpBomLineTemplateCuttedParts(models.Model):
_inherit = 'mrp.bom.line'
x_length = fields.Float(compute='compute_x_length',
string=_("X Length"),
default=0.0)
y_length = fields.Float(compute='compute_y_length',
string=_("Y Length"),
default=0.0)
client_x_length = fields.Float('X Cutted Qty', default=0)
client_y_length = fields.Float('Y Cutted Qty', default=0)
cutted_qty = fields.Float('Cutted Qty', default=0)
_inherit = "mrp.bom.line"

x_length = fields.Float(
compute="compute_x_length", string=_("X Length"), default=0.0
)
y_length = fields.Float(
compute="compute_y_length", string=_("Y Length"), default=0.0
)
client_x_length = fields.Float("X Cutted Qty", default=0)
client_y_length = fields.Float("Y Cutted Qty", default=0)
cutted_qty = fields.Float("Cutted Qty", default=0)

def compute_x_length(self):
for bom_line_id in self:
if bom_line_id.cutted_type == 'server':
if bom_line_id.cutted_type == "server":
product = bom_line_id.bom_id.product_id
if not product:
product = bom_line_id.bom_id.product_tmpl_id.product_variant_id
bom_line_id.x_length = self.computeXLenghtByProduct(product)
elif bom_line_id.cutted_type == 'client':
elif bom_line_id.cutted_type == "client":
bom_line_id.x_length = bom_line_id.client_x_length
else:
bom_line_id.x_length = 0

def compute_y_length(self):
for bom_line_id in self:
if bom_line_id.cutted_type == 'server':
if bom_line_id.cutted_type == "server":
product = bom_line_id.bom_id.product_id
if not product:
product = bom_line_id.bom_id.product_tmpl_id.product_variant_id
bom_line_id.y_length = self.computeYLenghtByProduct(product)
elif bom_line_id.cutted_type == 'client':
elif bom_line_id.cutted_type == "client":
bom_line_id.y_length = bom_line_id.client_y_length
else:
bom_line_id.y_length = 0
Expand All @@ -71,21 +68,25 @@ def compute_y_length(self):
def computeYLenghtByProduct(self, product_id):
wastage_percent_y = product_id.wastage_percent_y or 1
material_added_y = product_id.material_added_y
new_qty = (product_id.row_material_y_length * wastage_percent_y) + material_added_y
new_qty = (
product_id.row_material_y_length * wastage_percent_y
) + material_added_y
return new_qty

def computeXLenghtByProduct(self, product_id):
material_percentage = product_id.wastage_percent or 1
material_added = product_id.material_added
new_qty = (product_id.row_material_x_length * material_percentage) + material_added
return new_qty

new_qty = (
product_id.row_material_x_length * material_percentage
) + material_added
return new_qty

def write(self, vals):
res = super(MrpBomLineTemplateCuttedParts, self).write(vals)
if not self.env.context.get('skip_cutted_recompute'):
if not self.env.context.get("skip_cutted_recompute"):
self.recomputeCuttedQty()
return res

@api.model_create_multi
def create(self, vals):
res = super(MrpBomLineTemplateCuttedParts, self).create(vals)
Expand All @@ -94,13 +95,15 @@ def create(self, vals):

def recomputeCuttedQty(self):
ctx = self.env.context.copy()
ctx['skip_cutted_recompute'] = True
ctx["skip_cutted_recompute"] = True
for bom_line_id in self:
bom_line_id.with_context(ctx).product_qty = bom_line_id.computeCuttedTotalQty()
bom_line_id.with_context(
ctx
).product_qty = bom_line_id.computeCuttedTotalQty()

def computeCuttedTotalQty(self):
for bom_line_id in self:
if bom_line_id.cutted_type in ('server', 'client'):
if bom_line_id.cutted_type in ("server", "client"):
if bom_line_id.x_length or bom_line_id.y_length:
x_length = bom_line_id.x_length or 1
y_length = bom_line_id.y_length or 1
Expand All @@ -115,5 +118,3 @@ def computeTotalQty(self, xLenght, yLenght, cutted_qty):
cutted_qty = cutted_qty or 1
ret = ret * cutted_qty
return ret or 1


Loading

0 comments on commit df3d35b

Please sign in to comment.