Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhao committed Oct 23, 2023
1 parent 2228880 commit 42511fd
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 166 deletions.
7 changes: 0 additions & 7 deletions wms_connector/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
"data/cron.xml",
"data/ir_filters.xml",
"views/wms_product_sync.xml",
"views/attachment_queue.xml",
"views/stock_picking.xml",
"views/product_product.xml",
"views/stock_warehouse.xml",
],
"demo": [
"demo/wms_product_sync.xml",
"demo/attachment_queue.xml",
"demo/stock_picking.xml",
"demo/product_product.xml",
"demo/stock_warehouse.xml",
"demo/storage_backend.xml",
],
}
2 changes: 1 addition & 1 deletion wms_connector/data/ir_filters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]</field>
</record>
<record model="ir.filters" id="default_wms_export_picking_out_filter">
<field name="name">WMS: Default filter picking out</field>
<field name="name">WMS: Default filter for picking out</field>
<field name="model_id">stock.picking</field>
<field name="domain">[
("wms_export_date", "=", False),
Expand Down
12 changes: 0 additions & 12 deletions wms_connector/demo/attachment_queue.xml

This file was deleted.

12 changes: 0 additions & 12 deletions wms_connector/demo/product_product.xml

This file was deleted.

12 changes: 0 additions & 12 deletions wms_connector/demo/stock_picking.xml

This file was deleted.

12 changes: 0 additions & 12 deletions wms_connector/demo/stock_warehouse.xml

This file was deleted.

12 changes: 0 additions & 12 deletions wms_connector/demo/wms_product_sync.xml

This file was deleted.

60 changes: 54 additions & 6 deletions wms_connector/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"name_fragment": "exports (products, awaiting receptions, preparation orders",
"code": "wh = env['stock.warehouse'].browse({0})\n"
"wh.{1}.scheduler_export("
'"wms.product.sync", wh["wms_product_sync_filter_id"]._get_eval_domain()'
'"wms.product.sync", wh._wms_domain_for("wms_product_sync")'
")\n"
"wh.{1}.scheduler_export("
'"stock.picking", wh["wms_export_picking_in_filter_id"]._get_eval_domain()'
'"stock.picking", wh._wms_domain_for("pickings_in")'
")\n"
"wh.{1}.scheduler_export("
'"stock.picking", wh["wms_export_picking_out_filter_id"]._get_eval_domain()'
'"stock.picking", wh._wms_domain_for("pickings_out")'
")",
},
"reception": {
Expand Down Expand Up @@ -73,6 +73,15 @@ class StockWarehouse(models.Model):
)
wms_product_sync_ids = fields.One2many("wms.product.sync", "warehouse_id")

def _wms_domain_for(self, model_domain):
domains = {
"wms_product_sync": [("warehouse_id", "=", self.id)]
+ self.wms_product_sync_filter_id._get_eval_domain(),
"pickings_in": self.wms_export_picking_in_filter_id._get_eval_domain(),
"pickings_out": self.wms_export_picking_out_filter_id._get_eval_domain(),
}
return domains[model_domain]

def _inverse_active_wms_sync(self):
for rec in self:
if rec.active_wms_sync:
Expand Down Expand Up @@ -138,9 +147,6 @@ def _deactivate_crons_tasks(self):
rec[mappings["fieldname_task"]].active = False
rec[mappings["fieldname_cron"]].active = False

def action_open_flows(self):
return {"type": "ir.action"}

def refresh_wms_products(self):
for rec in self:
prd_with_sync = self.wms_product_sync_ids.product_id
Expand All @@ -160,3 +166,45 @@ def refresh_wms_products(self):
("product_id", "in", (prd_with_sync - prd_matching).ids),
]
).unlink()

def button_open_wms_sync_ids(self):
return {
"name": "WMS synchronized products",
"view_mode": "tree,form",
"views": [
(self.env.ref("wms_connector.wms_product_sync_tree_view").id, "tree"),
(self.env.ref("wms_connector.wms_product_sync_form_view").id, "form"),
],
"res_model": "wms.product.sync",
"type": "ir.actions.act_window",
"target": "current",
"domain": self._wms_domain_for("wms_product_sync"),
}

def button_open_wms_pickings_in(self):
return {
"name": "WMS synchronized transfers",
"view_mode": "tree,form",
"views": [
(False, "tree"),
(False, "form"),
],
"res_model": "stock.picking",
"type": "ir.actions.act_window",
"target": "current",
"domain": self._wms_domain_for("pickings_in"),
}

