Skip to content

Commit

Permalink
wms_connector: ADD a smart button to the picking view form that links to
Browse files Browse the repository at this point in the history
the wms export
  • Loading branch information
FranzPoize committed Nov 28, 2023
1 parent 0f2e0a9 commit e1be055
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
21 changes: 19 additions & 2 deletions wms_connector/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ class StockPicking(models.Model):
_inherit = ["synchronize.exportable.mixin", "stock.picking"]
_name = "stock.picking"

wms_connector_exported = fields.Boolean(String="Exported to WMS", compute="_compute_wms_exported", readonly=True, store=True)
is_wms_exportable = fields.Boolean(compute="_compute_is_wms_exportable", readonly=True, store=True)
wms_connector_exported = fields.Boolean(
String="Exported to WMS",
compute="_compute_wms_exported",
readonly=True,
store=True,
)
is_wms_exportable = fields.Boolean(
compute="_compute_is_wms_exportable", readonly=True, store=True
)

@api.depends("wms_export_attachment")
def _compute_wms_exported(self):
Expand All @@ -20,3 +27,13 @@ def _compute_wms_exported(self):
def _compute_is_wms_exportable(self):
for rec in self:
rec.is_wms_exportable = rec.picking_type_id.warehouse_id.active_wms_sync

def action_show_export(self):
self.ensure_one()
return {
"name": "WMS export",
"type": "ir.actions.act_window",
"res_model": "attachment.queue",
"view_mode": "form",
"res_id": self.wms_export_attachment.id,
}
29 changes: 22 additions & 7 deletions wms_connector/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,30 @@
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<header position="inside">
<field name="wms_connector_exported" invisible="True"/>
<field name="is_wms_exportable" invisible="True"/>
<field name="wms_connector_exported" invisible="True" />
<field name="is_wms_exportable" invisible="True" />
<button
name="button_trigger_export"
type="object"
string="Export to WMS"
attrs="{'invisible': ['|', ('wms_connector_exported', '=', True), ('is_wms_exportable', '=', False)]}"
/>
</header>
<xpath expr="//div[@name='button_box']" position="inside">
<button
name="action_show_export"
attrs="{'invisible': [('wms_connector_exported', '=', False)]}"
class="oe_stat_button"
type="object"
icon="fa-list"
help="View export attachment"
>
<div class="o_form_field o_stat_info">
<span class="oe_stat_text">WMS export</span>
</div>
</button>
</xpath>
</field>
</record>

<record model="ir.ui.view" id="stock_picking_search">
Expand All @@ -26,12 +41,12 @@
<field name="inherit_id" ref="stock.view_picking_internal_search" />
<field name="arch" type="xml">
<filter name="starred" position="after">
<field name="wms_connector_exported" invisible="True"/>
<field name="wms_connector_exported" invisible="True" />
<filter
string="Not WMS exported"
name="not_wms_exported"
domain="[('wms_connector_exported', '=', False)]"
/>
/>
</filter>
</field>
</record>
Expand All @@ -42,9 +57,9 @@
<field name="inherit_id" ref="stock.vpicktree" />
<field name="arch" type="xml">
<field name="state" position="after">
<field name="wms_connector_exported" invisible="True"/>
<field name="is_wms_exportable" invisible="True"/>
<field name="wms_connector_exported" optional="True"/>
<field name="wms_connector_exported" invisible="True" />
<field name="is_wms_exportable" invisible="True" />
<field name="wms_connector_exported" optional="True" />
</field>
</field>
</record>
Expand Down

0 comments on commit e1be055

Please sign in to comment.