Skip to content

Commit

Permalink
IMP: plm
Browse files Browse the repository at this point in the history
make default valoe to engineering_revison for fixing problem on client
side that the value is False by default and we wold like to have 0 for a
brend new part

IMP: pdf workorder
  • Loading branch information
mboscolo committed Jan 16, 2025
1 parent eb73131 commit 6e639f2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
##############################################################################
{
"name": "Product Lifecycle Management",
"version": "18.0.1.0.0",
"version": "18.0.2.0.0",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
8 changes: 2 additions & 6 deletions plm/models/plm_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
UPPERCASE_LETTERS = [
chr(i) for i in range(ord('A'), ord('Z') + 1)
]


#
def convert_to_letter(l, n):
n_o_w = len(l)
Expand All @@ -71,17 +69,15 @@ def convert_to_letter(l, n):
else:
out = l[n]
return out


#
#
class RevisionBaseMixin(models.AbstractModel):
_name = 'revision.plm.mixin'
_inherit = ['mail.thread', 'mail.activity.mixin']
_description = 'Revision Mixin'

engineering_code = fields.Char(string="Engineering Code")
engineering_revision = fields.Integer(string="Engineering Revision index")
engineering_revision = fields.Integer(string="Engineering Revision index",
default=0)
engineering_revision_letter = fields.Char(
string="Engineering Revision letter",
default="A"
Expand Down
5 changes: 5 additions & 0 deletions plm_pdf_workorder/models/mrp_routing_workcenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class MrpRoutingWorkcenter(models.Model):
use_plm_pdf = fields.Boolean(_("Use PLM PDF"))
plm_pdf = fields.Binary(_("Plm PDF"), compute="_compute_plm_pdf_data")

def refresh_plm_instruction_pdf(self):
self.ensure_one()
for workorder_id in self.workorder_ids.filtered(lambda x: x.use_plm_pdf):
workorder_id.refresh_plm_instruction_pdf()

def _compute_plm_pdf_data(self):
workorder_id = self.env["mrp.workorder"].search([
("operation_id", "in", self.ids)
Expand Down
14 changes: 10 additions & 4 deletions plm_pdf_workorder/models/mrp_workorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ def action_switch_pdf(self):
def create(self, vals):
ret = super(MrpWorkorder, self).create(vals)
for r in ret:
if r.operation_id.use_plm_pdf:
r.plm_pdf = base64.b64encode(self.getPDF(r))
r.refresh_plm_instruction_pdf()
return ret

def getPDF(self, workorder_id):
def refresh_plm_instruction_pdf(self):
self.ensure_one()
if self.operation_id.use_plm_pdf:
self.plm_pdf = base64.b64encode(self.getAttachmentWorkorderPDF())

def getAttachmentWorkorderPDF(self):
self.ensure_one()
report_model = self.env["report.plm.product_production_one_pdf_latest"]
return report_model._render_qweb_pdf(workorder_id.product_id, checkState=True)
return report_model._render_qweb_pdf(self.product_id,
checkState=True)

def fetch_release_attachment(self, workorder_id):
if self.view_plm_pdf:
Expand Down
3 changes: 3 additions & 0 deletions plm_pdf_workorder/views/mrp_routing_workcenter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='worksheet_type']" position="before">
<field name="use_plm_pdf"/>
<button name="refresh_plm_instruction_pdf"
type="object"
icon="fa-refresh"/>
<field name="plm_pdf" invisible="use_plm_pdf == False" widget="pdf_viewer"/>
</xpath>
<xpath expr="//field[@name='worksheet_type']" position="attributes">
Expand Down
3 changes: 3 additions & 0 deletions plm_pdf_workorder/views/mrp_workorder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<group>
<group>
<field name="view_plm_pdf" string="View PLM PDF" invisible="1"/>
<button name="refresh_plm_instruction_pdf"
type="object"
icon="fa-refresh"/>
</group>
<group>
<field name="use_plm_pdf" string="Use PLM PDF" invisible="1"/>
Expand Down

0 comments on commit 6e639f2

Please sign in to comment.