def button_open_wms_pickings_out(self):
return {
"name": "WMS synchronized transfers",
"view_mode": "tree,form",
"views": [
(False, "tree"),
(False, "form"),
],
"res_model": "stock.picking",
"type": "ir.actions.act_window",
"target": "current",
"domain": self._wms_domain_for("pickings_out"),
}
12 changes: 0 additions & 12 deletions wms_connector/tests/test_import.py

This file was deleted.

17 changes: 0 additions & 17 deletions wms_connector/views/attachment_queue.xml

This file was deleted.

17 changes: 0 additions & 17 deletions wms_connector/views/product_product.xml

This file was deleted.

22 changes: 14 additions & 8 deletions wms_connector/views/stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<!-- <record model="ir.ui.view" id="stock_picking_form_view">-->
<!-- <field name="name">stock.picking.form (in wms_connector)</field>-->
<!-- <field name="model">stock.picking</field>-->
<!-- <field name="inherit_id" ref="TODO othermodule.form_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- &lt;!&ndash; TODO &ndash;&gt;-->
<!-- </field>-->
<!-- </record>-->
<record model="ir.ui.view" id="stock_picking_form_view">
<field name="name">stock.picking.form (in wms_connector)</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<header position="inside">
<button
name="button_trigger_export"
type="object"
string="Trigger export"
/>
</header>
</field>
</record>



Expand Down
41 changes: 25 additions & 16 deletions wms_connector/views/stock_warehouse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@
<field name="code" position="after">
<field name="active_wms_sync" />
</field>

<div class="oe_button_box" position="inside">
<button
name="button_open_wms_sync_ids"
string="WMS sync'd products"
icon="fa-refresh"
class="oe_stat_button"
type="object"
/>
<button
name="button_open_wms_pickings_in"
string="View pickings in"
icon="fa-refresh"
class="oe_stat_button"
type="object"
/>
<button
name="button_open_wms_pickings_out"
string="View pickings out"
icon="fa-refresh"
class="oe_stat_button"
type="object"
/>
</div>

<xpath expr="//notebook" position="inside">
<page
name="wms_sync"
Expand Down Expand Up @@ -39,26 +64,10 @@
type="object"
string="Refresh WMS products"
/>
<field name="wms_product_sync_ids">
<tree>
<field name="name" />
<field name="product_id" />
</tree>
</field>
</group>
</page>
</xpath>

<div class="oe_button_box" position="inside">
<button
name="action_open_flows"
string="View flows"
icon="fa-refresh"
class="oe_stat_button"
type="object"
/>
</div>

</field>
</record>

Expand Down
35 changes: 13 additions & 22 deletions wms_connector/views/wms_product_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,20 @@
</field>
</record>

<!-- <record model="ir.ui.view" id="wms_product_sync_search_view">-->
<!-- <field name="name">wms.product.sync.search (in wms_connector)</field>-->
<!-- <field name="model">wms.product.sync</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <search>-->
<!-- &lt;!&ndash; TODO &ndash;&gt;-->
<!-- </search>-->
<!-- </field>-->
<!-- </record>-->

<!-- <record model="ir.ui.view" id="wms_product_sync_tree_view">-->
<!-- <field name="name">wms.product.sync.tree (in wms_connector)</field>-->
<!-- <field name="model">wms.product.sync</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <tree>-->
<!-- &lt;!&ndash; TODO &ndash;&gt;-->
<!-- <field name="name"/>-->
<!-- </tree>-->
<!-- </field>-->
<!-- </record>-->
<record model="ir.ui.view" id="wms_product_sync_tree_view">
<field name="name">wms.product.sync.tree (in wms_connector)</field>
<field name="model">wms.product.sync</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="product_id" />
<field name="warehouse_id" />
</tree>
</field>
</record>

<record model="ir.actions.act_window" id="wms_product_sync_act_window">
<field name="name">Wms Product Sync</field> <!-- TODO -->
<field name="name">Wms Product Sync</field>
<field name="res_model">wms.product.sync</field>
<field name="view_mode">tree,form</field>
<field name="domain">[]</field>
Expand All @@ -57,7 +48,7 @@

<record model="ir.ui.menu" id="wms_product_sync_menu">
<field name="name">Wms Product Sync</field>
<field name="parent_id" ref="stock.menu_stock_root" /> <!-- TODO -->
<field name="parent_id" ref="stock.menu_stock_root" />
<field name="action" ref="wms_product_sync_act_window" />
<field name="sequence" eval="16" />
</record>
Expand Down

0 comments on commit 42511fd

Please sign in to comment.