Skip to content

Commit

Permalink
[ADD] ir_attachment.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Dec 13, 2024
1 parent df629a2 commit 7bc9fae
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 7 deletions.
1 change: 1 addition & 0 deletions plm_box/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"data/plm_box_sequence_data.xml",
"views/non_cad_doc.xml",
"views/box_object_rel.xml",
"views/ir_attachment.xml"
],
"installable": True,
"application": False,
Expand Down
10 changes: 6 additions & 4 deletions plm_box/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class Plm_box_document(models.Model):
_inherit = "ir.attachment"

name = fields.Char(_("Attachment Name"), required=False)
is_plm_box = fields.Boolean('Is Plm Box document')

@api.model
@api.model_create_multi
def create(self, vals):
if not vals.get("name", False):
name = self.getNewSequencedName(vals)
vals["name"] = name
for val in vals:
if not val.get("name", False):
name = self.getNewSequencedName(val)
vals["name"] = name
return super(Plm_box_document, self).create(vals)

def getCheckOutUser(self):
Expand Down
3 changes: 2 additions & 1 deletion plm_box/models/plm_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def checkIfDocChanged(self, values):
return [], False

@api.model
def getBoxesStructureFromServer(self, primaryBoxes):
def getBoxesStructureFromServer(self, primaryBoxes, parameters, kwargs):
"""
*** CLIENT ***
Function called by "Add" button in the plm client
Expand Down Expand Up @@ -705,6 +705,7 @@ def getBoxStructure(self, primary=False):
outDict["description"] = boxBrws.description
outDict["state"] = boxBrws.engineering_state
outDict["readonly"] = boxBrws.boxReadonlyCompute()

return outDict

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
14 changes: 14 additions & 0 deletions plm_box/security/plm_security.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="group_plm_box_user" model="res.groups">
<field name="name">Plm Box User</field>
<field name="category_id" ref="plm.odooplm_module_category"/>
</record>

<record id="group_plm_box_admin" model="res.groups">
<field name="name">Plm Box Administrator</field>
<field name="category_id" ref="plm.odooplm_module_category"/>
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
<field name="implied_ids" eval="[(4, ref('plm_box.group_plm_box_user'))]"/>
</record>


<!-- model_plm_box -->
<record id="plm_plm_backupdoc_wizard_view" model="ir.model.access">
<field name="name">PLM Box</field>
Expand Down
64 changes: 64 additions & 0 deletions plm_box/views/ir_attachment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_attachment_form_plm_box" model="ir.ui.view">
<field name="name">ir.attachment.form.box</field>
<field name="model">ir.attachment</field>
<field name="type">form</field>
<field name="inherit_id" ref="plm.view_attachment_form_plm_hinerit"/>
<field name="arch" type="xml">
<field name="is_plm" position="after">
<field name="is_plm_box" readonly="1"/>
</field>
</field>
</record>

<record id="plm_box_attachment_tree" model="ir.ui.view">
<field name="name">plm.box.attachment.tree</field>
<field name="model">ir.attachment</field>
<field name="type">list</field>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<list string="Attachments">
<button name="toggle_check_out"
icon="fa-lock"
type="object"
invisible="is_checkout == True"
string="Check-Out">
</button>
<button name="toggle_check_out"
icon="fa-unlock"
invisible="is_checkout == False"
type="object"
string="Check-In">
</button>
<field name="checkout_user"/>
<field name="name"/>
<field name="datas"/>
<field name="engineering_state"/>
<field name="create_uid"/>
<field name="create_date"/>
<field name="write_uid"/>
<field name="write_date"/>
<field name="is_checkout" invisible="True"/>
</list>
</field>
</record>

<record model="ir.actions.act_window" id="action_box_docs">
<field name="name">BOX Documents</field>
<field name="res_model">ir.attachment</field>
<field name="view_mode">list,form</field>
<field name="search_view_id" ref="plm.ir_attachment_search"/>
<field name="context">{"odooPLM":True}</field>
<field name="domain">[('is_plm_box', '=', True)]</field>
</record>

<menuitem
name="BOX Documents"
action="plm_box.action_box_docs"
groups="plm_box.group_plm_box_admin"
id="menu_box_docs"
sequence="21"
parent="plm.ir_attachment_form"/>

</odoo>
4 changes: 2 additions & 2 deletions plm_box/views/non_cad_doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@
<field name="view_mode">list,form</field>
<field name="view_id" ref="plm_box_list"/>
</record>

getBoxesStructureFromServer
<menuitem
name="Search on BOX"
name="BOX Non CAD Document Relations"
action="action_non_cad_doc"
id="menu_non_cad_doc_relations"
parent="plm.ir_attachment_form"/>
Expand Down

0 comments on commit 7bc9fae

Please sign in to comment.