Skip to content

Commit

Permalink
[MOD] update changes regarding plm_pdf_workorder
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Jan 17, 2025
1 parent df009fc commit bdd165f
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 46 deletions.
29 changes: 21 additions & 8 deletions plm/models/ir_attachment_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class PlmDocumentRelations(models.Model):
_name = 'ir.attachment.relation'
_description = "Relation between document used for cad file structure"

parent_preview = fields.Binary(related="parent_id.preview",
string=_("Parent Preview"),
store=False)
Expand Down Expand Up @@ -82,12 +82,26 @@ class PlmDocumentRelations(models.Model):
default=False,
readonly=True)
notes = fields.Char(string="Notes: ")

preview_related = fields.Image(
compute="_compute_preview_related",
store=True, attachment=False,
max_height=1920, max_width=1920,
string=_("Child Parent Preview")
)

_sql_constraints = [
('relation_uniq', 'unique (parent_id,child_id,link_kind)', _('The Document Relation must be unique !')),
('parent_child_check', 'CHECK (parent_id <> child_id)', _('Parent child product must be different !'))
('relation_uniq', 'unique (parent_id,child_id,link_kind)', _('The Document Relation must be unique !')),
('parent_child_check', 'CHECK (parent_id <> child_id)', _('Parent child product must be different !'))
]

@api.depends('parent_id.preview', 'link_kind', 'child_id')
def _compute_preview_related(self):
for rec in self:
if not rec.child_preview and rec.child_id and rec.link_kind == 'ExtraTree' and rec.parent_id.preview:
rec.preview_related = rec.parent_id.preview
else:
rec.preview_related = False

def copy(self, default=None):
if not default:
default = {}
Expand Down Expand Up @@ -188,7 +202,7 @@ def is_2d_ok(self, from_ir_attachment_id):
if relation_id.child_id.document_type=='2d' and relation_id.parent_id.document_type in ['3d','pr'] :
if relation_id.child_id.getLastCadSave()<relation_id.parent_id.getLastCadSave():
return False
return True
return True

