Skip to content

Commit

Permalink
wms_connector: ADD wms_connector_exported and is_wms_exportable fields
Browse files Browse the repository at this point in the history
This allows to display the export to wms contextually and display wms_connector export state in tree view
  • Loading branch information
FranzPoize committed Nov 28, 2023
1 parent 6923c08 commit 0f2e0a9
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
15 changes: 14 additions & 1 deletion wms_connector/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Copyright 2023 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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


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)

@api.depends("wms_export_attachment")
def _compute_wms_exported(self):
for rec in self:
rec.wms_connector_exported = bool(rec.wms_export_attachment)

@api.depends("picking_type_id.warehouse_id.active_wms_sync")
def _compute_is_wms_exportable(self):
for rec in self:
rec.is_wms_exportable = rec.picking_type_id.warehouse_id.active_wms_sync
32 changes: 31 additions & 1 deletion wms_connector/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,45 @@
<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"/>
<button
name="button_trigger_export"
type="object"
string="Trigger export"
string="Export to WMS"
attrs="{'invisible': ['|', ('wms_connector_exported', '=', True), ('is_wms_exportable', '=', False)]}"
/>
</header>
</record>

<record model="ir.ui.view" id="stock_picking_search">
<field name="name">stock.picking.search (in wms_connector)</field>
<field name="model">stock.picking</field>
<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"/>
<filter
string="Not WMS exported"
name="not_wms_exported"
domain="[('wms_connector_exported', '=', False)]"
/>
</filter>
</field>
</record>

<record model="ir.ui.view" id="stock_picking_tree_view">
<field name="name">stock.picking.tree (in wms_connector)</field>
<field name="model">stock.picking</field>
<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>
</field>
</record>


</odoo>

0 comments on commit 0f2e0a9

Please sign in to comment.