def is_pr_ok(self, from_ir_attachment_id):
for relation_id in self.search(["|",('parent_id','=',from_ir_attachment_id.id),
Expand All @@ -201,7 +215,6 @@ def is_pr_ok(self, from_ir_attachment_id):
if relation_id.child_id.document_type=='pr' and relation_id.parent_id.document_type==['2d','3d']:
if relation_id.child_id.write_date < relation_id.parent_id.write_date:
return False
return True


return True

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
57 changes: 31 additions & 26 deletions plm/views/ir_attachment_relations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<hr style="background-color: rgba(0, 170, 34, 0.66);height: 1px;"></hr>
</span>
<span colspan="4"
style="color: rgb(218, 159, 34);"
style="color: rgb(218, 159, 34);"
invisible="parent_state != 'undermodify'">
<hr style="background-color: rgb(218, 159, 34);height: 1px;"></hr>
</span>
Expand Down Expand Up @@ -69,7 +69,7 @@
invisible="parent_linked in [False, []]"/>
</group>
<span colspan="4"
style="color: rgb(110, 51, 197);"
style="color: rgb(110, 51, 197);"
invisible="parent_state != 'draft'">
<hr style="background-color: rgb(110, 51, 197);height: 1px;"></hr>
</span>
Expand All @@ -84,7 +84,7 @@
<hr style="background-color: rgba(0, 170, 34, 0.66);height: 1px;"></hr>
</span>
<span colspan="4"
style="color: rgb(218, 159, 34);"
style="color: rgb(218, 159, 34);"
invisible="parent_state != 'undermodify'">
<hr style="background-color: rgb(218, 159, 34);height: 1px;"></hr>
</span>
Expand Down Expand Up @@ -135,7 +135,12 @@
<field name="child_state" readonly="True" style="color: rgb(231, 43, 26);" invisible="child_state != 'obsoleted'"/>
</group>
<group colspan="1" col="1">
<field name="child_preview" colspan="2" widget="image" readonly="1" nolabel="1" options="{'size':[400,400],'zoom': true, 'zoom_delay': 800}"/>
<field name="child_preview" colspan="2" widget="image"
readonly="1" nolabel="1" invisible="child_preview == False"
options="{'size':[400,400],'zoom': true, 'zoom_delay': 800}"/>
<field name="preview_related" colspan="2" widget="image"
readonly="1" nolabel="1" invisible="child_id == False or child_preview != False"
options="{'size':[400,400],'zoom': true, 'zoom_delay': 800}"/>
</group>
<group colspan="1" col="1">
<field name="child_linked" invisible="True"/>
Expand Down Expand Up @@ -179,7 +184,7 @@
<group>
<field name="notes"/>
</group>
</sheet>
</sheet>
</form>
</field>
</record>
Expand All @@ -189,19 +194,19 @@
<field name="model">ir.attachment.relation</field>
<field name="inherit_id" ref="plm.plm_docbom_form_view" />
<!-- <field name="groups_id" eval="[(6, 0, [ref('plm.group_plm_admin')])]" /> -->
<!-- Inherited view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition -->
<field name="arch" type="xml">
<!-- Inherited view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition -->
<field name="arch" type="xml">
<field name="parent_id" position="attributes">
<attribute name="readonly">0</attribute>
</field>
<attribute name="readonly">0</attribute>
</field>
<field name="child_id" position="attributes">
<attribute name="readonly">0</attribute>
</field>
<attribute name="readonly">0</attribute>
</field>
<field name="configuration" position="attributes">
<attribute name="readonly">0</attribute>
</field>
<attribute name="readonly">0</attribute>
</field>
<field name="link_kind" position="attributes">
<attribute name="readonly">0</attribute>
<attribute name="readonly">0</attribute>
</field>
</field>
</record>
Expand Down Expand Up @@ -235,17 +240,17 @@
<search string="Search on Document Relations">
<field name="parent_type"/>
<field name="child_type"/>
<filter
name="last_year"
string="Last Year"
<filter
name="last_year"
string="Last Year"
domain="[('create_date','&gt;=',(datetime.date.today() - relativedelta(days=1,months=1,years=1)).strftime('%%Y-%%m-%%d'))]"/>
<filter
name="last_month"
string="Last Month"
<filter
name="last_month"
string="Last Month"
domain="[('create_date','&gt;=',(datetime.date.today() - relativedelta(days=1,months=1)).strftime('%%Y-%%m-%%d'))]"/>
<filter
name="last_week"
string="Last Week"
<filter
name="last_week"
string="Last Week"
domain="[('create_date','&gt;=',(datetime.date.today() - datetime.timedelta(weeks=2)).strftime('%%Y-%%m-%%d'))]"/>
<separator orientation="vertical"/>
<field name="parent_state"/>
Expand Down Expand Up @@ -514,7 +519,7 @@
<td>
<t><strong>Name:</strong></t>
<field name="child_id"/>
<field name="display_name"
<field name="display_name"
invisible="child_id not in [False, []]"/>
</td>
</tr>
Expand Down Expand Up @@ -601,11 +606,11 @@
<record model="ir.actions.act_window" id="act_view_doc_related">
<field name="name">View Document Relations</field>
<field name="res_model">ir.attachment.relation</field>
<field name="binding_model_id" ref="model_ir_attachment"/>
<field name="binding_model_id" ref="model_ir_attachment"/>
<field name="view_mode">kanban,list,form</field>
<field name="view_id" ref="plm_docbom_list_view"/>
<field name="domain">['|', ('child_id', 'in', context.get('active_ids', [])), ('parent_id', 'in', context.get('active_ids', []))]</field>
</record>

</data>
</odoo>
8 changes: 6 additions & 2 deletions plm/views/ir_attachment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,13 @@
</t>
</td>
</tr>
<tr>
<td>
<field name="datas" filename="name" widget="binary"/>
</td>
</tr>
<tr>
<td>
<field name="datas" filename="name" widget="binary"/>
<t><strong>Name:</strong></t>
<field name="engineering_code"
readonly="id not in [False, [], 0]"/>
Expand Down Expand Up @@ -513,7 +517,7 @@
</td>
</tr>
<tr name="attachment_button_box">
<td name="attachment_button_box">
<td name="attachment_button_box" style="display: inline-flex;">
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion plm_automated_convertion/view/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<field name="inherit_id" ref="plm.document_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="//td[@name='attachment_button_box']" position="inside">
<button name="show_convert_wizard" type="object" class="btn btn-primary btn-sm">
<button name="show_convert_wizard" type="object" class="btn btn-primary btn-sm ms-1">
<i class="fa fa-openid"></i>
Convert
</button>
Expand Down
16 changes: 14 additions & 2 deletions plm_pdf_workorder/views/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@
<field name="model">ir.attachment</field>
<field name="inherit_id" ref="plm.document_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='related_not_update']" position="after">
<field name="is_production_doc" widget="boolean_toggle"/>
<xpath expr="//table/tr" position="inside">
<td>
<span>Prod Doc:</span>
<field name="is_production_doc" widget="boolean_toggle" readonly="context.get('readonly', False)"/>
</td>
<field name="doc_seq" invisible="1"/>
</xpath>
<xpath expr="//td[@name='attachment_button_box']" position="inside">
<button name="%(plm.report_ir_attachment_pdf)d"
class="btn btn-primary btn-sm ms-1"
type="action"
invisible="printout == False">
<i class="fa fa-file-pdf-o"></i>
PDF
</button>
</xpath>
</field>
</record>
</odoo>
3 changes: 0 additions & 3 deletions plm_pdf_workorder/views/mrp_routing_workcenter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='worksheet_type']" position="before">
<field name="use_plm_docs"/>
<!-- <button name="refresh_plm_instruction_pdf"-->
<!-- type="object" icon="fa-refresh"/>-->
<!-- <field name="plm_pdf" invisible="use_plm_docs == False" widget="pdf_viewer"/>-->
</xpath>
<xpath expr="//field[@name='worksheet_type']" position="attributes">
<attribute name="invisible">use_plm_docs == True</attribute>
Expand Down
3 changes: 2 additions & 1 deletion plm_pdf_workorder_enterprise/models/mrp_workorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def action_open_workorder_kanban(self):
ctx.update({
"create": False,
"delete": False,
'default_res_ids': self.production_doc_ids.ids
'default_res_ids': self.production_doc_ids.ids,
'readonly': True
})

return {
Expand Down
4 changes: 2 additions & 2 deletions plm_spare/views/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<field name="arch" type="xml">
<xpath expr="//table/tr" position="inside">
<td>
Spare Part:
<field name="used_for_spare" widget="boolean_toggle"/>
<span>Spare Part:</span>
<field name="used_for_spare" widget="boolean_toggle" readonly="context.get('readonly', False)"/>
</td>
<td>
<div class="fa fa-gear fa-2x"
Expand Down
2 changes: 1 addition & 1 deletion plm_web_3d/views/ir_attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<xpath expr="//td[@name='attachment_button_box']" position="inside">
<button type="object"
name="show_releted_3d"
class="btn btn-primary btn-sm"
class="btn btn-primary btn-sm ms-1"
invisible="has_web3d==False">
<i class="fa fa-cube"></i>
WebGl
Expand Down

0 comments on commit bdd165f

Please sign in to comment.